hi,
I'm new in php/mysql. I'm stored student marks values in following format in mysql db table.
id student_code Tamil English Maths Science Social
1 1 100 75 78 88 95
2 2 85 90 88 80 100
But i want to search and display the specific student marks in following format.
id:1
student_code:1
Tamil:100
English:75
Maths:78
Science:88
Social:92
Total:?
Avg:?
please give correct code for this format.
display details from mysql using php
Moderator: General Moderators
-
vboopathicse
- Forum Newbie
- Posts: 1
- Joined: Wed Sep 07, 2011 3:02 am
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: display details from mysql using php
Here's what you need to display your results:
1. An SQL query i.e "SELECT * FROM table" (with a conditional clause because you only want a specific record)
2. mysql_fetch_array() which places all data returned by the query into an array
3. A while loop to iterate through the array, although you will have only one record but for now use the while loop as it's easier
4. To display the data, you will need to access the keys of the array, something like : $array['id'] will return the value of id
These things are in order, you just have to write the correct syntax for this, which isn't to difficult. Use google or browse the forum some more because the topic has probably been covered before
1. An SQL query i.e "SELECT * FROM table" (with a conditional clause because you only want a specific record)
2. mysql_fetch_array() which places all data returned by the query into an array
3. A while loop to iterate through the array, although you will have only one record but for now use the while loop as it's easier
4. To display the data, you will need to access the keys of the array, something like : $array['id'] will return the value of id
These things are in order, you just have to write the correct syntax for this, which isn't to difficult. Use google or browse the forum some more because the topic has probably been covered before
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering