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 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 55
  1. #31
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    738
    Thanks
    20
    Thanked 85 Times in 85 Posts
    P.S. you can use single quotes so you don't need to slash double quotes inside a script or echo:

    PHP Code:
    echo '<textarea cols="75" rows="15">'.$row[HistoricalFigures].'</textarea><br>'
    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. #32
    Regular Coder
    Join Date
    Nov 2011
    Posts
    252
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Ok, next issue. In the original form there are several drop down boxes, is it possible to set the edit page to include the same?

  3. #33
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    738
    Thanks
    20
    Thanked 85 Times in 85 Posts
    yes, please post your <SELECT> ... </SELECT> code
    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. #34
    Regular Coder
    Join Date
    Nov 2011
    Posts
    252
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Do you mean the code for the original drop down?

  5. #35
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    738
    Thanks
    20
    Thanked 85 Times in 85 Posts
    yes thanks
    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. #36
    Regular Coder
    Join Date
    Nov 2011
    Posts
    252
    Thanks
    8
    Thanked 4 Times in 4 Posts
    PHP Code:
    <select name="unittype">
            <
    option value="Infantry" >Infantry</option>
            <
    option value="Artillery" >Artillery</option>
            <
    option value="Cavalry" >Cavalry</option>
            <
    option value="Drop Troop" >Drop Troop</option>
            <
    option value="Mechanized" >Mechanized</option>
            <
    option value="Armoured" >Armoured</option>
            <
    option value="Penal Unit" >Penal Unit</option>
            <
    option value="PDF" >PDF</option>
            <
    option value="Mixed" >Mixed</option>
            <
    option value="Ab-Human" >Ab-Human</option>
                </
    select
    This is one of them.

  7. #37
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    738
    Thanks
    20
    Thanked 85 Times in 85 Posts
    you need something like this


    PHP Code:
    $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>'
    you can also change your original form to match:

    PHP Code:
    $UTYPES = array("Infantry","Artillery","Cavalry","Drop Troop","Mechanized","Armoured","Penal Unit","PDF","Mixed","Ab-Human");

    echo 
    '<select name="unittype">';
    foreach(
    $UTYPES as $k1 => $v1) {
            echo 
    '<option value="'.$v1.'" >'.$v1.'</option>';
    }
    echo 
    '</select>'
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  8. #38
    Regular Coder
    Join Date
    Nov 2011
    Posts
    252
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Where would I put that in to this code?

    PHP Code:
    <?php
    $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']."'");    

    echo 
    "<form method='post' action='update.php'>";
    echo 
    "<table border='0'>
    <tr>
    <th>Commanders Information</th>
    </tr>"
    ;

    while(
    $row mysqli_fetch_array($result))
      {
      echo 
    "<tr>";
      echo 
    "</tr>";
      echo 
    "</tr>";
        echo 
    "</table>";
        echo 
    "<table>";
        echo 
    "<tr>";
      echo 
    "<th>Commanders Name:</th> <td><input type='text' name='Comname' value='$row[Comname]' size='50'>";
          echo 
    "<tr>";
      echo 
    "<th>Password:</th> <td><input type='password' name='password' value='$row[password]'>";
      echo 
    "</tr>";
        echo 
    "</table>";
        echo 
    "<table>";
        echo 
    "<tr>";
      echo 
    "<tr>";
      echo 
    "</tr>";
      echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
      echo 
    "<tr>
    <th>Imperial Guard Regiment Information</th>
    </tr>"
    ;
      echo 
    "<th>Regiment Name:</th> <td><input type='text' name='name' value='$row[name]' size='35'>";
          echo 
    "<tr>";
      echo 
    "<th>Homeworld:</th> <td><input type='text' name='homeworld' value='$row[homeworld]' size='35'>";
      echo 
    "</tr>";
        echo 
    "<th>Estimated Regiment Size:</th> <td><input type='text' name='regsize' value='$row[regsize]' size='35'>";
      echo 
    "</tr>";
      echo 
    "<th>Unit Type:</th> <td><input type='text' name='unittype' value='$row[unittype]'>";
          echo 
    "<tr>";
      echo 
    "<th>Gender:</th> <td><input type='text' name='gender' value='$row[gender]'>";
      echo 
    "</tr>";
      echo 
    "<th>Allegiance:</th> <td><input type='text' name='allegiance' value='$row[allegiance]'>";
          echo 
    "<tr>";
      echo 
    "<th>Prefered Special Weapon:</th> <td><input type='text' name='specialweapon' value='$row[specialweapon]'>";
      echo 
    "</tr>";
      echo 
    "<th>Prefered Heavy Weapon:</th> <td><input type='text' name='heavyweapon' value='$row[heavyweapon]' >";
          echo 
    "<tr>";
          echo 
    "</tr>";
      echo 
    "</tr>";
       echo 
    "<th></th> <td></td>";
        echo 
    "</tr>";
        echo 
    "</table>";
        echo 
    "<table>";
        echo 
    "<tr>";
        echo 
    "<th>Background:</th> <tr></tr> <td>";
          echo 
    "<textarea name='Background' cols=\"75\" rows=\"15\"> $row[Background] </textarea><br>";
          echo 
    "</tr>";
      echo 
    "<th>Historical Figures:</th> <tr> <td>";
      echo 
    "<textarea name='HistoricalFigures' cols=\"75\" rows=\"15\">$row[HistoricalFigures]</textarea><br>";
      echo 
    "</tr>";
        echo 
    "<th>Notable Campaigns:</th> <tr> <td>";
      echo 
    "<textarea name='campaigns' cols=\"75\" rows=\"15\">$row[campaigns]</textarea><br>";
      echo 
    "</tr>";  
      }
    echo 
    "</table>";
    echo 
    "<input type=\"submit\" name=\"submit\" value=\"Update Information\">";
    echo 
    "</form>";

    mysqli_close($con);
    ?>

  9. #39
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    738
    Thanks
    20
    Thanked 85 Times in 85 Posts
    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>"

    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. Users who have thanked Arcticwarrio for this post:

    Foster (02-28-2013)

  11. #40
    Regular Coder
    Join Date
    Nov 2011
    Posts
    252
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Thanks, you're a hero. On to the photo upload now, it never ends.

  12. #41
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    738
    Thanks
    20
    Thanked 85 Times in 85 Posts
    try this:

    you'll need to add something to add it to your database tho

    PHP Code:
    define ("MAX_SIZE","500");  

    function 
    getExtension($str) { 
        
    $i strrpos($str,"."); 
        if (!
    $i) { return ""; } 
        
    $l strlen($str) - $i
        
    $ext substr($str,$i+1,$l); 
        return 
    $ext

    $errors=0
    if(isset(
    $_POST['avatar'])){ 
        
    $image=$_FILES['image']['name']; 
        if (
    $image){ 
            
    $filename stripslashes($_FILES['image']['name']); 
            
    $extension getExtension($filename); 
            
    $extension strtolower($extension); 
            if ((
    $extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { 
                echo 

                Unknown extension! 
                "

                
    $errors=1
            } else { 
            
    $size=filesize($_FILES['image']['tmp_name']); 
                if (
    $size MAX_SIZE*1024) { 
                echo 

                You have exceeded the size limit! 
                "

                
    $errors=1
                }  
                elseif (!isset(
    $_POST['image'])) { 
                    echo 

                    You must browse for a picture first! 
                    "

                    
    $errors=1;  
                } 
                if(
    $errors){ exit; }
                
    $image_name=time().'.'.$extension
                
    $newname="upload/".$image_name
                
    $copied copy($_FILES['image']['tmp_name'], $newname); 
                if (!
    $copied)  { 
                    echo 
    "             
                    Copy unsuccessfull! 
                    "

                    
    $errors=1
                }
            }
        }
    } else {
        echo 
    '
        <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
      <p>&nbsp;</p>
      <p>
        <input type="file" accept="image/jpg, image/gif" name="avatar" />
      </p>
    </form>
        '
    ;

    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  13. #42
    Regular Coder
    Join Date
    Nov 2011
    Posts
    252
    Thanks
    8
    Thanked 4 Times in 4 Posts
    I want to do it as part of the code below and have it assigned to the user in the database.

    PHP Code:
    <form action="register.php" method="post">
    <
    center>

    <
    table class="table"><tr><td background="
    colspan="2"><font><b>Commanders Information</b></td></tr>
    <
    tr><td width="20%"><font>Commanders Name:&nbsp;&nbsp;&nbsp;</td>
        <
    td width="80%"><font><INPUT TYPE="text" NAME="Comname" size="50%" value=""></td></tr>

        <
    tr><td><font>Password:&nbsp;&nbsp;&nbsp;</td>
        <
    td><font><INPUT TYPE="password" NAME="password" size="50%" value=""></td></tr>
        <
    tr><td colspan="2"></td></tr>
    </
    table><BR><BR>

    <
    table class="table"><tr><td background="/~newreno/images/background2.gif" colspan="2"><font><b>Imperial Guard Regiment Information</b></td></tr>
    <
    tr>
        <
    td width="20%"><fontRegiment Name:&nbsp;&nbsp;&nbsp;</td>
        <
    td width="80%"><INPUT TYPE="text" NAME="name" size="50%" value=""></td></tr>
    <
    tr><td width="20%"><fontHomeworld:&nbsp;&nbsp;&nbsp;</td>
        <
    td width="80%"><INPUT TYPE="text" NAME="homeworld" size="50%" value=""></td></tr>
        <
    td width="20%"><fontEstimated Regiment Size:&nbsp;&nbsp;&nbsp;</td>
        <
    td width="80%"><textarea name="regsize" cols="50%"></textarea></td></tr>
    <
    tr><td><font>Unit Type:&nbsp;&nbsp;&nbsp;</td>
        <
    td><font>
        <
    select name="unittype">
            <
    option value="Infantry" >Infantry</option>
            <
    option value="Artillery" >Artillery</option>
            <
    option value="Cavalry" >Cavalry</option>
            <
    option value="Drop Troop" >Drop Troop</option>
            <
    option value="Mechanized" >Mechanized</option>
            <
    option value="Armoured" >Armoured</option>
            <
    option value="Penal Unit" >Penal Unit</option>
            <
    option value="PDF" >PDF</option>
            <
    option value="Mixed" >Mixed</option>
            <
    option value="Ab-Human" >Ab-Human</option>
                </
    select>
        </
    td></tr>
    <
    tr><td><font>Gender:&nbsp;&nbsp;&nbsp;</td>
        <
    td><font>
        <
    select name="gender">
            <
    option value="Male" >Male</option>
            <
    option value="Female" >Female</option>
            <
    option value="Mixed" >Mixed</option>
                </
    select>

        </
    td></tr>
        <
    tr><td><font>Allegiance:&nbsp;&nbsp;&nbsp;</td>
        <
    td><font>
        <
    select name="allegiance">
            <
    option value="Loyal" >Loyal</option>
            <
    option value="Traitor" >Traitor</option>
            <
    option value="Independant" >Independant</option>
                    </
    select>
        </
    td></tr>
        <
    tr><td colspan="2">
        </
    td></tr>
    <
    tr><td><font>Prefered Special Weapon:&nbsp;&nbsp;&nbsp;</td>
        <
    td><font>
        <
    select name="specialweapon">
            <
    option value="Flamer" >Flamer</option>
            <
    option value="Melta" >Melta</option>
            <
    option value="Plasma" >Plasma</option>
            <
    option value="Sniper Rifle" >Sniper Rifle</option>
            <
    option value="Grenade Launcher" >Grenade Launcher</option>
                </
    select>
        </
    td></tr>
        <
    tr><td><font>Prefered Heavy Weapon:&nbsp;&nbsp;&nbsp;</td>
        <
    td><font>
        <
    select name="heavyweapon">
            <
    option value="Lascannon" >Lascannon</option>
            <
    option value="Mortar" >Mortar</option>
            <
    option value="Heavy Bolter" >Heavy Bolter</option>
            <
    option value="Heavy Stubber" >Heavy Stubber</option>
            <
    option value="Missile Launcher" >Missile Launcher</option>
            <
    option value="Autocannon" >Autocannon</option>
                </
    select>
        </
    td></tr>
        <
    tr><td colspan="2">
        </
    td></tr>
    </
    table>
    <
    BR><BR>


    <
    BR><BR>
    <
    table class="table"><tr><td background="/~newreno/images/background2.gif"><center><font><b>Backgroud</td></tr>
    <
    tr><td align="center"><TEXTAREA NAME="Background" ROWS="10" COLS="100"></TEXTAREA></td></tr></table>
    <
    BR><BR>
    <
    table class="table"><tr><td background="/~newreno/images/background2.gif"><center><font><b>Historical Figures</b></td></tr>
    <
    tr><td align="center"><TEXTAREA NAME="HistoricalFigures" ROWS="10" COLS="100"></TEXTAREA></td></tr></table>
    <
    BR><BR>
    <
    table class="table"><tr><td background="/~newreno/images/background2.gif"><center><font><b>Notable Campaigns</b></td></tr>
    <
    tr><td align="center"><TEXTAREA NAME="campaigns" ROWS="10" COLS="100"></TEXTAREA></td></tr></table>

        

    <
    font>
    <
    b>STOP!</b><br>
    Please check your information before pressing the submit button belowLooking over your information now will make sure editing later wont be necessaryThank you.<BR>
    <
    input type="hidden" name="FormSubmit" value="Yes">
    <
    INPUT TYPE="submit" value="Submit Regiment"> &nbsp; <INPUT TYPE="reset" value="Reset Fields">
    </
    td></tr></table

  14. #43
    Regular Coder
    Join Date
    Nov 2011
    Posts
    252
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Right, I managed to get the file to upload to the server and the file name to store alongside the relevant id in the database. The problem I have now is that I need to call the image back to be shown with the rest of the users data, I can get it to show the file name but not the actual image.

  15. #44
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    738
    Thanks
    20
    Thanked 85 Times in 85 Posts
    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

  16. #45
    Regular Coder
    Join Date
    Nov 2011
    Posts
    252
    Thanks
    8
    Thanked 4 Times in 4 Posts
    That just stops everything below it from showing.


 
Page 3 of 4 FirstFirst 1234 LastLast

Posting Permissions

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