I wonder whether someone may be able to hep me please.
I’ve put together this page which allows the user to view the records saved in their account.
What I’m now trying to do is add the functionality whereby the user can select a radio button, click on the ‘Location Details’ icon, and they are taken to the ‘Details Page’ pertinent to the record which they have selected the radio button against.
The problem I’m having is that no matter which radio button I select, when I click on the icon, I’m always taken to the ‘Details Page’ for the last record. (*NB* For the purpose of this post I’ve taken the ‘submit’ action away from the button.)
The code below creates the table and ‘Location Details’ icon
<table id="theTable" width="835" class="sortable-onload-zebra no-arrow rowstyle-alt colstyle-alt paginate-20 max-pages-20 paginationcallback-callbackTest-calculateTotalRating paginationcallback-callbackTest-displayTextInfo sortcompletecallback-callbackTest-calculateTotalRating">
<thead>
<tr>
<th width="60" bgcolor="#ff8401">Select</th>
<th width="150" class="sortable-text" bgcolor="#ff8401">Location</th>
<th width="300" class="sortable-text" bgcolor="#ff8401">Address</th>
<th width="30" class="sortable-text" bgcolor="#ff8401">Finds</th>
</tr>
</thead>
<tbody>
<?php
mysql_data_seek($result, 0);
while ($row = mysql_fetch_array($result)) {
/* display row for each user */
?>
<tr height="80px">
<td style="text-align: center"><input type="radio" id="lid" name="lid" value=<?php echo $row['locationid'];?> /></td>
<td style="text-align: left"><strong><?php echo $row['locationname'];?></strong></td>
<td style="text-align: center"><?php echo $row['returnedaddress'];?></td>
<td style="text-align: center"><strong><em><?php echo $row['totalfinds'];?></em></strong></td>
</tr>
<?php
}
} else {
echo "<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan='5'><div align='center'><strong>No locations have been added yet. <a href='addlocation.php'>Click here</a> to add one.</strong></div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>";
}
?>
<form action='locationsaction.php'>
<input type='submit' class='detailsButton' name='type' value='Details' alt='Location Details' title='Location Details' style='margin-right:10px' />
</form>
</tbody>
</table>
Because I intend to have several submit buttons within one form, I’ve created the following ‘locationsaction.php’ script which you will see is called in the above script.
<?php
session_start();
$_SESSION['lid'] = $_POST['lid'];
if (isset($_POST['type'])) {
$urls = array(
'Details' => 'locationdetails.php',
'Add Finds' => 'addfinds.php',
'Images' => 'addimages.php',
'View Finds' => 'locationfinds.php'
);
$url = $urls[$_POST['type']];
header("Location: " . $url);
}
?>
I’ve been working on this for several days now and have tried several tutorials, but I just can’t seem to get this to work.
I just wondered whether someone may be able to take a look at this please and offer some guidance on how I can pass the correct radio button value through the ‘submit action.
Many thanks and kind regards
This is your current form:
Your table is not in your form at all; when you click on the submit button, it will only send details of inputs that are between the
<form>tags.If you move the
<form actiontag right to the top of the page, it should work.