[Lias] PHP help
Simon Bryan
sbryan at mpx.com.au
Thu Aug 16 11:32:05 UTC 2001
Hi,
I am trying to modify a query in PHP that is running against a MYSQL
database. At the moment the query searches a field called 'contents' in the
'tracking' table. (see below) I would like to be able to search on the
'computer' field in this table. Which I can do OK, however the field in
this table simply contains the ID number of the computer from the computer
table. The computer table, amongst other things contains the ID and a text
Description, it is this description that I would like the users to be able
to enter.
So I need a query that first searches the Computer table for matching ID
numbers and then passes the ID numbers to the existing query. eg the
computer is called T4-01, the user enters T4-01 or just T4 in the form. The
search then passes all the ID's to the query. It would be acceptable if it
only passed one and the initial query rejected anything that did not match
exactly in the search field.
Any help appreciated as I am totally new to PHP.
************************** PHP Code **********************************
These are your search results for the query: description contains <? echo
$contains; ?>.
<hr noshade>
<?
$query = "SELECT ID FROM tracking WHERE (contents LIKE \"%$contains%\")
ORDER BY
date DESC";
$result = $db->query($query);
$i = 0;
$number = $db->numrows($result);
PRINT "<center><table border=1 width=\"100%\">";
PRINT "<tr bgcolor=#DDDDDD><td>Status</td><td>Date</td><td width=5>Pri</td>
<td>Author</td><td>Assigned</td><td>Computer</td><td
colspan=2 width=70%>
Description</td></tr>";
while ($i < $number)
{
$ID = $db->result($result, $i, "ID");
Show_tracking($ID, 0);
$i++;
}
PRINT "</table></center>";
Simon Bryan
More information about the lias
mailing list