Jump to content

Transfer ID to new query??


JackW

Recommended Posts

I think I have a duh question. I am attaching an ID number to the url
Example someurl?variable1. The ID number is there and I can retrieve it.  How do I get it into my select * from query?


Here is my code:

// open data base
@ $db = mysql_pconnect('someserver.net', 'somedatabase', ' My password');
mysql_select_db('somedatabase1') or die( "Unable to select database");
//fetch Row ID number
$var1 = $_GET['variable1'];
echo $var1;
{
$query= 'SELECT * FROM `sometable` WHERE `ID` LIKE [color=red]??[/color]  LIMIT 0, 5 ';
$query_results=mysql_query($query);
$match_results=mysql_num_rows($query_results);
}

for ($i=0; $i < $match_results; $i++)
{
$row=mysql_fetch_array($query_results);
echo ($row ['body'] );

}

mysql_close($db);

The variable I want is being transferred and it shows up at echo $var1 just fine.  How do I get it to be where the [color=red]??[/color] is in:
$query= 'SELECT * FROM `sometable` WHERE `ID` LIKE [color=red]??[/color]  LIMIT 0, 5 ';

Everything I have tried has presented me with an error message.

If I replace the ?? with the ID number I do get the results I want, but how do I get it place the ID number in the select line automatically?  ???
Link to comment
https://forums.phpfreaks.com/topic/17262-transfer-id-to-new-query/
Share on other sites

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.