Trouble pulling data from MySQL

First off, please excuse my ignorance, it has been a while since I have written any code. Trying to run a pretty simple query here to pull data from a MySQL database. The code is as follows;

$sql = 'SELECT type, value FROM ' . $TBLPREFIX . 'config';
$data = mysql_query($sql);
$rs = mysql_fetch_array($data);

print_r($rs);

The print_r only shows the first row being fetched. There are currently three rows in the table. Not sure what I am missing here.

Hi zkiller,

mysql_fetch_array only fetches a single row of results at a time. You can loop over the results with a while loop:


while($row = mysql_fetch_array($data)) {
    print_r($rs);
}

You shouldn’t really use the mysql functions any more though, as they’ve been depreciated and will be removed from PHP at some point. It’s better to use [fphp]mysqli[/fphp] or [fphp]PDO[/fphp].

Thanks, I knew I was missing something. Oh and thanks for the info the mysql function being deprecated soon. After some quick research, I think I will rewrite using PDO. I quite like it.