WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Class to build a select tag in html, useful to build select boxes from a data base
Categories : PHP, HTML and PHP, PHP Classes Click here to Update Your Picture
David Perez
Date : Oct 17th 2002
Grade : 3 of 5 (graded 7 times)
Viewed : 12455
File : No file for this code example.
Images : No Images for this code example.
Search : More code by David Perez
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php
class Combo
{
var
$label;
var
$index;
var
$value;
var
$description;

function
Combo ()
  {
   
$this->label = "Select an option: ";
   
$this->index = -1;
   
$this->value = "";
   
$this->description = "";

  }

function
addItem ($value, $description)
  {
   
$this->index++;
   
$this->value[$this->index] = $value;
   
$this->description[$this->index] = $description;
  }

function
clear()
  {
   
$this->Combo();
  }

function
display ($name, $subnit)
  {
   if (
$this->index<0)
    {
     echo
"";
    }
   else
    {
     echo
$this->label . "<select name=\"$name\" ";
     if (
$subnit!="") echo " OnSubmit=\"$subnit\" ";
     
//if you want to use some other event just add it in this function
     
echo ">\r"// the \r is only for a clear html coding...
     
for ($x=0;$x<$this->index+1;$x++)
      {
       echo
"<option value=\"" . $this->value[$x] . "\">" . $this->description
[$x] . "</option>\r";
      }
     echo
"</select>\r";
    }
  }

}
// End Class
?>
<form>
<?
$cmb
= new Combo;
$cmb->addItem("A","Opci󮠁");
$cmb->addItem("B","Opci󮠂");
$cmb->addItem("C","Opci󮠃");
$cmb->display("letras","gotoLetras(this);");
$cmb->clear();
$cmb->label = "Choose a number";    //Chamging the label
$cmb->addItem("1","Opci󮠱");
$cmb->addItem("2","Opci󮠲");
$cmb->addItem("3","Opci󮠳");
$cmb->display("N?s","gotoNumeros(this);");
?>
</form>



Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but effective.
Categories : PHP, PHP Classes, HTML, HTML and PHP
Football News Aggregator
Categories : PHP, Object Oriented, PHP Classes, Rich Site Summary (RSS), HTML and PHP
XTemplate, a template class for PHP
Categories : PHP Classes, HTML and PHP, PHP
A script to generate a report from a valid mysql connection. The user has to supply which fields he wants to display in table. All properties are changable.
Categories : PHP, PHP Classes, Databases, MySQL, HTML and PHP
How To Create a PDF Using PHP
Categories : PHP, PDF, PHP Classes, HTML and PHP
Simple class to build tables with style sheets
Categories : HTML and PHP, PHP Classes, PHP
phpFormGenerator for Dynamic Form Generation from MySQL
Categories : PHP, PHP Classes, MySQL, Databases, HTML and PHP
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
Vote-Poll script that has a wrapper class that allows the user to create multiple polls on the same page with little trouble.
Categories : PHP, PHP Classes, HTML and PHP
Customizable Calendar Class
Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar
class formHTML build your HTML Forms from PHP
Categories : PHP, PHP Classes, HTML and PHP, HTML
A simple class with some HTML output functions that would come in handy for consistent page layout etc.
Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation
A class for sending email; it has support for To:, Cc:, Bcc: and Reply-To: headers. It requires that you have sendmail installed.
Categories : Email, PHP Classes, PHP
Image Cache
Categories : Graphics, PHP Classes, PHP
Multiple Select box, Select multiple Items from Menu.List box
Categories : PHP, HTML and PHP, Beginner Guides
 David Perez wrote :870
some changes in the function display
function display ($name, $selected, $subnit)
  {
   if ($this-&gt;index&lt;0)
    {
     echo "";
    }
   else
    {
     echo $this-&gt;label . "&lt;select name=\"$name\" ";
     if ($subnit!="") echo " OnSubmit=\"$subnit\" ";
     //if you want to use some other event just add it in this function
     echo "&gt;\r";  // the \r is only for a clear html coding...
     for ($x=0;$x&lt;$this-&gt;index+1;$x++)
      {
       echo "&lt;option value=\"" . $this-&gt;value[$x] . "\"";
       if ($selected==$this-&gt;value[$x]) echo " selected ";
       echo "&gt;" . $this-&gt;description[$x] . "&lt;/option&gt;\r";
      }
     echo "&lt;/select&gt;\r";
    }
  }
and now should be called like...
$cmb-&gt;display("Nmeros","2","gotoNumeros(this);");
this change is for select one option by default