-2

Basically, I have a drop-down menu that has two options - 'All' & 'Top Rated'.

<select class="dropdown">
<option value="all">All</option>
<option> value="toprated">Top Rated</option>
</select>

I want to run this query through the 'All' option...

$myQuery  = "SELECT Attraction.*, Type.TypeName, Rating.RatingUrl ";
$myQuery .= "FROM Attraction ";
$myQuery .= "INNER JOIN Type ON Attraction.Type = Type.TypeID ";
$myQuery .= "INNER JOIN Rating ON Attraction.AttractionID = Rating.AttractionID ";
$myQuery .= "WHERE Attraction.Type = 4 ";
$myQuery .= "ORDER BY Name ";

$result = mysql_query($myQuery);
if (!$result) {
    die('Query error: ' . mysql_error());
}

And the this query through the 'Top Rated' option...

$myQuery  = "SELECT Attraction.*, Type.TypeName, Rating.RatingUrl ";
$myQuery .= "FROM Attraction ";
$myQuery .= "INNER JOIN Type ON Attraction.Type = Type.TypeID ";
$myQuery .= "INNER JOIN Rating ON Attraction.AttractionID = Rating.AttractionID ";
$myQuery .= "ORDER BY Rating DESC, Name ";

$result = mysql_query($myQuery);
if (!$result) {
    die('Query error: ' . mysql_error());
}

Can anyone generate the php structure I would need for this to work...

If anyone can help that would be great!

4

1 回答 1

0

我推荐这个PHP 教程和这个mysqli阅读

另外,请查看 WebChemist 所说的:

不好:

<option> value="toprated">Top Rated</option>

好的:

<option value="toprated">Top Rated</option>
于 2012-12-01T01:33:38.187 回答