Jump to content

Display Table Items


mileslevi

Recommended Posts

I have movies in a table each with an row id, title, description, rating, cover img url, and some other things but those are the main ones. I want php to display all the movies in a html table with the cover image to the left and title description so on to the right in "squares" 6 wide. Each "square" contains a different movie. The link to the movie is displayed in details.php?id=(id of movie). I would like them to be displayed alphabetically by title but not necessary.

Link to comment
https://forums.phpfreaks.com/topic/151106-display-table-items/
Share on other sites

details.php gets the id of the movie and displays the info and cover in html:

<?php 
$id = $_GET['id'];
$link = mysql_connect("localhost", "user", "pass"); 
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("movies") or die(mysql_error()) ; 
$result = mysql_query("SELECT * FROM data
WHERE id='$id'");

while($row=mysql_fetch_object($result)){
        $tit=$row->title;
        $yer=$row->year;
	$des=$row->description;
	$qua=$row->quality;
	$cvr=$row->cover;
	$loc=$row->file_loc;
   		$oth=$row->other_info;
   
    }
mysql_close($link);
?>...
<table width="450" border="0" cellspacing="0" cellpadding="0">
         <tr>
           <td width="19%">Title:</td>
           <td width="81%"><?php echo $tit ?></td>
         </tr>
         <tr>
           <td>Year:</td>
           <td><?php echo $yer ?></td>
         </tr>
ad so on..
       </table>

 

I need php to index all the movies in the sql table alphabetically and i want them to be displayed in an html table with a link to the detail page with the corresponding id to the movie (ie. movie 1 links to details.php?id=1)

 

SEE DIAGRAM

 

diagram.jpg

 

 

Link to comment
https://forums.phpfreaks.com/topic/151106-display-table-items/#findComment-793868
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.