Brian V Bonini <mailto:[EMAIL PROTECTED]>
on Monday, March 01, 2004 11:00 AM said:
> while ($result = mysql_fetch_array($dbresult_riderlist)) {
> print('<tr>' . "\n");
> print("<td><input type=\"hidden\" name=\"rider_id[]\" value=\"" .
> $result["rider_id"] . '" />' . "\n");
> print("<input type=\"text\" name=\"rider_name[]\" value=\"" .
> $result["rider_name"] . '" size="15" /></td>' . "\n");
> print("<td><input type=\"text\" name=\"rider_license_cat[]\"
> value=\"" . $result["rider_license_cat"] . '" size="3" /></td>' .
> "\n"); print("<td><input type=\"text\" name=\"comments[]\" value=\"" .
> $result["comments"] . '" size="20" /></td>' . "\n");
> print("<td><input type=\"file\" name=\"image[]\" value=\"" .
> $result["image"] . '" size="10" /></td>' . "\n");
> print("<td>Edit: <input type=\"radio\" name=\"edit_rider_action[]\"
> value=\"edit\" /> Delete: <input type=\"radio\"
> name=\"edit_rider_action[]\" value=\"delete\" /></td>" . "\n");
> print('</tr>' . "\n");
i think i see some code in that jungle. allow me to clean it up a bit!
while ($result = mysql_fetch_array($dbresult_riderlist)) {
echo <<<QQQ
<tr>
<td>
<input type="hidden" name="rider_id[]" value="{$result['rider_id']}"
/>
<input type="text" name="rider_name[]"
value="{$result['rider_name']}" size="15" />
</td>
<td><input type="text" name="rider_license_cat[]"
value="{$result['rider_license_cat']}" size="3" /></td>
<td><input type="text" name="comments[]" value="{$result['comments']}"
size="20" /></td>
<td><input type="file" name="image[]" value="{$result['image']}"
size="10" /></td>
<td>Edit: <input type="radio" name="edit_rider_action[]" value="edit"
/>
Delete: <input type="radio" name="edit_rider_action[]" value="delete"
/></td>
</tr>
QQQ;
}
> I'm trying to gather the data from this form and test the condition of
> the radio button 'edit_rider_action'.
>
> I can traverse the form data array via $_POST and get the key/value
> pairs but am not sure how to test the 'edit_rider_action'.
well i think since you're doing a radio button you shouldn't have [] on
the end of your field name in the first place. the [] creates a new
element within an array, in your case an array called edit_rider_action.
but because of the way radio buttons work you will never have more than
one value for edit_rider_action so you don't need it turned into an
array after the form is submitted. therefore the following code:
<td>Edit: <input type="radio" name="edit_rider_action[]" value="edit"
/>
Delete: <input type="radio" name="edit_rider_action[]" value="delete"
/></td>
should be changed into:
<td>Edit: <input type="radio" name="edit_rider_action" value="edit" />
Delete: <input type="radio" name="edit_rider_action" value="delete"
/></td>
after the form is submitted you can get to the value of
edit_rider_action with: (
<?php
$edit_rider_action = $_GET['edit_rider_action'];
?>
note: if you submitted your form via post you'll need to use $_POST and
not $_GET.
hth,
chris.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php