Page 1 of 1

display details from mysql using php

Posted: Thu Sep 08, 2011 2:05 am
by vboopathicse
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.

Re: display details from mysql using php

Posted: Thu Sep 08, 2011 4:33 am
by social_experiment
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