Hi. I am trying to save myself some coding. I think this is a php question rather than sql...
I have 5 tables in database called plan1, plan2 etc.. with each one having 9 columns (tot1, tot2, tot3, tot4, etc..)
I am wondering if there is a way to do something like the following :
where $_SESSION[plan] says which table to use and $c is which total to get.
This would save me writing out the same script 9 times.
Any hints you can give on how to achieve this would be great!
I have 5 tables in database called plan1, plan2 etc.. with each one having 9 columns (tot1, tot2, tot3, tot4, etc..)
I am wondering if there is a way to do something like the following :
PHP:
$c=1;
require("connectdb.php");
while ($c <= 9)
{
$u=$_SESSION[refs][$c-1];
$result = mysql_query("SELECT * FROM [COLOR=red]plan.$_SESSION[plan][/color]
WHERE userid = '$u' LIMIT 1");
while($row = mysql_fetch_array($result))
{
$_SESSION[rlvltot][$c-1]=[COLOR=red]$row['tot.$c'][/color];
}
$c++;
}
mysql_close($con);
where $_SESSION[plan] says which table to use and $c is which total to get.
This would save me writing out the same script 9 times.
Any hints you can give on how to achieve this would be great!