Page 1 of 1

call the first raw of a while loop from another file

Posted: Sun May 17, 2009 12:50 am
by joelitos
The while loop below uses mysql_fetch_assoc and it has several rows and it is located in a file call example1.php. But what I want is to call the first row of this while loop found in example1.php from another file call shoe.php. it's that possible?

Code: Select all

$sql = 'SELECT id,Subject FROM menusubjects;';
$result = mysql_query($sql);
 
if($result && mysql_num_rows($result)!=0) {
    
    echo '<ul id="nav-categories">';
    
    while($row = mysql_fetch_assoc($result)) {
        
        $uri = 'example1.php?subject='.urlencode($row['id']);
        $class = !is_null($cat) && $cat==$row['id']?' class="selected"':'';
        
        echo "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>';
            
        if($submenu==false && !is_null($cat) && $cat == $row['id']) { 
 

Re: call the first raw of a while loop from another file

Posted: Sun May 17, 2009 2:06 am
by Benjamin
No, it's not.

Re: call the first raw of a while loop from another file

Posted: Sun May 17, 2009 2:48 am
by joelitos
I have three query in a file. the first one the third one call the same fields. They are styled different and I want that when a users click on the third query it affect the first query by opening it's while loop through a link in the last query.

Re: call the first raw of a while loop from another file

Posted: Sun May 17, 2009 2:59 am
by Benjamin
Listen, we would really like to help you, but you really ought to show some effort in two ways. 1. At least try to research how to write the code. 2. At least ask your question in a clear concise manor.