I'm used to using this:
Code: Select all
<?php
while($r = mysql_fetch_array($result)) {
echo "Hello $r[username]";
}
?>Here is what I have so far (don't slate me - i'm such a n00b with Classes (I still dont understand Arrays properly either :p))
Code: Select all
<?php
class DB {
var $db_host = "localhost";
var $db_user = "username";
var $db_pass = "password";
var $db_data = "database";
function connect() {
mysql_connect($this->db_host,$this->db_user,$this->db_pass);
mysql_select_db($this->db_data) or die($this->killed(mysql_error()));
}
function quel($thequery) {
$thequery = mysql_query($thequery) or die($this->killed(mysql_error()));
}
function qfet($fetchquery) {
mysql_fetch_array($this->quel) or die($this->killed(mysql_error()));
return $this->qfet;
}
function killed($whydie) {
echo "<html><head><title>An Error</title></head><body><font face=\"Verdana\" size=\"2\"><hr><font color=\"#FF0000\"><b>!! ERROR !!</b></font><br>$whydie<hr></font></body></html>";
die();
}
}
?>Code: Select all
<?php
$test = new DB;
$test->connect();
?>