PHP Classes

File: class.pop.php

Recommend this page to a friend!
  Classes of sujith nair   populate_sel   class.pop.php   Download  
File: class.pop.php
Role: ???
Content type: text/plain
Description: Class to populate the <select> form field from mysql table
Class: populate_sel
Author: By
Last change:
Date: 22 years ago
Size: 1,187 bytes


Class file image Download
<?php // Class to populate the <select> form field from mysql table // Made By Sujith Nair [] // On September 14, 2001 // Please go through another class called "multi" which allows // to populate multiple selected fields from the records. class populate_sel { var $hname="<hostname>"; var $uname="<username>"; // if any var $pname="<password>"; // if any var $dbname="<database name>"; var $tname; var $fname; var $sel; // Constructor function populate_sel($t_name,$f_name,$sel="") { $this->tname=$t_name; $this->fname=$f_name; $this->sel=$sel; } function display() { $db=mysql_connect($this->hname); mysql_select_db($this->dbname,$db); $sql="select $this->fname from $this->tname"; $res=mysql_query($sql); while($myrow=mysql_fetch_array($res)) { if($this->sel) { if($myrow[$this->fname]==$this->sel) { $val.="<option selected>".$myrow[$this->fname]."</option>"; } else { $val.="<option>".$myrow[$this->fname]."</option>"; } } else{ $val.="<option>".$myrow[$this->fname]."</option>"; } } echo $val; } // End of class } ?>