loops again..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
corillo181
Forum Commoner
Posts: 76
Joined: Wed Apr 26, 2006 3:02 pm

loops again..

Post by corillo181 »

ok i already learn how to work to loop table <td> and <tr> with files in a directory.. but i can't get it to work the same way when pulling information from database..

wha ti want to know it how i can't work a <td> loop and <tr> loops into this code..

Code: Select all

while($code = mysql_fetch_array($q)) { 
     echo '<a href=3-11-06/'.$code['name'].'>'.'<img border=0 height=100 width=100 src="3-11-06/'.$code['name'].'"></a>';
}
and has to be widthing this code because i'm using pagination...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

As you've been told before, read the first two threads linked to from Useful Posts.
corillo181
Forum Commoner
Posts: 76
Joined: Wed Apr 26, 2006 3:02 pm

Post by corillo181 »

yes i seen it.. but is that the way yo put the looping prosses is too complicated for me..all thos eout put and stuff take me no where..i know you just gettign all the code into variable and echo it in jus tone line.. but still.. i dont get it..
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Everything you need is in that post that feyd pointed you to. There is not really an easier way to do it.
(#10850)
corillo181
Forum Commoner
Posts: 76
Joined: Wed Apr 26, 2006 3:02 pm

Post by corillo181 »

i came with this.. everything seen to be workikng fine.. i set the amount per pages to 4 and the pages shows but the pictures don't display

Code: Select all

while($code = mysql_fetch_array($q)) { 
for($i=0; $i<$rows; $i++) { 
    echo    '<tr>'; 
    for($col=1;$col<=4;$col++) { 
     echo '<a href=3-11-06/'.$code['name'].'>'.'<img border=0 height=100 width=100 src="3-11-06/'.$code['name'].'"></a>';
	 }
	 echo"</tr>";
	 }
}
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

To display you need the <TD> html tag which you haven't written . Code must be like this if the $code['name'] stores the image name :

Code: Select all

while($code = mysql_fetch_array($q)) {
for($i=0; $i<$rows; $i++) {
    echo    '<tr>';
    for($col=1;$col<=4;$col++) {
     echo '<td><a href=3-11-06/'.$code['name'].'>'.'<img border=0 height=100 width=100 src="3-11-06/'.$code['name'].'"></a><td>';
         }
         echo"</tr>";
         }
}
:wink:
Cheers,
Dibyendra
corillo181
Forum Commoner
Posts: 76
Joined: Wed Apr 26, 2006 3:02 pm

Post by corillo181 »

yeah thans, i already got it to work soe other crazy way, but i guess i'll change it to this if it works is easier to understand, thanx :)
Post Reply