Tjk Posted July 1, 2006 Share Posted July 1, 2006 $campaign= "test"; $query= mysql_query("SELECT * from campaign INNER JOIN campaignd WHERE campaign.campaign='$campaign' campaignd.campaign='$campaign' ORDER BY minit LIMIT='1'")or die(mysql_error()); while($row= mysql_fetch_array($query)){ echo "<option value='".$row['commander']."'>". $row['commander']."</option>"; } ---------Here I'm trying to select records from 2 tables- campaign and campaignd where the value of the row campaign is equal to the string stored in the variable of the name campaign, then ordering them by the row minit value (an integer) and setting the limit to 1 so it only selects the record with the highest value minit. It then echoes a select option with the value of the row commander.I can't seem to get it to do what I want. When i try loading the page i don't get any errors but instead just get an empty select box. Could anyone show me where I'm going wrong?regards-Tjk Link to comment https://forums.phpfreaks.com/topic/13385-select-records-from-2-tables-and-order-by/ Share on other sites More sharing options...
Barand Posted July 1, 2006 Share Posted July 1, 2006 $query= mysql_query("SELECT * from campaign INNER JOIN campaignd ON campaign.campaign = campaignd.campaign WHERE campaign.campaign='$campaign' ORDER BY minit DESC LIMIT='1'")or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/13385-select-records-from-2-tables-and-order-by/#findComment-51734 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.