boxcarracer8792
2010-05-31 21:33:52 UTC
I'm setting up a website and I want to be able to edit the content from the website. I have a login page, and many more pages, including a picture's page, which I want to be able to move each picture back and forth. The pictures are ordered by the 'position' field, and I'm not anywhere near professional level of programming or code, so my way is probably very complicated.
I set it up so it links you to a page like: "/?page=pictures&edit=1&p=3&t=4". the page and edit can be ignored, as they are just where at in the page to goto, but 'p' is the current position, and 't' is the target location. So I setup the update code like this...
$pict01 = mysql_real_escape_string($_GET['p']);
$pict02 = mysql_real_escape_string($_GET['t']);
mysql_query("UPDATE pictures SET position = '$pict02' WHERE position='$pict01'");
mysql_query("UPDATE pictures SET position = '$pict01' WHERE position='$pict02'");
It only updates one, so I tried multiple ways, such as having it link to a second page, and updating the second after updating the first. Or using a third and fourth variable instead of the same two. Still nothing, Then I tried a suggestion, of:
mysql_query("UPDATE pictures SET position = 'holdme' WHERE position='$pict01'");
mysql_query("UPDATE pictures SET position = '$pict01' WHERE position='$pict02'");
mysql_query("UPDATE pictures SET position = '$pict02' WHERE position='holdme'");
Still nothing, it seems to update only one thing. Every time I test, I check it before and set each one to 1-5 (there are 5 current records). After executing it, it comes in (for example), 1,3,3,4,5 or 1,2,2,4,5, or 1,2,3,3,5, etc. I've tried separating the code, nothing, even putting the numbers in, nothing. Thanks for any help in advance.