Select * FROM multiple tables

Hi, im having trouble with a select statement it works fine at the moment, but i want to alter it so that it selects * from another table as well, i cant seem to get it work without it throwing errors, this is what I have at the moment:

[php]<?php
if (!empty($_REQUEST[‘term’])) {

$term = mysql_real_escape_string($_REQUEST[‘term’]);

$sql = “SELECT * FROM adrenaline WHERE title LIKE '%”.$term."%’";
$r_query = mysql_query($sql);

while ($row = mysql_fetch_array($r_query)){  
     echo '<br> <a href="../' . $row['description'] . '"> '. $row['title'] .'</a>';  
 }

}

?>[/php]

This is what Im looking for:
[php]$sql = “SELECT * FROM adrenaline “””+ hobby""" WHERE title LIKE ‘%".$term."%’"; [/php]

many thanks.

BUMP

You are using deprecated code. Update to PDO and we can help you. I have provided a complete working PDO database you can download to get you started.

http://www.phphelp.com/forum/the-occasional-tutorial/beginners-pdo-bumpstart-code-use-it-now!

If I update to PDO will all my old SQL statements become redundant and stop working? I dont have the time to redo all current sql statements, neither do I have the knowledge to update my current database to PDO.

The sql will stay 99.999999% the same. Slight modification for using parameterized querys.

Example:

This

SELECT * FROM adrenaline WHERE title LIKE '%".$term."%'

Would become this:

SELECT * FROM adrenaline WHERE title LIKE '%"?"%'

It is not the database that is PDO. PDO is the method you access the database. Your database stays the same. With the download I provided you can be up and running with your own database in minutes.

Sponsor our Newsletter | Privacy Policy | Terms of Service