SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MYSQL Database Driven Dropdown Menu Query?

    I've done a dropdown menu which lists values from the database. The problem is it is always missing one of the values from the database and it seems to be the last one in the list? I'm unsure why? Any ideas?

    PHP Code:
    <?

    require_once('../../podcast/database.class.php');
    include(
    "../../fckeditor/fckeditor.php");

    $database = new database();
    $link_id $database->database_connection();
    $query "select * from programs ORDER BY program_title DESC";
    $result mysql_query($query) or die(mysql_error());
    $total_rows mysql_num_rows($result);
    $file mysql_fetch_array($result);
    if (!
    $result)    
        {
            print 
    'There was a database error when executing';
            print 
    mysql_error();
            exit;
        }

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />




    <style type="text/css">
    <!--
    -->
    </style>

    <link href="../../style/aim.css" rel="stylesheet" type="text/css" />
    <link href="../../style/admin.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    <!--
    .style4 {font-size: 12px; color: #FFFFFF; }
    -->
    </style>
    </head>

    <body>
    <div id="wrapper">
    <div id="header"></div>
    <div id="nav"><div id="nav_txt">| Admin Home | Exit </div>
        <!-- Div tags for date and time in nav bar -->
      <div id="time"></div>
      <div id="date"></div>
    </div>

    <div id="main"><div id="admin_main_float"><form action="upload.php" enctype="multipart/form-data" method="post">
      <table width="100%" cellpadding="4">
        <tr>
          <td bgcolor="#330066"><span class="style4">Title</span></td>
          <td bgcolor="#330066"><input name="title" type="text" /></td>
        </tr>
         <tr>
          <td bgcolor="#330066"><span class="style4">Author</span></td>
          <td bgcolor="#330066"><input name="author" type="text" /></td>
        </tr>
        <tr>
          <td bgcolor="#330066"><span class="style4">Programme</span></td>
          <td bgcolor="#330066">
         <?php
        
    echo "<select name=\"program\">";
        if(
    mysql_num_rows($result))
        {
        while(
    $file mysql_fetch_assoc($result))
        {
        echo 
    "<option value=\"$file[id]\">$file[program_title]</option>";
        }
     
        }
        else {
        echo 
    "<option>No Programs</option>"
        }
        
    ?>
          
          
          
          </td>
        </tr>

        <tr>
          <td bgcolor="#330066"><span class="style4">Text</span></td>
          <td bgcolor="#330066"><?php
                        $oFCKeditor 
    = new FCKeditor('rte1');
                        
    $oFCKeditor->BasePath '../../../fckeditor/';
                        
    $oFCKeditor->Value '';
                        
    $oFCKeditor->Height '400' ;
                        
    $oFCKeditor->Create();
                        
    ?></td>
        </tr>

        <tr>
          <td bgcolor="#330066" colspan="2"><input name="submit" type="submit" value="Add" /></td>
        </tr>
      </table>
    </form></div>
    </div>
    </div>
    </body>
    </html>

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    get rid of the
    PHP Code:
    $file mysql_fetch_array($result); 
    on line 11.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


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
  •