All details of a single record of MySQL table in one pageWe have seen how to display records of a mysql table here. Now we will learn how to display one record in a single page. This is required where full details of a record are to be shown in a page. Usually the records unique id is used to collect the details from the table. So same php page is used and the value of unique id of the record is taken as a variable. Before that links to different records are displayed and on click the full details are shown. So we will fist start with displaying a group of records with link to individual records.
Displaying Links to individual recordsWe will use our student table where we have added two more columns ( fields ) to store address and image. As we have more records so to restrict number of records we will display records of a particular class. The query is here.
select * from student where class='Four' order by idUsing the above query we will display the records by keeping them inside an html table. At the top of the script we will connect to MySQL database.
Here is the code.
You can see we have used the name field to display a hyper link and by clicking that the individual record can be displayed in details.php page. We have formatted the hyper link to carry the student id in query string.
|PHP MySQL Data Display|
PHP functions to execute query to manage database, tables & records|
PHP MySql Data Display
Displaying details of record on click by user
Displaying record details with edit option
Displaying one record in a page with all details
Displaying records without repetitions of same field data
PHP Paging or breaking records per page
I was banging my head for more than 2 weeks on how to accomplish this task. Thanks for sharing. Well explained.
I would like to go 1 step further. How can I get the database result opens in a new page.
|Simple and Good.|
|Hey man I was looking for this, you have safe my life, thank you very much...|
|Hi how can I fix the problem with Notice: Undefined index: id.|
I have tested with $id = isset($_GET['id']) ? $_GET['id'] : ''; but send a Data Error; but everything is OK what am I doing wrong?