|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
Displaying quered results into an HTML Table
I have a MySQL table with 7 columns. The information stored in the table is: Name of the commitee, Chairmans last name, first name, advisers last name, firstname E-maill address and what division they fall under. After the table is queried I want it to show the information in multiple html tables. I unfortunetly don't know the best way of doing this. You can see the layout of the tables I want the queried results displayed(actually that is the information in the DB) at http://www.suanhacky.org/leb.php
__________________
CHornJr "One day I'll know what I am doing" ![]() My Blog Suanhacky Lodge #49 Rebel Squadrons |
|
#2
|
|||
|
|||
|
Re: Displaying quered results into an HTML Table
Quote:
The best way is to copy your record-set into an array. From the array create your html table. A foreach loop should do the trick as far as looping through the array. Now you can reuse this array to create more tables. -- Wil Moore III www.wilmoore.com
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
||||
|
||||
|
Would I have to create the table and the array variable in each column like
PHP Code:
|
|
#4
|
||||
|
||||
|
Quote:
You may want to take a look at this class: http://www.phpclasses.org/browse.html/package/632.html Quote:
Otherwise, the answer to your question would be yes. You would need to echo/print the array variable, however, you only need to do it once. Code:
<table>
<?php
while ( $result = $somthing ) {
?>
<tr>
<td><? echo "$result[1]" ?></td>
<td><? echo "$result[2]"></td>
</tr>
<?php
}
?>
</table>
You could also use a foreach loop, but you had better check that there are elements in the array first. |
|
#5
|
||||
|
||||
|
Those of you who have tried ot help me thank you. I really do appreciate it eventhough after this post you might not belive it or believe it and realize I am an absolute idiot.
Currently the site I am working is for a non-profit organization. When the site was first done the list of it's execuitive board was done strictly in html. its coding is in the attached tet file. you can see the finished product at http://www.suanhacky.org/leb.php. What I want to do with this is have it read froma database so I can have the chiefs update information as it changes and have it display the information automatically instead of having to go into an html file and change the information every time there is a change in the executive board. I also want to keep the tables looking as they look now. Now the PHP code below is a far as I have gotten so far in coding this. I don't know if I should use "mysql_fetch_row" or "mysql_fetch_array" or if there is a better function that I should be using for what I want. PHP Code:
Now If I can't keep this page looking the as it does now with how i set things up that is fine. |
|
#6
|
|||
|
|||
|
Try the attached file.
It is all setup for you to just add your html. It used a very simple mysql class called DbConnect.class.php. The part of the code that reads: PHP Code:
can be taken out as it is just for testing the array to see if it got populated. The real work is done here: PHP Code:
This allows $dbArray to be populated with the rows from the query. It acts as your recordset. Hope this helps. |
|
#7
|
||||
|
||||
|
Is there a way to get php to go to the next row in the mysql table that doesn't incldue looping?
|
|
#8
|
||||
|
||||
|
Forget about my last reply. I got it working and I did the coding myself instead of someone elses work. Yahoo!!!!!!!! Those of oyu who answeredmy questions and gave me smaple code thanks. Now I need to work on the login and update forms for this. Be prepared for another set of stupid questions
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Displaying quered results into an HTML Table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|