so i'm trying to add an "auto-increment" for my table for every value that has id=1, but the message
"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in"
keeps on popping up. So now i'm stuck on what to do. I think maybe LIMIT is the thing causing my problems. Please help. Thanks =)
Code:
$id=1;
$con=mysql_connect("localhost","databse","asdf");
if (!$con) die('Could not connect:'.mysql_error());
mysql_select_db("database", $con);
$numrow=mysql_query("SELECT COUNT(pid) FROM pictures WHERE id='$id'");
while($row=mysql_fetch_array($numrow)) {
$totalrow=$row['COUNT(pid)'];}
for($idid=0; $idid<=($totalrow-1); $idid++) {
$ppid=mysql_query("SELECT * FROM pictures WHERE id='$id' ORDER BY pid LIMIT '$idid',1");
$rows=mysql_fetch_object($ppid); }
while($rows=mysql_fetch_array($ppid)) {
mysql_query("UPDATE pictures SET idid='$idid' WHERE id='$id' AND pid='$rows[pid]'");
mysql_close($con);