0

Hello,

I was wondering does anyone have an idea how to make a dropdown menu that dosent repeat values from the SQL Server? Perferably using a while loop. I was thinking of camparing the set values with the new values as it loops through them but im not sure.

-Thanks

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by Odubz
0

Are you sure you're using pHp? SQL Server 'usually' used with ASP.

0

What is the query you are using to pull data from the database? (Are you already using the UNIQUE clause?)

-Brian

0

Heh yea im using SQL Server alright. Its using that plugin from microsoft (sqlsrv). Im actually not using the UNIQUE clause. Here is my code with the query in it:

$sql = "SELECT MaterialLot# FROM $Tower WHERE mainProc='$mainProc'";
		  $result = sqlsrv_query($conn,$sql) or die("Couldn't execut query");
	
		  echo "<form action='cutting.php' method='POST'>";
		  echo "<select name='LotSelect'><option> Choose </option>";

		  
		  while($data=sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)){
			echo "<option value=".$data['MaterialLot#'].">".$data['MaterialLot#']."</option>";
		
		  }
	  	  echo "<input type='hidden' name='cut' value='prevLot'>";
		  echo "<input type='submit' value='Select Pallet'></select></form></br>";

$Tower and $mainProc are from session variables.

Edited by Odubz: n/a

1

'SELECT DISTINCT' is what you probably want.

0

Haha nice! I kind of feel like a fool, I had a feeling it would be a keyword in the query...Should have looked at the docs closer. Thanks alot Ardav

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.