Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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