Click to See Complete Forum and Search --> : PHP mixed row colors (weird)


Jonathan
12-15-2003, 07:40 PM
I need help with this script... It is just coming up blank or in 8 cells with only a 6 cell table...

You can see a working one here: http://www.crosspoint.org/delete/sermons.php


<?
include ('header.php');
?>

<table style="border:1px solid black;" width="760px" cellpadding="3">
<tr>
<td class="sermons" width="200px">
Title</td><td class="sermons" width="188px">
Date</td><td class="sermons" width="350px">
Passage</td><td class="sermons" width="22px">
Play</td>
</tr>
<tr>
<?
mysql_pconnect("$db_host","$db_username","$db_password") or die(mysql_error());
mysql_select_db("$update_db_name") or die(mysql_error());

$query = mysql_query("select * from sermons order by date desc limit 15") or die(mysql_error());

$check = mysql_num_rows($query);
if($check == 0){
echo "<td class=\"sub_sermon_odd\" colspan=\"4\" align=center>No recorded sermons at this time</td>";
exit();
}

while ($row = mysql_fetch_array($query)){
echo "<td class=\"".$td_type."\">" . $row['title'] . "</td>";
echo "<td class=\"".$td_type."\">" . $row['date'] . "</td>";
echo "<td class=\"".$td_type."\">" . $row['passage'] . "</td>";
echo "<td class=\"".$td_type."\"><a href=\"" . $row['link'] . "\"><img src=\"images/play_button.png\" border=0></a></td>";
}
?>

Jonathan
12-15-2003, 07:42 PM
nevermind :)

olaf
12-16-2003, 01:43 AM
Hallo,

I think your table have some bad points! Where are the table rows (you start only one row) and where is the table endtag?

Jonathan
12-17-2003, 12:33 AM
no data is showing... here is what I have:


<?
include ('header.php');
?>

<table style="border:1px solid black;" width="760px" cellpadding="3">
<tr>
<td class="sermons" width="200px">
Title</td><td class="sermons" width="188px">
Date</td><td class="sermons" width="350px">
Passage</td><td class="sermons" width="22px">
Play</td>
</tr>
<?
mysql_pconnect("$db_host","$db_username","$db_password") or die(mysql_error());
mysql_select_db("sermons") or die(mysql_error());

$query = mysql_query("select * from sermons order by date desc limit 15") or die(mysql_error());

$check = mysql_num_rows($query);
if($check == 0){
echo "<td class=\"sub_sermon_odd\" colspan=\"4\" align=center>No recorded sermons at this time</td>";
exit();
}

if ($row = mysql_fetch_array($query)){
for ($i = 0; $i < count($row); $i++) {
if ($i % 2) {
$td_type = "<tr bgcolor=B0C4DE>";
} else {
$td_type = "<tr bgcolor=FOF8FF>";
}

echo "<tr>";
echo "<td class=\"".$td_type."\">" . $row['title'] . "</td>";
echo "<td class=\"".$td_type."\">" . $row['date'] . "</td>";
echo "<td class=\"".$td_type."\">" . $row['passage'] . "</td>";
echo "<td class=\"".$td_type."\"><a href=\"" . $row['link'] . "\"><img src=\"images/play_button.png\" border=0></a></td></tr>";
}}
}
?>
</table>

olaf
12-19-2003, 08:34 AM
Hallo,
for the table:
you use this as class:
<tr bgcolor=FOF8FF>

this means you using table row tag twice.

A tip:

set the table border to 1 px.

the serverside:

the rest looks goog check you query with echo and control your row-count