Jump to content

Archived

This topic is now archived and is closed to further replies.

Tjk

Select records from 2 tables and order by...

Recommended Posts

$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

Share this post


Link to post
Share on other sites
$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());

Share this post


Link to post
Share on other sites

×

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.