SunQuest
 
           General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Iron Speed
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old February 16th, 2003, 04:12 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
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

Reply With Quote
  #2  
Old February 16th, 2003, 09:10 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Re: Displaying quered results into an HTML Table

Quote:
Originally posted by CHornJr
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.


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.

Reply With Quote
  #3  
Old February 16th, 2003, 10:23 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
Would I have to create the table and the array variable in each column like
PHP Code:
<table><tr><td><? echo "$result[1]" ?></td><td><? echo "$result[2]"></td></tr></table

Reply With Quote
  #4  
Old February 16th, 2003, 11:55 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Quote:
Originally posted by CHornJr
Would I have to create the table and the array variable in each column like
PHP Code:
<table><tr><td><? echo "$result[1]" ?></td><td><? echo "$result[2]"></td></tr></table


You may want to take a look at this class:
http://www.phpclasses.org/browse.html/package/632.html

Quote:
This class is designed to provide a easy way to display mysql sql content
in HTML table form with pages information and navigation link.



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.

Reply With Quote
  #5  
Old February 17th, 2003, 01:28 AM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
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:
<?php
     
include('class.dbcon.php');
     
$result=mysql_query('SELECT chairname,chairaddy,advisernam,adviseraddy FROM leb') or die('Could not query table: '.mysql_error());


Now If I can't keep this page looking the as it does now with how i set things up that is fine.
Attached Files
File Type: txt leb.txt (4.6 KB, 217 views)

Reply With Quote
  #6  
Old February 17th, 2003, 03:11 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
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:
print "<pre>";
         
print_r($dbArray);
         print 
"</pre>"


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:
while($row=$db->fetchassoc()) { 
        
         
$dbArray[] = $row;
          
       } 


This allows $dbArray to be populated with the rows from
the query. It acts as your recordset.


Hope this helps.
Attached Files
File Type: zip leb.zip (2.4 KB, 330 views)

Reply With Quote
  #7  
Old February 18th, 2003, 05:58 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
Is there a way to get php to go to the next row in the mysql table that doesn't incldue looping?

Reply With Quote
  #8  
Old February 18th, 2003, 11:42 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Displaying quered results into an HTML Table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway