Jump to content

Recommended Posts

<table width="100%" align="center">
        <tr>
          <th align="left" valign="top" bgcolor="#000000" scope="row"><div align="center">
            <p> </p>
            <p><strong><u>DATA</u></strong>            </p>
            <form id="form3" name="form3" method="post" action="update.php">

	<p>
<?php

include "connection.php";

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
$count=mysql_num_rows($result);

?>
                </p>
              <table width="450" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
                <tr>
                  <td width="23" align="center" bgcolor="#000000"> </td>
                  <td width="22" align="center" bgcolor="#000000"><div align="left"></div></td>
                  <td width="120" align="center" bgcolor="#000000"><div align="left"><strong>Username</strong></div></td>
                  <td width="120" align="center" bgcolor="#000000"><div align="left"><strong>Password</strong></div></td>
                  <td width="153" align="center" bgcolor="#000000"><div align="left"><strong>Email</strong></div></td>
                  </tr>
                <?php
while($rows=mysql_fetch_array($result)){
?>
                <tr>
                  <td align="center" bgcolor="#000000"><? echo $rows['id']; ?></td>
                  <td bgcolor="#000000"><div align="left"></div></td>
                  <td bgcolor="#000000"><div align="left">
                    <input name="username2" type="text" id="username3" value="<? echo $rows['username']; ?>" />
                    </div></td>
                  <td width="120" align="center" bgcolor="#000000"><div align="justify">
                    <input name="password2" type="text" id="password3" value="<? echo $rows['password']; ?>" />
                    </div></td>
                  <td width="153" align="center" bgcolor="#000000"><div align="justify">
                    <input name="email" type="text" id="email2" value="<? echo $rows['email']; ?>" />
                    </div></td>
                  </tr>
                <?php
}
?>
                <tr>
                  <div>
                    <td align="center" bgcolor="#000000"><div align="left"></div></td>
                    <td align="left" bgcolor="#000000"> </td>
                    <td align="left" bgcolor="#000000"> </td>
                    <td align="left" bgcolor="#000000"> </td>
                    <td align="left" bgcolor="#000000"> </td>
                    </div>
                  </tr>
                <tr>
                  <td colspan="5" align="left" bgcolor="#000000"><input name="update" type="submit" id="update" value="Update" /></td>
                  </tr>
                <?
if($_POST['update'] == 'Update'){
for($i=0;$i<$count;$i++){
$update = "UPDATE $tbl_name SET username='$username', password='$password', email='$email' WHERE id='$id'";
mysql_query($update) or die(mysql_error()); 
echo "<meta http-equiv='refresh' content='2;url=update.php>";

}

else {
echo "SORRY TRY AGAIN";
echo "<meta http-equiv='refresh' content='2;url=update.php'>";
}

mysql_close();
?>
                </table>
            </form>
            <p> </p>
            <p> </p>
          </div></th>
        </tr>
    </table>

Link to comment
https://forums.phpfreaks.com/topic/161542-cant-update/
Share on other sites

So... what exactly happens?  Have you debugged anything?  Does the $id get passed correctly?  Does it echo "SORRY TRY AGAIN"?  Are there any errors?  Have you echoed out the update sql statement to see what's actually being executed?  NOTE - Use <?php tags never short-hand...

Link to comment
https://forums.phpfreaks.com/topic/161542-cant-update/#findComment-852476
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.