Finding variables from my post data by their names?
Posted: Sun Jun 05, 2005 8:09 am
Hi all 
I have a loop that draws part of a form for me, it looks like this:
This is fine except it gives each and every checkbox the same name (ie: 'present').
What I want is to say, name each checkbox individually, using the $id appended, for example:
Assuming this works (my code may be a bit out, but in theory it should be fine) I then get individually named checkboxes, which is great, but when I then go to read the post data, how can I know what the names will be? There could be 10 selections, all taken from the database with different $id values appended.
So my question is: How can I pull the individual variables from my post data by their names, if I don't know what the names are? Is there some kind of function to parse the post data, extract names and use them to create variables for use in my php project?
Currently I've been doing it manually like below, but I know it won't work, as I said, I don't know what they will be called, nor how many will be selected:
This one is really tricky for a post data neub like myself, it's an interesting one though, I have to say. 
Any advice really appreciated,
Rob
I have a loop that draws part of a form for me, it looks like this:
Code: Select all
<?
mysql_select_db($dbname);
$sql = "SELECT * FROM tablename ORDER BY id ASC";
$content = mysql_query($sql);
$Xcontent = mysql_fetch_array($content);
$cShowMax = mysql_num_rows($content);
for ($y=1; $y<=$cShowMax; $y++)
{
$id = $Xcontent["id"];
$present = $Xcontent["present"];
echo "<input name=\"present\" type=\"checkbox\" value=\"$present\">$present<br>";
$Xcontent = mysql_fetch_array($content);
}
mysql_free_result($content);
?>What I want is to say, name each checkbox individually, using the $id appended, for example:
Code: Select all
echo "e;<input name=\"e;present_$id\"e; type=\"e;checkbox\"e; value=\"e;$present\"e;>$present<br>"e;;So my question is: How can I pull the individual variables from my post data by their names, if I don't know what the names are? Is there some kind of function to parse the post data, extract names and use them to create variables for use in my php project?
Currently I've been doing it manually like below, but I know it won't work, as I said, I don't know what they will be called, nor how many will be selected:
Code: Select all
$get_present = $_GET['present'];Any advice really appreciated,
Rob