[Lias] Re: [SLUG] PHP help

Matthew Palmer mjp16 at ieee.uow.edu.au
Thu Aug 16 12:21:05 UTC 2001


On Thu, 16 Aug 2001, Simon Bryan wrote:

> 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.

Sounds to me like it's SQL help you need, rather than PHP.

OK, to match the contents of one field against another, use a join.  You cna
do it by having a member of your where clause with the form

table1.column1=table2.column2

and the tables are joined for that query.

So, for this query, you might do:

select description from computer where tracking.contents LIKE $contains and
contents.id=computer.id

This is the best guess I can make on the query from the info given.

I'd suggest getting a good book on database design and SQL syntax.


-- 
-----------------------------------------------------------------------
#include <disclaimer.h>
Matthew Palmer
mjp16 at ieee.uow.edu.au




More information about the lias mailing list