call the first raw of a while loop from another file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joelitos
Forum Newbie
Posts: 10
Joined: Sun May 17, 2009 12:43 am

call the first raw of a while loop from another file

Post 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']) { 
 
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

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

Post by Benjamin »

No, it's not.
joelitos
Forum Newbie
Posts: 10
Joined: Sun May 17, 2009 12:43 am

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

Post 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.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

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

Post 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.
Post Reply