Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Lionsanime Directory   High Bandwidth Dedicated Servers   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 08-14-2007, 11:57 AM   #1 (permalink)
Contributing Member
 
Join Date: 01-26-07
Posts: 111
iTrader: 0 / 0%
Latest Blog:
None

JustRetarded is on the right pathJustRetarded is on the right path
Need help with PhP MySQL

Hey guys i was wondering if its possible to actually split results, what i mean is that having like

5 rows showing then like a double <br> and 5 more bla bla bla... till the end of my DB.

i looked up everywhere but cant seem to find anything.

im sure its possible though lol

any advices ? thanks alot
JustRetarded is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 08-14-2007, 02:02 PM   #2 (permalink)
Contributing Member
 
Join Date: 06-11-07
Posts: 153
iTrader: 0 / 0%
Latest Blog:
None

Capo64 is on the right pathCapo64 is on the right pathCapo64 is on the right path
Pretty easily.

Code:
$con = mysql_connect("yadayada", "yada", "blah"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("blahblah", $con); $result = mysql_query("SELECT * FROM db"); $i = 0; while($row = mysql_fetch_array($result)) { echo $row['column']; $i++; if ($i >= 5) { echo "<br />"; $i = 0; } }
that should work, if not it's something similar to that you just use a counter and when it gets to 5 you echo a br and reset it.
Capo64 is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-15-2007, 09:10 AM   #3 (permalink)
Contributing Member
 
Join Date: 01-26-07
Posts: 111
iTrader: 0 / 0%
Latest Blog:
None

JustRetarded is on the right pathJustRetarded is on the right path
works great thanks alot and actually thanks to you i learned alot of new possibilities

im stupid but learning lmao
JustRetarded is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-15-2007, 03:09 PM   #4 (permalink)
v7n Mentor
 
Taltos's Avatar
 
Join Date: 11-22-06
Location: Phoenix, AZ
Posts: 1,788
iTrader: 0 / 0%
Latest Blog:
None

Taltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web pro
Send a message via Yahoo to Taltos
The one thing I would add to Capo64's solution would be to use modulus and then you don't have to reset the counter. Something like:

Code:
$i = 1; if($i % 5 = 0) echo <br />
The % is modulus which returns the remainder of a division. Everytime it is 0, you have looped 5 times. For this particular case, Capo's solution is just as good although later you may find you get into bigger projects and the modulus technique will be more useful. Have fun!
__________________
Experimenting
Taltos is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-15-2007, 11:12 PM   #5 (permalink)
Moderator
 
ToddW's Avatar
 
Join Date: 01-11-04
Location: Folsom
Posts: 2,635
iTrader: 0 / 0%
ToddW is a web professional of the highest orderToddW is a web professional of the highest orderToddW is a web professional of the highest orderToddW is a web professional of the highest orderToddW is a web professional of the highest orderToddW is a web professional of the highest orderToddW is a web professional of the highest orderToddW is a web professional of the highest orderToddW is a web professional of the highest orderToddW is a web professional of the highest orderToddW is a web professional of the highest order
Send a message via AIM to ToddW
Quote:
Originally Posted by Taltos View Post
The one thing I would add to Capo64's solution would be to use modulus and then you don't have to reset the counter. Something like:

Code:
$i = 1; if($i % 5 = 0) echo <br />
The % is modulus which returns the remainder of a division. Everytime it is 0, you have looped 5 times. For this particular case, Capo's solution is just as good although later you may find you get into bigger projects and the modulus technique will be more useful. Have fun!
Keep this stuff in mind for pagination too
__________________
Learn about Bear Grylls, Les Stroud, Man Vs. Wild & SurvivorMan at Survival TV Shows
Order Exciting Inspirational Posters from Inspirational Posters at great value.
ToddW is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySql help daniel0012 Coding Forum 4 06-28-2007 02:48 AM
MySQL help Limit Coding Forum 28 08-27-2004 05:39 AM
MySQL help cbolts Web Design Lobby 2 04-09-2004 06:39 AM
PHP/mySQL SN3 Coding Forum 5 02-03-2004 10:38 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 06:43 PM.
© Copyright 2008 V7 Inc