FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Search whole database

 


avk
Hello,

what should i do if i want to search in a table of a database??
Not a single row but the whole table.
AftershockVibe
I assume you mean multiple columns (fields) as it already searches all rows (records).

I'm afraid that you have to specify them by name. Something along the lines of;

SELECT * FROM Table WHERE Field1 = "Criteria" OR Field2 = "Criteria".

You shouldn't really ever need to search the entire table though unless you have something odd going on with your table design,.
asiddle423
hi

is it something like a login where you want to find a username and password match. if so it will be something similar to this:

Code:

<?php
$login = 'login';
$pass = 'password';

mysql_query = "SELECT * FROM tableName WHERE login = '$login' AND password = '$pass'";

?>
thnn
If you want to make say a search page to search content on you site you can do,

Code:
mysql_query = "SELECT * FROM tableName WHERE fieldName like '%Query%'";


The % means that anything can be on the side of it. If you wanted more you would use (fieldname like '&Query&') OR (fieldname2 like '%Query%')
avk
Yup,
Thankyou I got my answer.
This thread can be closed now
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.