PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
mysql_connect("localhost", "user", "pdub") or die(mysql_error()) ;
mysql_select_db("table") or die(mysql_error()) ;
if(!isset($cmd))
{
$result = mysql_query("select * from test order by id");
while($r=mysql_fetch_array($result))
{
$title=$r["title"];//take out the title
$id=$r["id"];//take out the id
$thumb=$r["thumb"];
echo "<form><table>
<tr>
<td><input type='text' name='id' value='$id' size='3'></td><td width='350px'><strong>$title</strong></td>
</tr>
<td colspan='2' align='center'><img src='upload/test/$thumb'></td>
</table></form>
";
}
}
?>
<?
echo "<div style='text-align:center;'><a href='testorder.php?cmd=order&id=$id'>Submit</a></div>";
?>
<?
if($cmd=="order")
{
$sql = "UPDATE test SET id=$id";
$result = mysql_query($sql);
echo "UPDATED!";
echo "<a href='main.php'>Click here to return to the Administration Area.</a>";
}
}
?>
$sql = "UPDATE test SET id=$id";
$result = mysql_query($sql);
echo "UPDATED!";
echo "<a href='main.php'>Click here to return to the Administration Area.</a>";
Quotation marks aren't necessary - in fact, if the id is a number then you shouldn't use quotes - but without that WHERE it'll update every row in the table.
Nothing... you bolding the code doesn't mean anything to me. I am pretty new to PHP but am starting to understand some of this stuff. Why would I use the $GET statement for CMD? ID is the primary key.