Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 4 of 4 FirstFirst ... 234
Results 46 to 55 of 55
  1. #46
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    722
    Thanks
    20
    Thanked 84 Times in 84 Posts
    sorry wrote it on here lol missed the end off
    PHP Code:
    echo '<img src="'.$row[imagefilename].'"/> '
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  2. #47
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Did some research based on your code and found the one below works.

    PHP Code:
    echo '<img src="/images/gallery/'.$row['file'].'" />'
    Is it possible to restrict the size of the image displayed based on this code?

  3. #48
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    722
    Thanks
    20
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by Foster View Post
    Did some research based on your code and found the one below works.

    PHP Code:
    echo '<img src="/images/gallery/'.$row['file'].'" />'
    Is it possible to restrict the size of the image displayed based on this code?
    sure:


    PHP Code:
    echo '<img src="/images/gallery/'.$row['file'].'" width="300" height="300"/>'
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  4. #49
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    My brain really isn't working as I never even thought of that. Can I maintain the aspect ratio at the same time?

  5. #50
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    722
    Thanks
    20
    Thanked 84 Times in 84 Posts
    http://www.codekites.com/php-resize-...s-imagemagick/

    http://php.net/manual/en/imagick.examples-1.php

    or


    something like:

    PHP Code:
    $size=GetimageSize($this->file['tmp_name']);
                if (
    $size[0] > $this->maxWidth){
                    if (
    $size[1] > $this->maxHeight){
                        
    $width=round($this->maxHeight*$size[0]/$size[1]);
                        
    $height=$this->maxHeight;
                    }else{
                        
    $width=$this->maxWidth;
                        
    $height=round($this->maxWidth*$size[1]/$size[0]);
                    }
                    switch(
    $this->file['type'])
                    {
                        case 
    'image/jpeg':
                            
    $images_orig imagecreatefromjpeg($this->file['tmp_name']);
                            break;
                        case 
    'image/jpg':
                            
    $images_orig imagecreatefromjpeg($this->file['tmp_name']);
                            break;
                        case 
    'image/png':
                            
    $images_orig imagecreatefrompng($this->file['tmp_name']);
                            break;
                        case 
    'image/gif':
                            
    $images_orig imagecreatefromgif($this->file['tmp_name']);
                            break;
                    }

                    
    $photoX ImagesX($images_orig);
                    
    $photoY ImagesY($images_orig);
                    
    $images_fin imagecreatetruecolor($width$height);
                    
    imagecopyresampled($images_fin$images_orig0000$width+1$height+1$photoX$photoY);

                    switch(
    $this->file['type'])
                    {
                        case 
    'image/jpeg':
                            
    imagejpeg($images_fin,'images/'.$this->file['name']);
                            break;
                        case 
    'image/jpg':
                            
    imagejpeg($images_fin,'images/'.$this->file['name']);
                            break;
                        case 
    'image/png':
                            
    imagepng($images_fin,'images/'.$this->file['name']);
                            break;
                        case 
    'image/gif':
                            
    imagegif($images_fin,'images/'.$this->file['name']);
                            break;
                    }
                

                    
    imagedestroy($images_orig);
                    
    imagedestroy($images_fin); 
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  6. #51
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Ok, last thing. I have the photo being brought up along with the rest of the information from a table, the problem is I can either have it above, in between or under the data. I am however wanting the image to the right hand side of several lines of text. My current code is below.

    PHP Code:
    <?php
        
    // Connect to database server
        
    mysql_connect("host""user","password") or die (mysql_error ());

        
    // Select database
        
    mysql_select_db("database") or die(mysql_error());

        
    // Get data from the database depending on the value of the id in the URL
        
    $strSql "SELECT * FROM IGarmy WHERE id= "$_GET['id'];
    $rs mysql_query($strSql) or die(mysql_error());
        
        
    // Loop the recordset $rs
        
    while($row mysql_fetch_array($rs))
      {
      
                     
      
    // Write the data of the person
            
    echo "<table>";
      echo 
    "<th>Regiment Name:</th> <td>" $row['regname'] . "</td>";  
      echo 
    "<tr>";
      echo 
    "<th>Homeworld:</th> <td>" $row['homeworld'] . "</td>";
      echo 
    "<tr>";
      echo 
    "<th>Commanders Name:</th> <td>" $row['Comname'] . "</td>";
      echo 
    "<tr>";
      echo 
    "<th>Estimated Regiment Size:</th> <td>" $row['regsize'] . "</td>";
      echo 
    "<tr>";
      echo 
    "<th>Unit Type:</th> <td>" $row['unittype'] . "</td>";
      echo 
    "<tr>";
      echo 
    "<th>Gender:</th> <td>" $row['gender'] . "</td>";
      echo 
    "<tr>";
      echo 
    "<th>Allegiance:</th> <td>" $row['allegiance'] . "</td>";
      echo 
    "<tr>";
      echo 
    "<th>Prefered Special Weapon:</th> <td>" $row['specialweapon'] . "</td>";
      echo 
    "<tr>";
      echo 
    "<th>Prefered Heavy Weapon:</th> <td>" $row['heavyweapon'] . "</td>";
        echo 
    "</table>";
      echo 
    "<table>";
      echo 
    '<img src="/images/gallery/'.$row['file'].'" width="150" height="150" />';
      echo 
    "</table>";
      echo 
    "<table>";
      echo 
    "<th>Background:</th> <tr> <td>" $row['Background'] . "</td>";
      echo 
    "</tr>";
      echo 
    "</tr>";
      echo 
    "<th>Historical Figures:</th> <tr> <td>" $row['HistoricalFigures'] . "</td>";
       echo 
    "</tr>";
      echo 
    "</tr>";
      echo 
    "<th>Notable Campaigns:</th> <tr> <td>" $row['campaigns'] . "</td>";
      echo 
    "<th></th> <td></td>";
        echo 
    "</table>";
        echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
        echo 
    "<th></th> <td></td>";
     echo 
    "</tr>";
        echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
        echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
        echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
        echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
        echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
        echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
        echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
        echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
        echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
        echo 
    "<th></th> <td></td>";
      }
    echo 
    "</table>";
    mysql_close();
    ?>

  7. #52
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Never mind I fixed it, on to the next job.

  8. #53
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Arcticwarrio View Post
    sorry i had to clean your code up, there was lots of HTML missing

    PHP Code:
    $con=mysqli_connect("host","user","password","database");
    // Check connection
    if (mysqli_connect_errno()){
      echo 
    "Failed to connect to MySQL: " mysqli_connect_error();
    }
    $result mysqli_query($con,"SELECT * FROM IGarmy WHERE Comname = '".$_SESSION['Comname']."'");    
    $row mysqli_fetch_array($result);
    mysqli_close($con);


    echo 
    "
    <form method='post' action='update.php'>
    <table border='0'>
        <tr>
            <th>Commanders Information</th>
            <td></td>
        </tr>
        <tr>
              <th>Commanders Name:</th>
            <td><input type='text' name='Comname' value='$row[Comname]' size='50'></td>
        </tr>
          <tr>
              <th>Password:</th>
            <td><input type='password' name='password' value='$row[password]'></td>
          </tr>
          <tr>
          </tr>
          <tr>
            <th>Imperial Guard Regiment Information</th>
            <td></td>
        </tr>
        <tr>
              <th>Regiment Name:</th>
            <td><input type='text' name='name' value='$row[name]' size='35'></td>
        </tr>
          <tr>
              <th>Homeworld:</th>
            <td><input type='text' name='homeworld' value='$row[homeworld]' size='35'></td>
          </tr>
        <tr>
              <th>Estimated Regiment Size:</th>
            <td><input type='text' name='regsize' value='$row[regsize]' size='35'></td>
          </tr>
        <tr>
              <th>Unit Type:</th>
            <td>"
    ;
      
    $UTYPES = array("Infantry","Artillery","Cavalry","Drop Troop","Mechanized","Armoured","Penal Unit","PDF","Mixed","Ab-Human");

    echo 
    '<select name="unittype">';
    foreach(
    $UTYPES as $k1 => $v1) {
        if (
    $row['unittype'] == $v1){
            echo 
    '
            <option value="'
    .$v1.'" selected="selected">'.$v1.'</option>';
        }else{
            echo 
    '
            <option value="'
    .$v1.'" >'.$v1.'</option>';
        }
    }
    echo 
    "
        </select></td>
          <tr>
              <th>Gender:</th>
            <td><input type='text' name='gender' value='$row[gender]'></td>
          </tr>
        <tr>
              <th>Allegiance:</th>
            <td><input type='text' name='allegiance' value='$row[allegiance]'></td>
        </tr>
          <tr>
              <th>Prefered Special Weapon:</th>
            <td><input type='text' name='specialweapon' value='$row[specialweapon]'></td>
          </tr>
        <tr>
              <th>Prefered Heavy Weapon:</th>
            <td><input type='text' name='heavyweapon' value='$row[heavyweapon]' ></td>
          </tr>

          <tr>
              <th>Background:</th>
            <td></td>
        </tr>
        <tr>
            <td colspan='2'><textarea name='Background' cols=\"75\" rows=\"15\"> $row[Background] </textarea></td>
          </tr>
        <tr>
              <th>Historical Figures:</th>
            <td></td>
        </tr>
        <tr>
            <td colspan='2'><textarea name='HistoricalFigures' cols=\"75\" rows=\"15\">$row[HistoricalFigures]</textarea></td>
          </tr>
        <tr>
              <th>Notable Campaigns:</th>
            <td></td>
        <tr>
        <td colspan='2'><textarea name='campaigns' cols=\"75\" rows=\"15\">$row[campaigns]</textarea></td>
          </tr> 
      
        </table>
        <input type=\"submit\" name=\"submit\" value=\"Update Information\">
        </form>"

    This code doesn't work correctly, I have just been informed that it stops the text boxes below it from working and will not update.

  9. #54
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    722
    Thanks
    20
    Thanked 84 Times in 84 Posts
    what does the script for the textboxes below it look like?
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  10. #55
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    It shows the boxes and the information that it should but when the form is submitted it doesn't carry the information over to the server.


 
Page 4 of 4 FirstFirst ... 234

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •