Here’s my script:
$sqlCommand = “SELECT * FROM events”;
$query = mysql_query($sqlCommand) or die (mysql_error());
$num = mysql_num_rows($query);
if ($num > 0)
while($row = mysql_fetch_array($query)){
$pid = $row[“id”];
$title = $row[“title”];
$displayorder = $row[“displayorder”];
echo "<h7>$title</h7>
<h4>Display Order</h4>
<form action='change_order_parse.php' method='post'>
<input name='$pid' type='text' value='$displayorder' size='5' />
<p>current ID is: $pid</p>
<input type='submit' value='Change Order' />
</form>
As you can see, I am listing the title of the event then I’m listing the ID of that row (variable of $pid). I also have a row called displayorder and have made a variable of that. Then I show the title and name the text field the ID ($pid). I then display the current order that particular event is displayed.
What I would like to do is for my user then change the display order since on the display page I am calling from MySql to order by display order ASC.
My problem is, since I’m naming my text field $pid (ID) and it’s in a fetch array, once I send it to my parse.php I can’t very well declare a new variable using $pid since it’s in a fetch array.
Hence I can’t update mysql because I can’t get the info into a variable as I would like. I tried to echo $pid for the name and that didn’t work.
Or perhaps I should scrap this method completely and someone else may have a better idea of how I can list the title of the event then change the order (displayorder in my database).
Like I said, it should be very simple to change that one item but it has me scratching my head. Right now there’s only 5 events so it’s not a huge database at this point. But the while loop was the easiest way for me to list everything there.
Thoughts?