I have a mysql query:
$analyse_ot1="SELECT COUNT(*) AS ot_count FROM first, base, users
WHERE base.base_id=$base
AND
users.base_id=$base
AND
users.id=first.user_id
AND
first.$sub='OT'";
$result_ot1=mysqli_query($con,$analyse_ot1);
$row_ot1= mysqli_fetch_assoc($result_ot1);
$total_ot1= $row_ot1['ot_count'];
$otper1=($total_ot1/$total)*100;
I will be re-using this code many times on a web-page and want to be able to run it as part of a loop.
I don't want to have to rename my variables each time (where $result_ot1 become $result_ot2 etc...)
I've tried introducing an indexing variable $x and then appending it to another variable name:
$x=2;
$result_ot.$x=....
But , it doesn't want to work.
Any suggestions? I have an idea that arrays might be needed but I'm concerned that the queries will be throwing up arrays and I'm not sure an array in an array isn't going to set my computer on fire...