hey I'm having a problem trying to get some variables passed on a form to another page where the processing is handled.
basically what I'm trying to do is display the titles of pages from a website that are stored on a mysql database. those titles are passed thru a variable, which is used for the name and value in the html form.
I used a loop to display the values, passing each element to a variable in php, which is coded as such for the value and name of each page title. This way no matter how many pages are added or removed in the future, I don't have to go back and manually display all pages - it just pulls the titles from a database and assigns a numeric value to them in an array.
Here is what I'm getting at, because I'm sure I'm not explaining this correctly.
...code from above
$pageName = mysql_query("select `pageName` from pages");
if(!$pageName)
{
echo "ERROR: $pageName query invalid in editMain.php <br/>";
mysql_close();
exit();
}
$rows = mysql_num_rows($pageName);
$i = 0;
while($i < $rows)
{
while($getPageName=mysql_fetch_array($pageName))
{
?>
<tr>
<td align="left">
<?php echo $getPageName['pageName'];?>
</td>
<td align="right">
<input type="radio" value="<?php $getPageName['pageName'];?>" name="<?php $getPageName['pageName'];?>">
</td>
</tr>
<?php
$i++;
}
}
and so on and so forth for the rest of the code. I'm trying to pass $getPageName into the values and names of the radio buttons - so for instance, if one of the pages is named main, that element of the array ($getPageName) will be assigned Main for the first round of the loop.
My problem is getting the next page to carry that variable over (the value of the variable changes due to the user deciding which page he/she wants to edit) and assign it to the $var = $_POST assignment on the page that handles the form processing.
so I guess my ultimate question is on the next page when I try to pull the choice the user selected, how do I pull that variable using post?
it would be something like: $title = $_POST[$getPageName['pageName']'];
but I know that syntax is wrong - I got an error when I tried to run it. That's kinda where I'm stuck.
if anyone understands what I'm getting at, can you please let me know what I'm doing wrong?
I know you can also pass variables thru session handling, but since I am trying to do this strictly in php, the page the user chooses isn't set in stone until after the form is submitted. I don't think it's possible to assign a variable like that to a session variable after the form has been submitted.