NYCPHP Meetup

NYPHP.org

Fwd: Re: [nycphp-talk] image display

Michael Southwell michael.southwell at nyphp.com
Sun Aug 26 20:19:29 EDT 2007


oops, forgot to set $num correctly:

>If I understand correctly what you are trying to do, the simple way 
>to do this is to end a row and start a new row in your table every 
>time you have finished displaying four rows from the database, like 
>this, using your $num variable:
><table>
><tr>

$num = 0;

>// loop through result
>// display stuff

$num ++;

>if ( $num % 4 == 0 ) echo '</tr><tr>';
>}
></tr>
></table>
>
>>Here is the code:
>>
>>require_once('connect/mysql_connect.php');
>>
>>$query="SELECT item_id, modelnum, name, upload, size, description, 
>>price, gender FROM clothing ORDER BY item_id ASC";
>>   $result=@mysql_query($query);
>>     $num=@mysql_num_rows($result);
>>$col = 0;
>>echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" 
>>align="center">';
>>
>>if($num>0) {
>>while($row=mysql_fetch_array($result)) {
>>if($col == 0)
>>echo '<tr>';
>>
>>
>>echo '<td align="center" width="20%"><font 
>>color="teal">cAclOm'.$row['modelnum'].'</font>
>><span style="padding-left:5%">'.$row['name'].'</span><br /><br />
>><img src="/coles/admin/new_images/'.$row['upload'].'" width="120" 
>>height="140" /><br />
>>'.$row['description'].'<span style="padding-left:5%">'.$row['price'].'</span>
>></td>';
>>
>>if($col == 0)
>>
>>echo '</tr>';
>>
>>$col++;
>>$col = ($col == 4) ? 0 : $col;
>>}
>>}
>>echo '</table>';
>>_______________________________________________
>>New York PHP Community Talk Mailing List
>>http://lists.nyphp.org/mailman/listinfo/talk
>>
>>NYPHPCon 2006 Presentations Online
>>http://www.nyphpcon.com
>>
>>Show Your Participation in New York PHP
>>http://www.nyphp.org/show_participation.php
>
>Michael Southwell, Vice President for Education
>New York PHP
>http://www.nyphp.com/training - In-depth PHP Training Courses
>
>
>_______________________________________________
>New York PHP Community Talk Mailing List
>http://lists.nyphp.org/mailman/listinfo/talk
>
>NYPHPCon 2006 Presentations Online
>http://www.nyphpcon.com
>
>Show Your Participation in New York PHP
>http://www.nyphp.org/show_participation.php

Michael Southwell, Vice President for Education
New York PHP
http://www.nyphp.com/training - In-depth PHP Training Courses





More information about the talk mailing list