Conexion.php
Código PHP:
Ver original
<?php //could be happy class conexion_online { protected $conexion; public $message; public $numrows; public $myid; public function sql($case){ switch ($case) { case 1: $sql="my_database"; $this->message= "Error 1 , connect success·"; break; case 2: $sql="select * from eljuegodelavida"; $this->message= "Error 2 , query success·"; break; case 3: echo $this->myid=$res['id']."<br>"; } $this->message= "Error 3 , assoc success ·"; break; case 4: $this->message= "Error 4 , num success·"; break; default: # code... $this->message = "You Fail"; break; } } } $connect= new conexion_online(); $connect->sql(1); echo $connect->message; $connect->sql(2); echo $connect->message; $connect->sql(4); echo $connect->message; echo "Total: ".$connect->numrows; if($connect->numrows < 20){ echo "Search:".$connect->numrows; $connect->sql(3); echo $connect->message; }//class //conexion is OK ?>
clase_extends.php
Código PHP:
Ver original
<?php abstract class myclass { abstract protected function getValue(); public function printOut(){ echo $this->getValue() . "\n"; } }//class myclass CLASE MADRE class unit_class extends myclass{ public $Lasta_one_number; public $arrayName; public function getValue(){ include("conexion.php"); return "Ultimo numero ".$this->arrayName[0][0]." con valor ".$this->arrayName[0][1]; } }//class unit_class class parents extends myclass{ public $editor; public function getValue(){ return " <form action='' method='post'> <textarea name='editor_name'> ".$this->editor."</textarea> <input type='submit'> </form> "; } }//class parents ?> <?php //Respuesta impresion $Resp1 = new unit_class(); echo $Resp1->printOut(); $Resp2 = new parents(); echo $Resp2->printOut(); echo $Resp2->editor=@$_POST['editor_name']; echo "<br>"; ?>
El buscador trata de encontrar el primer o ultimo numero de una lista en la base de datos mas su valor y escribirle la descripción en su celda.