Jump to content

select value in multiple fields and multiple tables


cybernalle

Recommended Posts

I am a rather newbie with php and mySQL, so my question might be a little naiv...

 

 

1. I have a webpage with one .php-file that makes selections from a mySQL-database and displays different pages. (i.e index.php?id=1, where 1 is the id of the page)

2. I have successfully included a secondary .php-code in some database fields, now I want to make that code to make a new selection from the database depending on a variable $search.

 

This is the code that I have in the textfield of the entry in the page table:

 

<? $result = mysql_query("SELECT * FROM pages, lists, links, text WHERE text, keywords, content, description LIKE $search");

while($row = mysql_fetch_array($result))

{

echo "page:" . $row[''title''] . "<br />";

echo "content" . $row[''content''] . "<br />";

}

?>

 

To clarify: after FROM it is the names of my tables that I want to make the selection from, and after WHERE is the name of the different fields in the different tables.

 

Question: I do not get any hits, no matter what value $search has. Any ideas why?

 

Tnx in advance!

$result = mysql_query("SELECT * FROM pages, lists, links, text WHERE text, keywords, content, description LIKE $search");

 

Step #1 for your long journey... familiarize yourself with how a SELECT works... several examples there... also be sure to visit the "JOIN Syntax" and  "UNION Syntax" links in the same page... after study those pages and adjust your code properly come back with your doubts/questions and we will glad to help more.

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.