Ok i have a database thats going to list all of my movies on a page. right now im using this code:
<?
include 'connect.php';
mysql_select_db("undrgrnd_mov");
$query = "select * from list ORDER BY title";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo '<table cellpadding="0" cellspacing="0" border="0" bordercolor="#FFFFFF">
<tr><td colspan=5 valign=top><font color=#000099>Total Movies: <b>'.$num_results.'</b></td></tr></table><br><br>';
echo '<table class="tex" width="400" cellpadding="0" cellspacing="0" border="0" bordercolor="#FFFFFF">';
$ss = 0;
while ($row = mysql_fetch_array($result))
{
$id=$row["id"];
$ss ++;
echo '<tr><td><a href="http://www.imdb.com/find?q='.$row["title"].';tt=on;nm=on;mx=20">'.$row["title"].'</td></tr>';
}
echo '</table><br><br>';
?>
After trying to do a nice divide i used this code:
<?
include 'connect.php';
mysql_select_db("undrgrnd_mov");
$query = "select * from list ORDER BY title";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo '<table cellpadding="0" cellspacing="0" border="0" bordercolor="#FFFFFF">
<tr><td colspan=5 valign=top><font color=#000099>Total Movies: <b>'.$num_results.'</b></td></tr></table><br>';
echo '<table cellpadding="5">';
$column = 0;
while ($row = mysql_fetch_array($result)) {
if (!$column) echo '<tr>';
echo '<td>', $row["title"], '</td>';
if ($column) echo '</tr>';
$column = !$column;
}
if ($column) echo '<td></td></tr>';
echo '</table>';
?>
The only problem with that is that the movies aren't staying in alphabetical order anymore. They are going like this
table
movie1, movie2
movie3, movie4
/table
instead i want each colum to go in alpha order like this:
table
movie1, movie5
movie2, movie6
movie3, movie7
movie4, movie8
/table
Anyone got a solution ?? 🙂