0

I have a table in my database and i would like to bring up all the details where
the datafield "votes" is the largest. i cannot get the fuctionality i desire.

i would like a user to make a choice from the selection then have all the datafield where "votes" is the highest returned.
please help, the code i have is below

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Results</title>

<?php
 $connect = mysql_connect("localhost", "root","");
    if (!$connect)
    {
       die("database connection failed". mysql_error());
    }
    //make sure we’re using the right database
    $select_db = mysql_select_db("Elections");
    if (!select_db)
    {
      die("database selection failed " .mysql_error());
    }
    
    $portfolio = trim($_POST['portfolio']);
    $queryOne = "SELECT * FROM $portfolio WHERE MAX(Votes);
    $resultOne = mysql_query($queryOne);
    
    
?>

<style type="text/css">
.auto-style1 {
	margin-top: 93px;
}
</style>

</head>

<body>

<form action="results.php" method="post" style="width: 514px; height: 168px">

    <fieldset name="Group1" style="height: 164px">
	<legend>Results Per Portfolio</legend>
		<select name="portfolio" style="height: 23px; width: 117px;" class="auto-style6">
				<option value=" president "> President </option>
				<option value=" vicePresident "> Vice President</option>
				<option value=" secretary "> Secretary </option>
				<option value=" viceSecretary "> Vice Secretary </option>
				<option value=" treasurer "> Treasurer </option>
				
    	 </select><br />
    <input name="Results" type="submit" value="Results" class="auto-style1"/>
	</fieldset>
	</form>





</body>

</html>

Edited by liphoso: n/a

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by smantscheff
0

Hello,

Try changing the WHERE MAX(Votes) to

WHERE Votes = (select MAX(Votes) from $portfolio )
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.