cybernalle Posted June 14, 2011 Share Posted June 14, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/239334-select-value-in-multiple-fields-and-multiple-tables/ Share on other sites More sharing options...
mikosiko Posted June 14, 2011 Share Posted June 14, 2011 $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. Quote Link to comment https://forums.phpfreaks.com/topic/239334-select-value-in-multiple-fields-and-multiple-tables/#findComment-1229526 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.