Location: PHPKode > scripts > comboBoxList > comboboxlist/comboBox.php
<?
	/**
	** Author: Oliver Susano (hide@address.com)
	** Class comboBox
	** Creates a list box using two fields.
	** syntax: comboBox($tblName, $drpListName, $rowValue1, $fieldRowLocation2, $vCheck,  $orderBy, [$asc], $name);
	** $tblName       = table name fro you database.
	** $dropListName  = name to be assigned on select.
	** $rowValue1     = rows from the table fields to be assign to option.
	** $rowValue2     = rows from the table fields to be assign to drop list.
	** $vCheck        = given parameter to be checked from the list.
	** $orderBy       = select given field name to be order.
	** $asc           = assign DESC for descending display or blank for default ascending order.
	** $name          = name to be dislpayed on your first list like [ Select Country ]
	**/
	
	class comboBox {
		/* Begin Edits Constructor */
		function comboBox( $tblName, $drpListName, $rowValue1, $rowValue2, $vCheck, $orderBy, $asc, $name ){
			// assign SQL select statement
			$sql = "select * from $tblName order by $orderBy";
			$sqlQuery=mysql_query( $sql ) or die (mysql_error());
			
			 /* Begin result table */
			echo("<select size='1' name='$drpListName'>");
			echo("<option value=''>[ Select $name ]");
			while ($row = mysql_fetch_array($sqlQuery)){
				/* Output combo box */
				if($vCheck == $row[ $rowValue1 ] ){
					echo("<option value=");
		     		echo( $row[ $rowValue1 ] );  
		     		echo(" selected>"); 
		     		echo( $row[ $rowValue2 ] ); 
		     		echo("</option>");
				} else {
					echo("<option value=");
		     		echo( $row[ $rowValue1 ] );  
		     		echo(">"); 
		     		echo( $row[ $rowValue2 ] ); 
		     		echo("</option>");
				}
			}
			echo("</select>");
			/* End result table */
		} // end comboBox
	} // end Class
?>
Return current item: comboBoxList