Re: how to reuse DB results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry for mystakes, ....(shame on me, i said i was new) using Object array,
here is a working version (tested) with use of array.

Bye

$recordset=mysql_query('SELECT * FROM my_tabella'); // or whatever query is

/* define an array with fields to be shown on top of page. Attention
...values name must be the same of table field names you want to show on top
of the page*/
$my_key = array('key01','key02','key03'); /* u can use $_REQUEST variables
instead of
fixed values*/
$i=0;
while($record=mysql_fetch_array($recordset, MYSQL_ASSOC))
{
    foreach ($record as $k=>$val)
        if ($k==$my_key[$i])
        {
            // echo the top of the page
            echo "<p>$k :$val</p>";
            /* if u need a top_array to store result shown on top of the
page, comment this line only
            $top_array[$i]=$val; // loose the matching key<->field!! */
            $i++;
        }
}

//reset the resource
mysql_data_seek($recordset,0);

// some middle-page code here

echo '<p>this is the bottom page and displays the whole result</p>';
while ($record=mysql_fetch_array($recordset, MYSQL_ASSOC))
    foreach ($record as $k=>$val)
        echo "<p>$k : $val</p>"; // make your choice for html code

mysql_free_result($recordset);

// Bye

"Aaron Wolski" <aaronjw@xxxxxxxxxxxxx> ha scritto nel messaggio
news:032e01c43ea6$f099efd0$6901a8c0@xxxxxxx
> Hi All,
>
> Got this logic problem I don't know how to solve.
>
> Is there any way I can make a call to the DB for some records.
>
> Display some info from a column or two say at the top of the page and
> then display the full result set in a while() loop?
>
> Right now, I am making two calls to the Db to get the data I need to
> display at the top of the page and then a second query to retrieve the
> full result set.
>
> I'm confused!
>
> Thanks for any help!
>
> Aaron

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux