Jump to content
xisto Community
Sign in to follow this  
iGuest

parse mysql table into array

Recommended Posts

i made a mysql db class and now i want to make a function that parses the table into an array, i dont have that much php experience so can anyone help me?

<?php	if(!class_exists('cDB'))	{  class cDB  {  	var $lDB;  	function cDB($name)  	{    $this->lDB = mysql_connect();    mysql_select_db($name, $this->lDB);  	}  	  	function table($name)  	{    //parse table array here  	}  	  	function __destruct()  	{    mysql_close($this->lDB);  	}  }	}?>

Share this post


Link to post
Share on other sites

i made a mysql db class and now i want to make a function that parses the table into an array, i dont have that much php experience so can anyone help me?

<?php	if(!class_exists('cDB'))	{  class cDB  {  	var $lDB;  	function cDB($name)  	{    $this->lDB = mysql_connect();    mysql_select_db($name, $this->lDB);  	}  	  	function table($name)  	{    //parse table array here  	}  	  	function __destruct()  	{    mysql_close($this->lDB);  	}  }	}?>

Do you want to parse table, called $name, data?

Share this post


Link to post
Share on other sites

i made a mysql db class and now i want to make a function that parses the table into an array, i dont have that much php experience so can anyone help me?

<?php	if(!class_exists('cDB'))	{  class cDB  {  	var $lDB;  	function cDB($name)  	{    $this->lDB = mysql_connect();    mysql_select_db($name, $this->lDB);  	}  	  	function table($name)  	{    //parse table array here  	}  	  	function __destruct()  	{    mysql_close($this->lDB);  	}  }	}?>

Do you want to parse table, called $name, data?

no i want to return the row where column is data in an array

Share this post


Link to post
Share on other sites

no i want to return the row where column is data in an array

ok, maybe this will help
$result = mysql_query('SELECT * FROM '.$name) or trigger_error(mysql_error(), E_USER_ERROR);$arr = array();while($row = mysql_fetch_assoc($result)){	$arr[] = $row;}strip($arr);
Not completely sure, that this will work, as I cut it out of my sql class :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.