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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sugapablo

    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,$s ql);

    //Echo out all links with an item of 1...

    while(list($id, $item,$link_nam e,$url) = pg_fetch_row($r es) && $item == 1) {
    printf("<a href=\"%s\">%s</a><br>",$url,$l ink_name);
    }

    //Echo out other junk

    echo $someStuff1;

    //Echo out all links with an item of 2...

    while(list($id, $item,$link_nam e,$url) = pg_fetch_row($r es) && $item == 2) {
    printf("<a href=\"%s\">%s</a><br>",$url,$l ink_name);
    }

    //Echo out other junk

    echo $someStuff2;

    //Et cetera

    while(list($id, $item,$link_nam e,$url) = pg_fetch_row($r es) && $item == 3) {
    printf("<a href=\"%s\">%s</a><br>",$url,$l ink_name);
    }

    echo $someStuff3;

    while(list($id, $item,$link_nam e,$url) = pg_fetch_row($r es) && $item == 4) {
    printf("<a href=\"%s\">%s</a><br>",$url,$l ink_name);
    }

    echo $someStuff4;

    [end code]


    Any ideas?


    --
    Sugapablo - russpghREMOVE@s targate.net
    http://www.sugapablo.com | ICQ: 902845

Working...