You can use this function to grab data from your database by creating an array and calling the function. You should be able to make each parameter an array (the table, field, etc) but I have only tested the field parameter. The require include.php contains the database info: $DBhost, $DBuser, $DBpass, $DBname, etc...
PHP Example :
<?php
require 'include.php';
function ConnectToTable( $field, $tableName, $data, $data2 )
{
require 'include.php';
$fieldCount = count($field);
for ($i=0; $i<$fieldCount;$i++)
{
$connection = mysql_connect($DBhost, $DBuser, $DBpass) or die ("Unable to connect to MySQL server.");
$db = mysql_select_db($DBname, $connection) or die ("Unable to select database.");
$sql = "SELECT $field[$i] FROM $tableName WHERE $data = $data2";
// testing sql statement
echo ("sql: $sql <br>");
$sql_result = mysql_query($sql,$connection) or die ("Couldn't execute SQL query");
//---------------------------------------------------------------------------------------------------------------
//
// Put the fields you want to query from the database into an array
// Then make another array to hold the data.
// ConnectToTable( A, B, C, D )
//
// The query will look like: SELECT A FROM B WHERE C = D
//
// $fieldCount just counts how many fields you use, in this case I used a 'for loop' to output the data.
//
//---------------------------------------------------------------------------------------------------------------