could use a little help (html tables from mysql data)

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
Shamu
Forum Newbie
Posts: 5
Joined: Thu Aug 08, 2002 7:55 pm
Contact:

could use a little help (html tables from mysql data)

Post by Shamu »

Hello,

I am trying to make a gallery for movies in php to display data from my mysql database in a table with 3 colums and a row for each 3 more movies in the database until it finishes. I am very new to php and could use some help. It barely works now and when it does it displays the same data in all 3 colums.. how do I get it to display the different data in each cell? any help is much appreciated!

<body bgcolor="#FFFFFF" text="#6666FF">
<?
$dbase = mysql_connect("localhost","user","password") or die ("Cant connect to sql");
mysql_select_db("family",$dbase) or die ("Cant connect to database");

$results = mysql_query("SELECT * FROM movies ORDER BY moviename DESC");

print "<center><table>";

while(list($catagory, $moviename, $filesize, $time)=mysql_fetch_row
($results))
{
print "<tr><td>

<div align=\"center\">
<a href="\$moviename\"><img src =\"$moviename".".jpg\">
<br>Filesize $filesize KB
<br>download button
<\div></td>
<td>
<a href="\$moviename\"><img src =\"$moviename".".jpg\">
<br>Filesize $filesize KB
<br>download button
<\div>
</td>
<td>
<a href="\$moviename\"><img src =\"$moviename".".jpg
<br>Filesize $filesize KB
<br>download button
<\div>
</td>
</tr>";
}

?>
MattF
Forum Contributor
Posts: 225
Joined: Sun May 19, 2002 9:58 am
Location: Sussex, UK

Post by MattF »

Try this:

Code: Select all

<body bgcolor="#FFFFFF" text="#6666FF">
<?
$dbase = mysql_connect("localhost","user","password") or die ("Cant connect to sql");
mysql_select_db("family",$dbase) or die ("Cant connect to database");

$results = mysql_query("SELECT * FROM movies ORDER BY moviename DESC");

print "<center><table>";
$cell = "1";
while(list($catagory, $moviename, $filesize, $time)=mysql_fetch_row
($results))
&#123;
if($cell == "1") &#123;
    echo "<tr>";
&#125;
print "<td>
<div align="center">
<a href="\$moviename"><img src ="$moviename".".jpg">
<br>Filesize $filesize KB
<br>download button
<\div></td>";
if($cell == "3") &#123;
echo "</tr>";
$cell = 0;
&#125;
$cell++;
&#125;

?>
Post Reply