|
 |
|
 |
06-30-2005, 09:34 AM
|
#1 (permalink)
|
|
Recruit
Join Date: Jun 2005
Posts: 4
|
help with alternate row color php script
the code is returning the following error:
Parse error: parse error, unexpected '}', expecting ',' or ';' in /home/linblood/public_html/table.php on line 82
Code:
<?php require_once('Connections/linblood.php'); ?>
<?php
$maxRows_list = 10;
$pageNum_list = 0;
if (isset($_GET['pageNum_list'])) {
$pageNum_list = $_GET['pageNum_list'];
}
$startRow_list = $pageNum_list * $maxRows_list;
mysql_select_db($database_linblood, $linblood);
$query_list = "SELECT clan, `character`, timezone, avail, email, msn FROM members ORDER BY clan DESC";
$query_limit_list = sprintf("%s LIMIT %d, %d", $query_list, $startRow_list, $maxRows_list);
$list = mysql_query($query_limit_list, $linblood) or die(mysql_error());
$row_list = mysql_fetch_assoc($list);
if (isset($_GET['totalRows_list'])) {
$totalRows_list = $_GET['totalRows_list'];
} else {
$all_list = mysql_query($query_list);
$totalRows_list = mysql_num_rows($all_list);
}
$totalPages_list = ceil($totalRows_list/$maxRows_list)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
$num=20;
// Open the HTML table before the loop
echo '<table width="667" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutDefaultTable-->
<tr>
<td width="667" height="19" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="118" height="19" valign="top">clan</td>
<td width="130" valign="top">character</td>
<td width="69" valign="top">time zone </td>
<td width="67" valign="top">availability</td>
<td width="142" valign="top">email</td>
<td width="141" valign="top">msn</td>
</tr>
</table></td>
</tr>';
for($i=0;$i<$num;$i++){
if($i % 2 ==0)
{
$bgcolor='#f3f3f3';
}
else
{
$bgcolor='#e3e3e3';
}
do {
echo '<tr bgcolor=$bgcolor>
<td height="19" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>' ?>
<td width="118" height="19" valign="top" ><?php $row_list['clan']; ?></td>
<td width="128" valign="top"><?php echo $row_list['character']; ?></td>
<td width="71" valign="top"><?php echo $row_list['timezone']; ?></td>
<td width="67" valign="top"><?php echo $row_list['avail']; ?></td>
<td width="141" valign="top"><?php echo $row_list['email']; ?></td>
<td width="142" valign="top"><?php echo $row_list['msn']; ?></td>
<?php echo '</table></td>
</tr>
<tr>
<td height="25"> </td>
</tr>
</table>'
} // line 82
?>
keep in mind that i haven't done any php in about a year, so im a bit rusty...
any help would be greatly apreciated, also i would like the code to be in php, but the html stuff to be in well html (preferably).
|
|
|
06-30-2005, 10:09 AM
|
#2 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
|
First off... I'm not quite sure if it will work or not.. but you're using " (double quotes)within your echo string, which by the way is declared as a char, by using ' (single quotes) to enclose it.
I havn't tried to use it like that, so I have no idear if it will work or not..
PHP Code:
...
<?php echo '</table></td>
</tr>
<tr>
<td height="25"> </td>
</tr>
</table>'
} // line 82
If you notice, you have a echo ending just befor the 82.nd line, which isn't rounded off by a ;, if you read the error carefully that is exactly what it describes.
So add a ; after your echo action.
|
|
|
06-30-2005, 04:25 PM
|
#3 (permalink)
|
|
Recruit
Join Date: Jun 2005
Posts: 4
|
problem continues
i changed the code but the problem persists it still returns the error...
Code:
<?php echo '</table></td>
</tr>
<tr>
<td height="25"> </td>
</tr>
</table>';
} // line 82
?>
error:
Parse error: parse error, unexpected ';', expecting T_WHILE in /home/linblood/public_html/table.php on line 83
|
|
|
06-30-2005, 10:44 PM
|
#4 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
|
I just noticed:
PHP Code:
do {
echo '<tr bgcolor=$bgcolor>
<td height="19" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>' ?>
Shouldn't there be a trailing ; here aswell??
Else I can't seem to find what should be wrong with your code. Perhaps changing every ' to " and visa versa.. To make sure echo is having a string as it's argument.
|
|
|
07-01-2005, 09:37 AM
|
#5 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,446
|
besides the 2 semicolons you are missing that red pointed out, you're missing an echo tag for $row['clan'].
you also have a 'do{' command for no reason. along with the other changes, just take that line out and you should be good to go.
PHP Code:
<?php require_once('Connections/linblood.php');
$maxRows_list = 10;
$pageNum_list = 0;
if (isset($_GET['pageNum_list'])) {
$pageNum_list = $_GET['pageNum_list'];
}
$startRow_list = $pageNum_list * $maxRows_list;
mysql_select_db($database_linblood, $linblood);
$query_list = "SELECT clan, `character`, timezone, avail, email, msn FROM members ORDER BY clan DESC";
$query_limit_list = sprintf("%s LIMIT %d, %d", $query_list, $startRow_list, $maxRows_list);
$list = mysql_query($query_limit_list, $linblood) or die(mysql_error());
$row_list = mysql_fetch_assoc($list);
if (isset($_GET['totalRows_list'])) {
$totalRows_list = $_GET['totalRows_list'];
} else {
$all_list = mysql_query($query_list);
$totalRows_list = mysql_num_rows($all_list);
}
$totalPages_list = ceil($totalRows_list/$maxRows_list)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
$num=20;
// Open the HTML table before the loop
echo '<table width="667" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutDefaultTable-->
<tr>
<td width="667" height="19" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="118" height="19" valign="top">clan</td>
<td width="130" valign="top">character</td>
<td width="69" valign="top">time zone </td>
<td width="67" valign="top">availability</td>
<td width="142" valign="top">email</td>
<td width="141" valign="top">msn</td>
</tr>
</table></td>
</tr>';
for($i=0;$i<$num;$i++){
if($i % 2 ==0)
{
$bgcolor='#f3f3f3';
}
else
{
$bgcolor='#e3e3e3';
}
echo '<tr bgcolor=$bgcolor>
<td height="19" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>'; ?>
<td width="118" height="19" valign="top" ><?php echo $row_list['clan']; ?></td>
<td width="128" valign="top"><?php echo $row_list['character']; ?></td>
<td width="71" valign="top"><?php echo $row_list['timezone']; ?></td>
<td width="67" valign="top"><?php echo $row_list['avail']; ?></td>
<td width="141" valign="top"><?php echo $row_list['email']; ?></td>
<td width="142" valign="top"><?php echo $row_list['msn']; ?></td>
<?php echo '</table></td>
</tr>
<tr>
<td height="25"> </td>
</tr>
</table>';
} // line 82
?>
__________________
Mike
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 04:46 AM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|