SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    a fresh, new start... dujmovicv's Avatar
    Join Date
    Aug 2006
    Location
    Earth
    Posts
    559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    retrive items from dBase

    Hi,
    my script is intended to get menu items from a dBase and to put them between hyperlink tags <a>, however instead it puts the first item "it1" and the rest is blank. I know this will be a child game to you (php/mysql experts )
    PHP Code:
    <?
     $query 
    "SELECT lang, it1, it2, it3, it4, it5 FROM menu WHERE id = $selected_lang";
     
    $result mysql_query($query) or die('Error : ' mysql_error());
    ?>

    <div class="hovermenu">
    <ul>
    <li><a href="" ><?      $row mysql_fetch_array($result);  printf($row['it1']);    ?>
    </a></li>
    <li><a href="" ><?      $row mysql_fetch_array($result);  printf($row['it2']);    ?>
    </a></li>
    <li><a href=""><?      $row mysql_fetch_array($result);  printf($row['it3']);    ?>
    </a></li>
    <li><a href=""><?      $row mysql_fetch_array($result);  printf($row['it4']);    ?>
    </a></li>
    <li><a href=""><?      $row mysql_fetch_array($result);  printf($row['it5']);    ?>
    </a></li>        
    </ul></div>
    Your help is greatly appreciated!

    Full time ADMIN - art community
    Part time coder - dsign

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,491
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    You got all 5 items in one row of the DB?
    Then you need to do only one fetch. Put it after the mysql_query line.
    And cancel the 5 fetches you got right now.

    Though you'd better normalize your DB. Have a menu-table with three fields (menuId, lang, item) and 1 line for each menu item. That way you can have more or less than 5 items for a menu. It's more flexible that way.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •