justlukeyou Posted February 22, 2011 Share Posted February 22, 2011 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']; Quote Link to comment https://forums.phpfreaks.com/topic/228489-mixing-different-queries-together/ Share on other sites More sharing options...
Muddy_Funster Posted February 22, 2011 Share Posted February 22, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/228489-mixing-different-queries-together/#findComment-1178137 Share on other sites More sharing options...
justlukeyou Posted February 22, 2011 Author Share Posted February 22, 2011 Hi, I want the price to be based on the description. So it shows descriptions within the given price range I need to get it to read the description which is in the address and then add the price query on top of that. Quote Link to comment https://forums.phpfreaks.com/topic/228489-mixing-different-queries-together/#findComment-1178140 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.