FUNKAM35 Posted February 24, 2014 Share Posted February 24, 2014 if(empty($_GET['order_by']))$order="order by rate3 ASC "; if($_GET['order_by']=='rate3asc')$order="order by rate3 ASC "; if($_GET['order_by']=='rate3desc')$order="order by rate3 DESC "; if($_GET['order_by']=='bedsasc')$order="order by beds ASC "; if($_GET['order_by']=='bedsdesc')$order="order by beds DESC "; $select = "SELECT prop_id, agent_id, ref, price, prop_type, town, province, country, location, beds, baths, pool, url, description, image1, rate1, rate2, rate3, currency, ski_area, sleeps, holiday_parks, shortdescription FROM rental WHERE $where LIMIT $from, $max_results ".$order; echo "<table width=\"40%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"left\"> <tr><td class=\"norm\" align=\"left\"> <div class=\"styled-select\"> <form id=\"formorder\" action=\"$_SERVER[PHP_SELF]\" method=\"get\"> <select name=\"order_by\" onChange=\"UpdateQty(this)\" > <option value=\"sort by\" selected=\"selected\">Sort by</option> <option value=\"rate3asc\">Lowest Price First</option> <option value=\"rate3desc\">Highest Price First</option> <option value=\"bedsasc\">Beds (Low to High)</option> <option value=\"bedsdesc\">Beds (High to Low)</option> <input type=\"submit\" name=\"submit\" id=\"button\" value=\"go\"> </form></div></td><td class=\"norm\" align=\"left\">\n"; if($order_by=="rate3 asc"){ echo"Sorted by Lowest Price First"; } if($order_by=="rate3 desc"){ echo"Sorted by Highest Price First"; } if($order_by=="beds asc"){ echo"Sorted by Least Bedrooms First"; } if($order_by=="beds desc"){ echo"Sorted by Most Bedrooms First"; } echo"</tr></td></table>\n"; $pic_count=0; echo "<table width=\"70%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"position:absolute; margin-top:40px; margin-left:180px; height=100%;\">\n"; if($num_rows = mysql_num_rows($results)==0) { echo "There are no Holiday Homes for Rental in $country Please Visit Again Soon as This Website is Updated Daily"; } while ($query_data = mysql_fetch_row($results)) { $prop_id=$query_data[0]; Hi, I am trying to order my results with two parts of code and the results will not display, the same code works on a different website so I don't think its that far off? Many thanks Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted February 24, 2014 Share Posted February 24, 2014 (edited) You have defined the query ($select) but you have not executed it. You need to call mysql_query to run a sql query on a mysql database (provided you have connected to MySQL and selected a database first) Edited February 24, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
gristoi Posted February 24, 2014 Share Posted February 24, 2014 yep, no mysql_query() Quote Link to comment Share on other sites More sharing options...
Solution FUNKAM35 Posted February 24, 2014 Author Solution Share Posted February 24, 2014 please could you show me how o add this as been trying all sorts for past hour much appreciated Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted February 24, 2014 Share Posted February 24, 2014 Did you not bother looking at http://php.net/mysql_query to see how to use that function? The missing code is. $results = mysql_query($select); Quote Link to comment Share on other sites More sharing options...
FUNKAM35 Posted February 24, 2014 Author Share Posted February 24, 2014 solved this but it has turned up another problm Quote Link to comment 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.