| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() | PHP: putting returned mysql data in individual table cells how do i loop through returned mysql data, putting each element in its own <td> using multiple rows? i.e. if i have thumbnails which i want displayed three to a row, how do i do the loops? can somebody please give me some advice on how to do this?
__________________ Bais Menachem
Last edited by whyme953; 08-19-2005 at 07:24 PM.
|
| |
| | #2 (permalink) |
| Senior Member Join Date: Jul 2004 Location: Kizmiaz
Posts: 1,088
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | I just put together a quick example of one way to handle formatting and table layouts. It should be enough to get you on your way. PHP Code:
__________________ 1 Cent Web Hosting @ Online HostGatorVoucher.com Adsense Hack for Vbulletin - Fully 3.6 Compatible ForexArea.com Free E-Course in Programming EA's |
| |
| | #3 (permalink) |
| DNOA Member Join Date: May 2004
Posts: 5,040
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | PHP Code: |
| |
| | #4 (permalink) | ||||
| Senior Member Join Date: Jul 2004 Location: Kizmiaz
Posts: 1,088
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Lux
__________________ 1 Cent Web Hosting @ Online HostGatorVoucher.com Adsense Hack for Vbulletin - Fully 3.6 Compatible ForexArea.com Free E-Course in Programming EA's | ||||
| |
| | #5 (permalink) |
| NamePros Regular Join Date: Mar 2005
Posts: 921
![]() ![]() ![]() ![]() ![]() | you can use this way together all the information from your table. just replace the important variables & table/column names to the owns you have or want. PHP Code:
__________________ Live Support : Zubair11 [at] hotmail.com Free SEO Directory! || Free Online TV || Tech Blog Web Design & Web Development Services || Reliable Web Hosting |
| |
| | #7 (permalink) | ||||
| Senior Member Join Date: Jul 2004 Location: Kizmiaz
Posts: 1,088
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
The OP's question was not how to display data in A (as in one) cell but how to display it in a variable number of cells and rows. The example I gave shows a way to display any number of cells in any format you choose. Sorry to be pedantic but attention to detail is part of being a good programmer ![]() So while your code obviously will work it doesn't address the OP's problem. Lux PS: Zubair1 - Your code is wrong for the same reason.
__________________ 1 Cent Web Hosting @ Online HostGatorVoucher.com Adsense Hack for Vbulletin - Fully 3.6 Compatible ForexArea.com Free E-Course in Programming EA's | ||||
| |
| | #9 (permalink) |
| Live Chat Operator Join Date: Jun 2005 Location: NY
Posts: 881
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Might I suggest not using multiple <td>'s... but rather... <div>'s? PHP Code: ![]() I'm using the code above on a domain portfolio site that I'm currently working on... http://www.gdzo.com... As you can see... you can easily give the illusion of having multiple <tr>'s & <td>'s this way. Hope this helps.
__________________ ` ... .
Last edited by greatdomainz; 08-20-2005 at 11:23 AM.
|
| |
| | THREAD STARTER #10 (permalink) |
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() | thank you very much to all of you who responded. to make my problem clear: i need multiple rows with multiple objects in each row. i.e. how do i put every 3 <td>'s within a <tr>?? (my issue is not how to print the <td> tag, its how to make multiple rows) to luxinterior: thanx a lot, i tried something using that same basic idea, the problem is that it printed out each record times the total number of records instead of looping through all the records (if there were 3 records it would print each one three times etc.) i will try fooling around with your code a bit and see if i get anywhere... once again thanks to everybody for your help
__________________ Bais Menachem |
| |
| | THREAD STARTER #11 (permalink) |
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() | figured it out. there is probably a easier/simpler/better way than what i did but it does the trick. (i didnt make a max. num of rows and pagination as i will never have too many records for a page) here goes: PHP Code:
__________________ Bais Menachem
Last edited by whyme953; 08-21-2005 at 03:40 AM.
|
| |
| | #12 (permalink) |
| Senior Member Join Date: Jul 2004 Location: Kizmiaz
Posts: 1,088
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Glad you got it sorted whyme953, well done! Something else you may want to look into and try to adopt into your normal devlopment process is seperating functionality from design. Theres' loads of reasons to do it so I won't go over old ground. Here's a really useful link that will open your eyes to the idea of templating and I promise you once you get used to it you'll wonder why you didn't use it before. http://www.massassi.com/php/articles/template_engines/ Take it easy! Lux
__________________ 1 Cent Web Hosting @ Online HostGatorVoucher.com Adsense Hack for Vbulletin - Fully 3.6 Compatible ForexArea.com Free E-Course in Programming EA's |
| |
| | THREAD STARTER #13 (permalink) | ||||
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=116972 thats something i've been working on doing lately. if i'm not mistaken (correct me if i'm wrong) the only thing that would apply to in this case is the <table></table> tags, it actualy crossed my mind to fix that, i just got a bit lazy.
__________________ Bais Menachem | ||||
| |
| | #14 (permalink) |
| Senior Member Join Date: Jul 2004 Location: Kizmiaz
Posts: 1,088
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Well what I'd do is use that templating system and load variables. Take out ALL html. Your objective should be to remove as much html as possible. When you have to change the look of your site etc you'll be glad you developed using templates. One of the suggestions above was also pretty good and something I do. Having perhaps a 'row.tpl' with three cells and variables like var1, var2 and var3 then just do a loop loading each variable, build a html string (using the templates) and then sending it to another .tpl. Sounds complicated but once you get the hang of it it's pretty straight forward. Good luck Lux
__________________ 1 Cent Web Hosting @ Online HostGatorVoucher.com Adsense Hack for Vbulletin - Fully 3.6 Compatible ForexArea.com Free E-Course in Programming EA's |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Googlism - What does google think of you? | deadserious | The Break Room | 55 | 12-15-2005 09:09 AM |
| Tutorial: How to Install Apache2 MySQL and PHP on Windows | deadserious | Webmaster Tutorials | 35 | 09-21-2005 09:46 PM |
| Dedicated Servers from just £45 $90 + [UK] 1 TB Data Transfer P4 3.0GHZ Only £119 | blackicehosting | Web Hosting Offers | 0 | 07-12-2005 06:24 PM |
| Tutorial: Getting Started With MySQL (The Basics) | deadserious | Webmaster Tutorials | 3 | 04-18-2004 01:17 PM |