<?
/*
#|||||||||||||||||||||||||||||||||||||||||||||||||||||||||#
|---------------------------------------------------------|
|------------ www.comnsoftware.com ----------------|
|------------ BRAZIL ----------------|
|---------------------------------------------------------|
|------------ Author: David Mukasey ----------------|
|------------ hide@address.com ----------------|
|---------------------------------------------------------|
|------------ Last Updated: 10-31-2003 ----------------|
|---------------------------------------------------------|
|----------------------------------------- Version 1.0 ---|
#|||||||||||||||||||||||||||||||||||||||||||||||||||||||||#
Manual:
The class HtmlFormsObjects makes an html dropdownlist,
you need only to call de method GenerateDropDownList and send the parameters
like an example on footer of this code.
Requirements:
Web server: Apache or Xitami or Microsoft IIS.
PHP: version 4.0 or later, recommmended 4.3.3. http://www.php.net
DataBase: MySQL http://www.mysql.com
Questions?
send mail to: hide@address.com
Thanks:
PHP-Editor (Brazilian): http://paginas.terra.com.br/informatica/php_editor/ (The best PHP-Editor)
+ Brazil Forever!
*/
Class HtmlFormsObjects{
function GenerateDropDownList($MysqlConnection,$SqlQuery,$HtmlObjectName,$HtmlObjectDefaultValue,$DBFieldToValue,$DBFieldToDescription){
echo "<select name='$HtmlObjectName'> \n";
$result = mysql_query($SqlQuery,$MysqlConnection);
while ($rec = mysql_fetch_array($result)){
if ($HtmlObjectDefaultValue == $rec["$DBFieldToValue"]){
echo "<option selected value='".$rec[$DBFieldToValue]."'>$rec[$DBFieldToDescription]</option> \n";
}
else{
echo "<option value='".$rec[$DBFieldToValue]."'>$rec[$DBFieldToDescription]</option> \n";
}
}
echo "</select> \n";
}
}
/* BEGIN OF EXAMPLE
$o = new HtmlFormsObjects;
$cn = mysql_connect("type your server","type your user","type your password");
$con = mysql_select_db("type your database",$cn);
$o->GenerateDropDownList($cn,"type your SQL query","type the name of control","type the default value","type a field of a database that will be a value of control","type a field of a database that will be a description of control");
mysql_close($cn);
//End OF EXAMPLE */
?>