Jump to content

Mixing Different Queries Together


justlukeyou

Recommended Posts

I have two seperate piece of code.  One which sorts description and one which sorts price.  However, I am looking to almalgamate them into one.  I have tried the following however I appear to be way off. 

 

I want to select a product description with one link and then select a price range.  However, I want the price range to read the description. 

 

<?phpif( isset($_GET['description' ; 'price' ]))
$description = $_GET['description' ; 'price'];
$query = "SELECT * FROM productfeed WHERE description like '%$description%' LIMIT 0, 10";
$query = "SELECT * FROM productfeed WHERE price like '%$price%' LIMIT 0, 10";
$fetchdata = mysql_query($query) or die("query: $query<br>
This has an error: " . mysql_error() . '<br>');while($row = mysql_fetch_array($fetchdata)) {
$id = $row['id'];
$image = $row['awImage'];
$link = $row['link'];
$description = $row['description'];
$fulldescription = $row['fulldescription'];
$price = $row['price'];

 

<?phpif( isset($_GET['description']))
$description = $_GET['description'];
$query = "SELECT * FROM productfeed WHERE description like '%$description%' LIMIT 0, 10";
$fetchdata = mysql_query($query) or die("query: $query<br>
This has an error: " . mysql_error() . '<br>');while($row = mysql_fetch_array($fetchdata)) {
$id = $row['id'];
$image = $row['awImage'];
$link = $row['link'];
$description = $row['description'];
$fulldescription = $row['fulldescription'];
$price = $row['price'];

 

<?phpif( isset($_GET['price']))
$price = $_GET['price'];
$query = "SELECT * FROM productfeed WHERE price like '%$price%' LIMIT 0, 10";
$fetchdata = mysql_query($query) or die("query: $query<br>
This has an error: " . mysql_error() . '<br>');while($row = mysql_fetch_array($fetchdata)) {
$id = $row['id'];
$image = $row['awImage'];
$link = $row['link'];
$description = $row['description'];
$fulldescription = $row['fulldescription'];
$price = $row['price'];

Link to comment
https://forums.phpfreaks.com/topic/228489-mixing-different-queries-together/
Share on other sites

what do you meen you "want the price range to read the description"? you want the form on the page to display a price range dependant on what the description is? or you want to have the price range tied to the description during the query so that the result set is only descriptions within the given price range?

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.