hi - i am wondering if there is somebody that can help me out with this code here:
(two questions in one post)
<?
$query = "CREATE TABLE $today (
id smallint(3) NOT NULL auto_increment,
firstname TEXT NOT NULL,
lastname TEXT NOT NULL,
score smallint(2) NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM";
$resultt = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
{
$x = sizeof($array);
$query = "INSERT INTO $today(firstname, lastname, score) VALUES('$row2->firstname', '$row2->lastname', '$x')";
$resulti = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
unset($array);
}
$query = "SELECT * FROM $today ORDER BY score DESC LIMIT 10";
$resultf = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
if (mysql_num_rows($resultf) > 0)
{
// iterate through resultset
// print article titles
while($rowf = mysql_fetch_object($resultf))
{
$average = ($rowf->score / 0.17);
?>
<li><? echo $rowf->firstname ?> <? echo $rowf->lastname ?> - <? printf('%01.1f', $average) ?>%<br>
<?
}
}
else
{
}
echo '<br><br>';
$strSQL = mysql_query("DROP TABLE $today");
is it possible to insert the data that i have now going into a table into an array? i am not sure how i would do this, as i am looping the INSERT INTO line. basically i have the table that is created act as a temporarly holding point for the results of the loop until the every row has been processed (inside the loop). how do i go about this using an array?
also - the rows with the highest score value to be displayed - displaying the top10 including ties... is that even possible with an array? if it is not possible that way - how would i do it with the table/mysql query i am using right now?
using an array instead of creating/dropping a temp table should be faster and less demanding, right?