So I'm new to this, and I thought I would try out several things. Well I tried this (see the code below) and it turns out that there is a problem.
The thing is that when I search for a special ID, this whole "thing" I'm trying to make is supposed to check for this ID in a database, and if it finds the ID then it should post the results.
So I tried to search for an ID, and it gave me this error (it give me this error if I just try to access the php file anyway):
Parse error: syntax error, unexpected T_PRINT in /home/st/ml514//Epu/L5/legoquery.php on line 40
Anyone know how to solve this problem? 🙂
Here's the code (never mind the language in the code):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sökresultat av sats i LEGO</title>
</head>
<body>
<?php
mysql_connect("studsql.itn.liu.se","lego_guest","");
mysql_select_db("lego");
$query_temp = $_POST["query"];
$query = stripslashes($query_temp);
?>
<h2>Resultat</h2>
<p style="font-family:monospace">Din sökning gav följande resultat :
</p>
<p>
<?php
$contents = mysql_query("SELECT Setname, year FROM sets WHERE SetID LIKE '$query%' ORDER BY year");
$parts = mysql_query("Select Partname FROM sets, parts WHERE sets.setID = sets.$query AND set.catID = parts.catID");
print("<table>\n<tr>");
for($i=0; $i<mysql_num_fields($contents); $i++) {
$fieldname = mysql_field_name($contents, $i);
print("<th>$fieldname</th>");
}
print "</tr>\n";
while($row = mysql_fetch_row($contents)) {
print("<tr>");
for($i=0; $i<mysql_num_fields($contents); $i++) {
print("<td>$row[$i]</td>");
}
print("</tr>\n");
for($j=0; $j<mysql_num_fields($parts); $j++) {
$part = mysql_fetch_row($parts)
print("<td>$part[$j]</td>);
} // end for
} // end while
print("</table>\n");
?>
</body>
</html>