Page 1 of 1

[SOLVED] Limiting SQL results

Posted: Wed Sep 27, 2006 6:42 pm
by tristanlee85

Code: Select all

// Get list of authors for the sort menu
$authors_qry = "SELECT author FROM megasquirt";
$result=mysql_query($authors_qry);
$num=mysql_numrows($result);

if ($num==0)
{
	$authors = "<option> --- </option>";
}
else
{
$count=0;
while ($count < $num)
	{
	$authors .= "<option name='sort' value='" . mysql_result($result,$count,"author") ."'>". mysql_result($result,$count,"author") . "</option>";
	$count++;
	}
}
In the table 'megasquirt', there are currently 3 rows. Row 1 has an author of 'tristanlee85' and rows 2 and 3 have an author of 'Natedogg'. This script creates a drop-down menu with the "author" as an option. The problem is, this returns both options to select Natedogg as the author in my drop-down menu. I tried using isset() with no luck. Any suggestions?

Posted: Wed Sep 27, 2006 6:44 pm
by Todd_Z

Code: Select all

$authors_qry = "SELECT DISTINCT(author) FROM megasquirt";

Posted: Wed Sep 27, 2006 6:45 pm
by tristanlee85
I new it was something simple like that. I tried using LIMIT 1, but obviously that only limited my result to 1. Thank you!

Posted: Thu Sep 28, 2006 12:18 am
by BDKR
I take it you are into Car stuff?

Posted: Thu Sep 28, 2006 12:52 am
by tristanlee85
Most definately.

Posted: Thu Sep 28, 2006 1:01 am
by BDKR
Right on. I have a Turbocharged '89 Volvo 244. A lot of the guys over at Turbobricks.com are running MS. I'm going to use it for my next project.

Posted: Thu Sep 28, 2006 1:04 am
by tristanlee85
This won't help you any since it's a Saturn forum, but I've been writing a downloads section for the MegaSquirt files.

http://forums.plastikracing.net/downloads.php?

Posted: Thu Sep 28, 2006 1:50 am
by BDKR
Ahh..... So you've got different tunes that can be downloaded by others?

Posted: Thu Sep 28, 2006 11:00 am
by tristanlee85
Yeh. A lot of the Saturn guys are turning to the MegaSquirt because they are cheap. Most of the people on my site run with the MS and by sharing each other's configurations, it helps to give a nice starting point for others who are new to the system.