Im new to php so I decided to make site to test what i have learnt so far, nothing fancy just a test of php skills..
So I created a MySQL database (also new to), with a schema called items, a table called things, with 10 columns, idthings being the identifyer and then the other columns where just tf2 classes.
I wanted users to sign up (done that) and imput what masks they have for an event, therre is one mask for each class (in other words ten different masks, but you can get mutiples of each mask. so i created an imput page so the data would be put into a database with idthing equal to their name and then an integer depending on how many of the masks/hats they had.
Now ive got a group that distributes the hats evenly through the group, with everyone getting one hat.
SO i did this:
$resultgroup = mysql_query("SELECT SUM(*) FROM '$class'.things");
Where class is supposed to cycle through the 9 different classes and so $resultgroup would be an array of 9 numbers each number the sum of how many of each hat/masks that all the users had.
I can't work out how to make $class cycle through the 9 different columns which are named after each class.
Im rather confused myself as to what im trying to do!
Hopefully this post isnt so long that everybody gets bored and stop reading! (if youve made it this far well done!
This is part of my page but not the whole thing , i think it is pretty self contained though
<?php
echo "<h3>What is required:</h3>";
$con = mysql_connect("localhost","tf2","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("items", $con);
$needed=mysql_query("SELECT COUNT(idthing) FROM things");
$class='...................';
$resultgroup = mysql_query("SELECT SUM(*) FROM \"$class\".things");
echo "
<tr>
<td>Scout?</td> //possibly i could use a loop here to just cycle through each of the
<td>Soldier?</td> //classes names
<td>Pyro?</td>
<td>Demoman?</td>
<td>Heavy?</td>
<td>Engineer?</td>
<td>Medic?</td>
<td>Sniper?</td>
<td>Spy?</td>
</tr>";
while($col = mysql_fetch_array($resultgroup))
{
echo "<td>" . $col[$class] . "</td>";
}
echo "</tr>
THanks in advance Dragazarth