Re-assign array

Hi guys,

Can somebody give me an idea how to assign the arrays I assigned in the for loop and the re-assign to another array as the script below ?

 <?PHP 
$ct1=mysql_query("SELECT id FROM `num` ORDER BY `id` DESC LIMIT 0,1")or die (mysql_error());
$ct2=mysql_fetch_array($ct1);
 
for ( $ss=$ct2['id']+1; $ss--;)
{
$cons_mag1=mysql_query("SELECT draw_id FROM `num` WHERE `id` = '$ss' ")or die (mysql_error());
$cons_mag2=mysql_fetch_array($cons_mag1);
$cons_mag3 = mysql_query("SELECT * FROM  `draw_doc` WHERE `type` = 'num' AND `draw_id` = '{$cons_mag2['draw_id']}' AND number = '1111' ORDER BY  `time` DESC ");
$cons_mag4=mysql_num_rows($cons_mag3);
if ("$cons_mag4" == '0')
{
$tp[]=0;
}
else
{
$tp[]=1;
}
} 
     

  // assign values of $tp[] to array() below
        $SQLQuery = array($tp[0],$tp[1],$tp[2],$tp[3],$tp[4],$tp[5],$tp[6],$tp[7],$tp[8],$tp[9],$tp[10]);
        // $SQLQuery = array(1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0); <- output something like this
        $max = 0;
        $cur = 0;
        $last = 0;
      ?>

Then another question will be how can I actually count the same most time value 1 is displayed consecutively in the script below?

// just count max of number 1 only and ignore number 0
        for ($i=0, $x=sizeof($SQLQuery); $i<$x; $i++) {
  $SQLQuery[$i] == $last ? $cur++ : $cur = 1;
        $last = $SQLQuery[$i];
        if($cur > $max) $max = $cur;
        }
 
        echo $max;

Your advise will be appreciated and thank you.

Oh my, you do know you can do all this in a single query don’t you? :eek:

Hmm… if I know I have already done it my friend. Can you advise on this. Thank you very much