View Single Post
Old 06-18-2007, 03:07 AM   #22 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,693
redhead is on a distinguished road
Just a quick out of thoughts rewrite of your VB thingy there into PHP, Absolutely no guarentie it will work of any sort
PHP Code:
<?

$con 
mysql_connect("localhost","peter","abc123");
if (!
$con)
{
  die(
'Could not connect: ' mysql_error());
}
mysql_select_db("WB"$con);

class 
details {
  var 
$name;
  var 
$species;
  var 
$sex;
  function 
details($id){
    
$result mysql_query("select * from Birds where id = '$id'");
    if(
$array mysql_fetch_array($result)){
      
$this->name $array['name'];
      
$this->species $array['species'];
      
$this->sex $array['sex'];
    }
  }
  function 
show(){
    echo 
"<table border=1 cellspacing=0 cellpadding=0>
    <tr><td>" 
$this->name "</td>
    <tr><td>" 
$this->species "</td>
    <tr><td>" 
$this->sex"</td></tr></table>"
  }
}

class 
record{
  var 
$items = array();
  var 
$count;
  function 
record(){
    
$this->count 0;
    
$result mysql_query("select id from Birds");
    while (
$array mysql_fetch_array($result)) {
      
$this->items[$this->count++] = new details($array['id']);
    }
  }
  function 
show(){
    for(
$i=0$i $this->count$i++)
      
$this->items[$i]->show();
  }
}

$my_record = new record();
$my_record->show();
?>
For a refference, you can look at the Object Oriented PHP article.

And DjMs question regarding your age, is of some relevence, since some of your questions seems to come from one who dosn't grasp what is going on, and feel it is easier to ask for a solution than to piece together one from previus explanations.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote