NYCPHP Meetup

NYPHP.org

Help!!

jose sanchez j_r_sanchez at yahoo.com
Wed May 29 15:18:15 EDT 2002


Hi All:

I am having a little problem:

I am trying to load a file's path from a DB and store
the record_id on an array. That way the next time the
function is called I don't get a repeated file into
the page. In other words, I'm trying to simulate
randomized links to be included on the page but, I
don't want it to repeat.


$path='NULL';
$text = array( 2, 3, 6, 9 );
$currentPath = 1;

//the function gets called from different places
several times like this: 
<tr>
<td><? get_file( $currentPath++ ); include($path); ?>
</td>
</tr>


function get_file($cur){
   global $path, $text;
   if( $cur == 1 )
    {
     $id = rand( 1, 10 );
     $sql = "select path from table where rec_id=$id";
     $result = runQuery( $sql );
     ..... database functions work .......
     $text[1]=$id;
     list( $path ) = mysql_fetch_array($result);
    }
   else
    {
     while( !checkId( $id=rand( 1, 10 ) ) )
      {
        $id = rand( 1, 10 );
     $sql = "select path from table where rec_id=$id";
     $result = runQuery( $sql );
     ..... database functions work .......
     $text[$cur]=$id;
     list( $path ) = mysql_fetch_array($result);
}
    }
}// endFunction

function checkId( $id )
{
  global $text;

   for($i=1; $i<5; $i++ )
   {
    if( $text[$i]==$id )
     print( 'Compared...' );
     return true;
   }
   return false;

}

Some how the print statement in the checkId() never
gets executed. I don't know why. What am I doing
wrong?

Please help.

Thanks.

=====
"An ounce of gold cannot buy an ounce of time."
- Anonymous


www.whmicro.com

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



More information about the talk mailing list