470,833 Members | 1,468 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

Looking for the most EFFICIENT way to do the following...

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

Jul 16 '05 #1
0 1323

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Simon Cooke | last post: by
6 posts views Thread by utkarsh | last post: by
16 posts views Thread by Dustan | last post: by
1 post views Thread by cwertman | last post: by
82 posts views Thread by Bill David | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.