Jump to content

Trying to select one record from a database


ballhogjoni

Recommended Posts

if your saying that you want to find a certain record in 10 table then i guess the only way is to query each table one by one

What php and mysql syntax would I use to accomplish this?

 

it will only need the usual way the fetch array and mysql_query

this is my code so far:

 

$query = "SELECT `contact_n_questions`.`fname`, `dispo_callBack`.`fname`, `dispo_client`.`fname`
FROM contact_n_questions, dispo_callBack, dispo_client
WHERE ((`contact_n_questions`.`fname`) OR (`dispo_callBack`.`fname`) OR (`dispo_client`.`fname`)) = '$search_fname'";
			$result = mysql_query($query) or die(mysql_error());

your using a Cartesian join i dont know if thats gonna sort it out but look if you can do a print_r(mysql_fetch_array(' ')) i believe its the same as the usual thing foreach or while

 

but with this question

How would run a loop with the tables in the db? 

 

i believe you you have to come up with

$table = array('table1','table2');

foreach($table as $tbl)
{
    select * from $tbl 
}
[code]

although querying for this way may be slower but it will give you an exact ouptu you neeed

[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.