I'm new to php and need a little help please.
I try to build a class that return an Array of all the table in my db.
and be able to get all the data by there col name (like username, password....)
but all i got is the last record from the db.
here is the class:
Code: Select all
<?php
class db{
function getall($table, $search){
$sql = "SELECT ". $search ." FROM " . $table;
$result = mysql_query($sql) or die('Error, insert query failed' . mysql_error());
while($row=mysql_fetch_assoc($result)){
$data = $row;
}
return $data;
}
Code: Select all
$data = $db->getall("users", "*");
foreach($data as $row){
echo $row['fullname'];
echo "<BR>";
}