PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function getTable($table)
{
//fetch data
$sql = "SELECT * FROM " . $table;
$q = mysql_query($sql);
while($row = mysql_fetch_array($q))
{
echo $row[0] . "<br>";
echo $row[1] . "<br>";
}
}
I need help with the logic of replacing $row[0] / $row[1] for something more dynamic based on the table's row number.. and I can't seem to figure it out..
any tips would be much appreciate it!
First of all, don't use the mysql extension. It's deprecated and generally terrible and will be removed from PHP. Look at PDO instead. Secondly, why is your function echoing values (and line breaks!) rather than returning an array?