Login   Register  
PHP Classes
elePHPant
Icontem

MySQL data display in a table and clickable events

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Top level forums  >  PHP Specialists  >  General  >  MySQL data display in a table and clickable events  
Subject:MySQL data display in a table and clickable events
Summary:Get the value of current table value drawn from Mysql Database
Messages:1
Author:Teacha Kyng
Date:2013-09-17 03:23:15
Update:2013-09-17 04:27:44
 

  1. MySQL data display in a table and clickable events   Reply   Report abuse  
Picture of Teacha Kyng
Teacha Kyng
2013-09-17 04:27:44
I have a code that displays data from Mysql database. I want that when a user clicks on one of the fields drawn from the database, the database should display corresponding results of that ID.
As you can see in the code below, the code loops through data in the database and select std_id and std_name and display them in an HTML table within a form. I want that, when a user clicks on the button it should display other data in another page such as age, adress, phone... What code would I need to write? Your support will be greatly appreciated.

<?php

//database variables
require_once('admin_settings.php');


//these variables are from a form used to display the current data
$level = $_POST['level_group'];
$room = $_POST['room_group'];


$con=mysqli_connect("$host","$dbuser","$dbpass","$dbname");
mysqli_set_charset($con, "utf8");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT std_id, std_name FROM students WHERE std_level LIKE '$level%' AND std_room LIKE '$room';");

//table
echo"
<table border='1' id='mytable'>
<tr bgcolor = #99CCFF>
<th><b>Student ID</b></th>
<th><b>Name</b></th>
<th><b>Action</b></th>
</tr>";

//loop through the database



while($row = mysqli_fetch_array($result))
{
echo"<form action='view_one_student.php' method='post'>";
echo "<tr bgcolor = '#c0eae4n' id = 'listings'>";
echo "<td name= 'stdid'>" . $row['std_id'] . "</td>";
echo "<td>" . $row['std_name'] . "</td>";
echo "<td>" . '<input type="submit" value="view"> <input type="submit" value="sdq">' . "</td>";
echo "</tr>";
echo "</form>";
}
echo "</table>";

mysqli_close($con);
?>