Results 1 to 17 of 17

Thread: load data from database to list menu

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Resolved load data from database to list menu

    i'm try to load data from database to list menu...but dont know y cannot work.....anyone can point out my mistake?? i attach my file together.......
    Attached Files Attached Files
    Last edited by kenny_oh; Nov 1st, 2005 at 10:16 AM.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: load data from database to list menu

    Code:
    	while ($x < $numrows){
    		$program = mysql_result($results, $x, "programTitle");
    
    
    		echo "<option>$program</option>\n"
    
    		
    		$x++;
    	}
    	}
    You have two closing curly brackets, you shoul only have one.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: load data from database to list menu

    that bracket is for the top side if statement!

  4. #4
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Re: load data from database to list menu

    It's mysql_num_rows() and you have mysql_NumRows()
    But it seems as if you're putting more work into it than you need, why not just loop through each record and print out your field, instead of calling mysql_result() each time through?
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Enter Program Schedule</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    .style1 {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 12px;
    }
    .style2 {color: #FF9933}
    .style5 {color: #000000}
    .style6 {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 14px;
    }
    .style7 {color: #FF0000}
    -->
    </style>
    </head>

    <body>
    <?php
        $host 
    "localhost";
        
    $dbname "Broadcast";
        
    $dbpass "";

        
    $connection mysql_connect("$host""$dbname","$dbpass");
        
    $db mysql_select_db("$dbname"$connection);

        
    $results mysql_query("select programTitle from tblProgram"$connection) or die(mysql_error());
        
    $numrows mysql_num_rows($results);

        if (
    $numrows 0)
        {
    ?>

    <form>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <div align="center">
      <table width="522" height="90" border="0">
        <tr>
          <td width="169" height="35"><div align="center" class="style1"><span class="style2">*</span>Program Title </div></td>
          <td width="23">&nbsp;</td>
          <td width="316"><div align="left">
            <input name="txtProgTitle" type="text" id="txtProgTitle" size="40">
            <select name="selectTitle" id="selectTitle">

    <?php
            
    while ($row mysql_fetch_assoc($results))
            {
                
    $program $row['programTitle'];
                echo 
    "<option>$program</option>\n"
            
    }
        }    

    ?>
            </select>
          </div></td>
        </tr>
        <tr>
          <td width="169" height="35"><div align="center" class="style1"><span class="style2">*</span>Episode</div></td>
          <td>&nbsp;</td>
          <td><div align="left">
            <input name="txtEpisode" type="text" id="txtEpisode">
          </div></td>
        </tr>
        <tr>
          <td width="169" height="35"><div align="center" class="style1"><span class="style2">*</span>Episode title </div></td>
          <td>&nbsp;</td>
          <td><div align="left">
            <input name="txtEpisodeTitle" type="text" id="txtEpisodeTitle" size="30">
          </div></td>
        </tr>
      </table>
      <p>&nbsp;</p>
      <table width="531" height="64" border="0">
        <tr>
          <td width="176" height="35"><div align="center" class="style1"><span class="style2">*</span>Date</div></td>
          <td width="20">&nbsp;</td>
          <td width="321"><div align="left">
            <select name="selectProgDay" id="selectProgDay">
              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8">8</option>
              <option value="9">9</option>
              <option value="10">10</option>
              <option value="11">11</option>
              <option value="12">12</option>
              <option value="13">13</option>
              <option value="14">14</option>
              <option value="15">15</option>
              <option value="16">16</option>
              <option value="17">17</option>
              <option value="18">18</option>
              <option value="19">19</option>
              <option value="20">20</option>
              <option value="21">21</option>
              <option value="22">22</option>
              <option value="23">23</option>
              <option value="24">24</option>
              <option value="25">25</option>
              <option value="26">26</option>
              <option value="27">27</option>
              <option value="28">28</option>
              <option value="29">29</option>
              <option value="30">30</option>
              <option value="31">31</option>
            </select>
            <select name="selectProgMonth" id="selectProgMonth">
              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8">8</option>
              <option value="9">9</option>
              <option value="10">10</option>
              <option value="11">11</option>
              <option value="12">12</option>
            </select>
            <select name="selectProgYear" id="selectProgYear">
              <option value="2005">2005</option>
              <option value="2006">2006</option>
              <option value="2007">2007</option>
              <option value="2008">2008</option>
              <option value="2009">2009</option>
              <option value="2010">2010</option>
            </select>
          </div></td>
        </tr>
        <tr>
          <td height="35"><div align="center" class="style1"><span class="style2">*</span>Time</div></td>
          <td>&nbsp;</td>
          <td><div align="left"><span class="style1"><span class="style2">*</span>Start</span>            
            <input name="txtStart" type="text" id="txtStart" size="10" maxlength="4"> 
                <span class="style1"><span class="style2">*</span>End</span>            <input name="txtEnd" type="text" id="txtEnd" size="10" maxlength="4"> 
                <span class="style2"><span class="style5">(</span><span class="style5"><span class="style2">*</span>eg: 1845)</span> </span></div></td>
        </tr>
      </table>
      <table width="529" border="0">
        <tr>
          <td width="171" height="87"><div align="center" class="style1"><span class="style2">*</span>Description</div></td>
          <td width="21">&nbsp;</td>
          <td width="315" height="90">
            <div align="left">
              <textarea name="txtDescription" cols="35" rows="5" wrap="VIRTUAL" id="txtDescription"></textarea>
            </div></td>
        </tr>
      </table>
      <table width="528" height="28" border="00">
        <tr>
          <td width="167" height="40">&nbsp;</td>
          <td width="25">&nbsp;</td>
          <td width="109"><div align="left"><img src="btn_Enter.gif" width="100" height="18"></div></td>
          <td width="199"><img src="cancel_btn.gif" width="100" height="18"></td>
        </tr>
      </table>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <table width="791" height="66" border="0" bgcolor="#FFFFFF">
        <tr>
          <td width="377"><div align="right"><img src="FIFA%202006.GIF" width="340" height="65"></div></td>
          <td width="398"><img src="NHL.GIF" width="340" height="65"></td>
        </tr>
      </table>
      <p><span class="style6">Kenny<span class="style7">Tv.com</span></span></p>
      <p>&nbsp;</p>
    </div>
    <div align="center">  </div>
    <p align="center">&nbsp;</p>
    </form>
    </body>
    </html>
    {yak}

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: load data from database to list menu

    data didnt load into menu...and this line code display at the top of the form

    0){ //$numrows = mysql_NumRows($results); //$x = 0; if ($numrows > 0){ ?>

  6. #6
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Re: load data from database to list menu

    Post the code you used, I don't see anywhere in the page I posted it has those lines...
    {yak}

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: load data from database to list menu

    here is my code:
    Attached Files Attached Files

  8. #8
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Re: load data from database to list menu

    We forgot a semicolon here:
    echo "<option>$program</option>\n";
    {yak}

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: load data from database to list menu

    i change alr....but that line stil exists and menu still empty

  10. #10
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Re: load data from database to list menu

    echo out $numrows or test the query to make sure it returns some rows.
    {yak}

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: load data from database to list menu

    nothing...js print out the word "echo '$numrows'

  12. #12
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Re: load data from database to list menu

    Do you have the page saved as .php?
    {yak}

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: load data from database to list menu

    errr..this is htm woh...want save as .php?

  14. #14
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Re: load data from database to list menu

    Yes, the file extension needs to be .php, so somepage.php.
    {yak}

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: load data from database to list menu

    oic...thank......i make this mistake...

  16. #16
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: load data from database to list menu

    Quote Originally Posted by {yak}
    Yes, the file extension needs to be .php, so somepage.php.
    Just want to clarify, it doesn't need to be this, its just the way the hoster has setup PHP. Most only allow the php extension. To make things simple for me, I enabled it for both html and php on my server.
    But, to be on the safe side, always use xxx.php.
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  17. #17
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Re: load data from database to list menu

    Quote Originally Posted by k1ll3rdr4g0n
    Just want to clarify, it doesn't need to be this, its just the way the hoster has setup PHP. Most only allow the php extension. To make things simple for me, I enabled it for both html and php on my server.
    But, to be on the safe side, always use xxx.php.
    Not a good thing because it causes PHP to be loaded for HTML files that may not require PHP at all, I believe its recommended to just use .php unless you really need to.
    Don't Rate my posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width