I have a table that has links in it.
Columns: id, item, link_name, url.
I want to run through the recordset of this table and so something like
the following.... (Obviously, the following didn't work. I'd like to be
able to do something like this, avoiding having to make several seperate
database calls.)
[begin code]
$sql = "SELECT * FROM table ORDER BY item";
$res = pg_query($db,$sql);
//Echo out all links with an item of 1...
while(list($id,$item,$link_name,$url) = pg_fetch_row($res) && $item == 1) {
printf("<a href=\"%s\">%s</a><br>",$url,$link_name);
}
//Echo out other junk
echo $someStuff1;
//Echo out all links with an item of 2...
while(list($id,$item,$link_name,$url) = pg_fetch_row($res) && $item == 2) {
printf("<a href=\"%s\">%s</a><br>",$url,$link_name);
}
//Echo out other junk
echo $someStuff2;
//Et cetera
while(list($id,$item,$link_name,$url) = pg_fetch_row($res) && $item == 3) {
printf("<a href=\"%s\">%s</a><br>",$url,$link_name);
}
echo $someStuff3;
while(list($id,$item,$link_name,$url) = pg_fetch_row($res) && $item == 4) {
printf("<a href=\"%s\">%s</a><br>",$url,$link_name);
}
echo $someStuff4;
[end code]
Any ideas?
--
Sugapablo - ru***********@stargate.net
http://www.sugapablo.com | ICQ: 902845