Variable Variables - Page 2

Example

Let's say you have a MySQL database that stores link submissions for sites of interest.
In that database there is a table called submissions. The fields in the submissions table are as follows:

SubmissionID
PostedBy
Link
Description
Approved

You want to be able to display all the submissions that have been made but are not yet approved in
a table. The editor will then be able to correct any typing mistakes, select the proper radio
button next to each link for approval, and submit them all at once.

First, when you pull the data from the database and display it on the page you must set each name
for every record to be unique. This will enable us to loop through the records and be able to
identify what value goes where once the submit button has been pressed. To do this we do the following:

/*
Assuming we already have retrieved the records from the database into an array setting
$myrow = mysql_fetch_array(). The do...while loop assigns a value to the $xstr variable
by taking the name and concatenating the value of $index to the end starting with 0. So
the first time through the loop $SubmissionIDStr would have a value of SubmissionID0 the
next time through it would be SubmissionID1 and so forth.
*/

// I also had to create an index count to keep track of the total number of rows.

echo "<INPUT TYPE=hidden NAME=counter VALUE=$index_count>\n";

echo "<INPUT TYPE=submit></form>\n";

?>

After the submit button is pressed to we have to loop through all the variables on the page again.
We are able to do this with the $index_count variable we created. Next, we assign the value of
those variables to yet another variable in the second step. This is where variable variables come into play.