By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,890 Members | 1,048 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,890 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.