Page 1 of 1

Datebase Class??

Posted: Tue Mar 09, 2004 12:03 pm
by AndrewBacca
Hi,

im tring to create a database class
i have it connectig using it

and i can select the first record. BUT i want to be able to select ALL records from the database (well the ones that match the query). so that i can access them after teh function has run

This what i have so far

Code: Select all

$query = "SELECT * FROM forensis_post_formating";
$result = $myDB->query_select($query);
then in the db class file

Code: Select all

function query_select($query)
{
	$result  = mysql_query($query);
	return $result;
}
then back in the other file

Code: Select all

$fetch = $myDB->Fetch($result);
is that which calls

Code: Select all

function Fetch($result)
  {
    $fetch = mysql_fetch_array($result);

    return $fetch;
  	}
back to the other file!

Code: Select all

print $fetchї3];


that last line prints the field of the first record depending on ghe number

if you need more details of what am i after, ill try to give me

cheers

Andrew

Posted: Tue Mar 09, 2004 2:30 pm
by patrikG
[php_man]while[/php_man] will certainly be of use, e.g.

Code: Select all

<?php
while ($fetch[] = mysql_fetch_array($result))
   {}
return $fetch;
?>
There are some fantastic books out there which can guide you through common PHP problems like this. I most certainly recommend PHP Anthology - you can download some sample chapters to check it out and it does teach you about best practice coding.

http://www.sitepoint.com/launch/24dc6f

And no, I am not gaining anything from recommending this book. ;)