Hi,

I retrieve all students from database with adding submit buttons along with them. For example; when i click on 3rd student’s submit button, it gives me information of last retrieved student. How can solve this problem? Note : All action is in same page.

Thanks

<?php
while ($myArray = mysql_fetch_array ($runSql, MYSQLI_ASSOC)) {
	$id = $myArray['id'];
	$name = $myArray['name'];
?>
<tr>
	<td><?php echo $myArray['id']; ?></td>
	<td><?php echo $myArray['name']; ?></td>						
	<td><input type="submit" name="seeButton" value="Details" ></td>
</tr>
<?php
}
?>

Recommended Answers

All 2 Replies

Hi veledrom,

This is what I would do:

<?php

while($array = mysql_fetch_assoc($result)) // Iterate through list of students
{
	$id = $array['id'];
	$name = $array['name'];

        if($_POST['student_' . $id]) $class = 'current';
?>
<tr>
	<td><?php echo $id; ?></td>
	<td><?php echo $name; ?></td>						
	<td><input type="submit" name="student_<?php echo $id; ?>" value="Details"></td>
</tr>
<?php
}

?>

Solved. I haven forgotton the Form to cover buttons in main Form.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.