...

View Full Version : how to display 4 cells who php and mysql



er6f
02-28-2010, 02:06 AM
hi,

am trying to list some image data from my mysql database. But i can't seem to work out how to get it into 4 rows and have the data display in order example.

+ image1 + image2 + image3 + image4 +
| image5 | image6 | image7 | image8 |
| | | | |

right now it just goes down

image1
image2
image3
image4
........

any ideas?
thanks



<?php


$conn = mysql_connect($host, $user, $pass)
OR DIE (mysql_error());
@mysql_select_db ($db, $conn) OR DIE (mysql_error());



$sql = "SELECT * FROM $table WHERE displaysub='1' ORDER BY image_date DESC LIMIT $offset, $rowsPerPage";
$result = mysql_query ($sql, $conn);
$i=0;
$str='';
if (mysql_num_rows($result)>0)
{
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$count=$row['total_votes'];//how many votes total
$current_rating=$row['total_value'];//total number of rating added together and stored
$tense=($count==1) ? "vote" : "votes";//plural form votes/vote

$i++;
$str .= "<table border='1'><tr>";
$str .= "<tr><td COLSPAN=4>Title: ".$row["title"]." <br /></td></tr>";
$str .= "<td><a href='/wac/embed.php?image_id=".$row["image_id"]."'>";
$str .= "<img height=\"100\" width=\"110\" alt=\"click image to view video\" src='/wac/".$row["file_path"]."'>
</img>
</a>
<br />
</td>";
$str .= "<td>


<ul class=\"star-rating\">".
"<li class=\"current-rating\" style=\"width:". @number_format($current_rating/$count,1)*25 ."px;\"></li>".
"<li class=\"one-star\">1</li>".
"<li class=\"twotwo-stars\" >1.5</li>".
"<li class=\"two-stars\" >2</li>".
"<li class=\"three-stars\">3</li>".
"<li class=\"fourfour-stars\">3.5</li>".
"<li class=\"four-stars\">4</li>".
"<li class=\"five-stars\">5</li>".
"</ul>".
"Rateing <strong>".@number_format($current_rating/$count,2)."</strong> [".$count." ".$tense."]<br />";

$str .= "</td></tr></table><br />";
}
print $str;


}

?>

abduraooft
02-28-2010, 02:40 PM
Take a look at http://www.codingforums.com/showthread.php?t=129466

ffmast
02-28-2010, 03:31 PM
Why can't you show pictures in 1 table, like:


<table>
<tr>
<td>PIC1</td> <td>PIC2</td> <td>PIC3</td> <td>PIC4</td>
</tr>
<tr>
<--- next 4 pictures...
</tr>
....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum