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

Recommended Answers

All 5 Replies

Member Avatar for diafol

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

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

-Brian

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.

Member Avatar for diafol

'SELECT DISTINCT' is what you probably want.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.