happypete Posted September 30, 2009 Share Posted September 30, 2009 This is for a simple photo upload script, i want to be able to display the description e image order in a text box so they can be edited and update, but it doesn't save the update. Im ne to this and have spend the last 2 days trying to get it to work... <form method="POST" action=""> <? include('config.php'); $result = mysql_query("SELECT * FROM photo ORDER BY rank ASC") or die("Bad query: ".mysql_error()); while ( $row = mysql_fetch_array($result) ) $result = mysql_query("UPDATE photo SET rank='{$_POST['rank']}', description='{$_POST['description']}' WHERE id=$id"); mysql_query($result) or die(mysql_error()); echo (mysql_affected_rows()) ? "Photo Edited.<br />" : "Nothing changed. <br />"; { ?> <input type="text" name="<? print $row['rank'] ;?>" size="2" value="<? print $row['rank'] ;?>"> <input type="text" name="<? print $row['description'] ;?>" size="" value="<? print $row['description'] ;?>"> <input type="text" name="<? print $row['id'] ;?>" size="" value="<? print $row['id'] ;?>"> <? echo "<img src=\"".$row['tn_src']."\"/>"; echo " <a href=delete1.php?id={$row['id']}>Delete</a>"; ?><br> <? } // END WHILE ?> <input type="submit" value=" Update " name="submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/176018-cant-get-it-to-read-and-update/ Share on other sites More sharing options...
smerny Posted September 30, 2009 Share Posted September 30, 2009 echo "UPDATE photo SET rank='{$_POST['rank']}', description='{$_POST['description']}' WHERE id=$id"; try that once and see what the output is... see if its what you're wanting ...otherwise, what is it doing exactly? Quote Link to comment https://forums.phpfreaks.com/topic/176018-cant-get-it-to-read-and-update/#findComment-927474 Share on other sites More sharing options...
happypete Posted September 30, 2009 Author Share Posted September 30, 2009 tried that but it just printed the words... ok the above code produces the result: "Query was empty" so basically i'm trying to get the script to print to output multiple 'rank' and 'descriptions' and Update them.... I can get it to work with just a single ID query but not the array.. Quote Link to comment https://forums.phpfreaks.com/topic/176018-cant-get-it-to-read-and-update/#findComment-927480 Share on other sites More sharing options...
smerny Posted September 30, 2009 Share Posted September 30, 2009 well i guess this is the syntax i normally use $query = "UPDATE photo SET rank='".$_POST['rank']."', description='".$_POST['description']."' WHERE id='".$id."'"; $result = mysql_query($query) or die("Bad query: ".mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/176018-cant-get-it-to-read-and-update/#findComment-927637 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.