SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2008
    Location
    Pakistan
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile i have created a list menu in java script but it does not retrieve data from database

    i have created a list menu in java script but it does not retrieve data from database using php

    plz check this code why it doest retrieve data from data base using php

    function addnewrow()
    {
    var divNew = document.getElementsByTagName("p")[0];
    var tbl = document.createElement("table");
    var tblBody = document.createElement("tbody");

    var row = document.createElement("tr");

    //var fDiv = document.getElementById('fields');
    var cell = document.createElement("td");
    var combo_box = document.createElement('select');
    combo_box.name = 'prod';
    <?php
    $sql_p=mysql_query("select * from products_card");
    while($prs = mysql_fetch_array($sql_p))
    {
    ?>

    var choice = document.createElement('option');
    choice.value = '<?php echo $prs['product_name']; ?>';
    choice.appendChild(document.createTextNode('<?php echo $prs['product_name']; ?>'));
    combo_box.appendChild(choice);
    <?php
    }
    ?>
    cell.appendChild(combo_box);
    row.appendChild(cell);
    tblBody.appendChild(row);
    tbl.appendChild(tblBody);
    divNew.appendChild(tbl);
    }

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,181
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    What errors are you getting?
    Did you forget the connection stuff. i.e. username, password, dbhost, dbname?

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2008
    Location
    Pakistan
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    But it does not show the retrirving data from database in list menu....i have some records in database but it does not show

    connection page is include in this page....its right

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,181
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    If you try
    PHP Code:
        while($prs mysql_fetch_array($sql_p))
        {
    var_dump($prs);
    ?> 
    what do you get?

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2008
    Location
    Pakistan
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Thanx.......Now its work correctly


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
  •