|
Posted by Mtregael on 09/28/20 11:48
sloane.irwin@gmail.com a écrit :
> Hi, I'm working on a computer inventory database at my federal
> work-study job and I've been able to find help so far with everything
> I've been doing, but this error message is really bugging me. Here's
> the code, the error is generated on line 41:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
> />
> <title>Computer Database Home</title>
> <link href="2col_leftNav.css" rel="stylesheet" type="text/css" />
> </head>
> <?
> $default_sort = 'id';
> $allowed_order = array ('inventory', 'date_entered','first',
> 'id','date_changed', 'serial', 'last', 'location', 'brand', 'model',
> 'email');
>
> if (!isset ($_GET['order']) ||
> !in_array ($_GET['order'], $allowed_order)) {
> $order = $default_sort;
> } else {
> $order = $_GET['order'];
> }
>
>
> require('db_login.php');
> require('db_connect.php');
> ?>
>
> <body>
>
> <p align="center"><img src="osu-hort-logo-color.gif" width="469"
> height="173" /></a></p>
> <p class="story"><a href="enter.html">Add New Entry</a><br />
> <?php
> $db = mysql_connect($host, $user, $pass);
> mysql_select_db($db_name,$db);
> $result = mysql_query("SELECT * FROM data ORDER BY $order",$db);
> $numofrows = mysql_num_rows($result);
>
> echo "<TABLE BORDER=\"1\">";
> echo"<TR bgcolor=\"lightblue\"><TD><B><a href
> ='display2.php?order=inventory'>Inventory</a></B><TD><B><a href
> ='display2.php?order=date_entered'>Date Entered</a></B><TD><B><a href
> ='display2.php?order=first'>First</a></B></TR><TD><B><a href
> ='display2.php?order=last'>Last</a></B></TR><TD><B><a href
> ='display2.php?order=date_changed'>Date Changed</a></B></TR><TD><B><a
> href ='display2.php?order=serial'>Serial</a></B></TR><TD><B><a href
> ='display2.php?order=id'>ID</a></B></TR><TD><B><a href
> ='display2.php?order=location'>Location</a></B></TR><TD><B><a href
> ='display2.php?order=brand'>Brand</a></B></TR><TD><B><a href
> ='display2.php?order=model'>Model</a></B></TR><TD><B><a href
> ='display2.php?order=email'>Email</a></B></TR><TD><B><a href
> ='display2.php?order=model'>Model</a></B></TR><TD><B>Delete</B></TR><TD><B>Edit</B></TR>";
>
> for($i = 0; $i < $numofrows; $i++); {
> $myrow = mysql_fetch_array($result);
> if($i % 2); { //this means if there is a remainder
> echo "<TR bgcolor=\"yellow\">\n";
> } else { //if there isn't a remainder we will do the else
> echo "<TR bgcolor=\"white\">\n";
> }
> $id=$myrow['id'];
> echo "<TR><TD>";
> echo $myrow["inventory"];
> echo "<TD>";
> echo $myrow["date_entered"];
> echo "<TD>";
> echo $myrow["first"];
> echo "<TD>";
> echo $myrow["last"];
> echo "<TD>";
> echo $myrow["date_changed"];
> echo "<TD>";
> echo $myrow["serial"];
> echo "<TD>";
> echo $myrow["id"];
> echo "<TD>";
> echo $myrow["location"];
> echo "<TD>";
> echo $myrow["brand"];
> echo "<TD>";
> echo $myrow["model"];
> echo "<TD>";
> echo $myrow["email"];
> echo "<TD>";
>
> echo "<TD><a href=\"view1.php?id=".$myrow["id"]."\">View</a> ";
> echo "<TD>";
> echo "<a href=\"Delete1.php?id=".$myrow["id"]."\">Delete</a>";
> }
> echo "</TABLE>";
> ?>
> </p>
> </html>
>
Hi,
You have problems with ";"...
After a "for" and/or a "if" statment, you don't have to put a ";" before
the "{"
Exemple, for 'for': http://fr2.php.net/manual/en/control-structures.for.php
This is correct:
for ($i = 0; $i < $numofrows; $i++) {
$myrow = mysql_fetch_array($result);
if ($i % 2) { //this means if there is a remainder
echo "<TR bgcolor=\"yellow\">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor=\"white\">\n";
}
It would work...
Regards,
Mtregael
Navigation:
[Reply to this message]
|