Can't Get Information to Display

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashraf02
    New Member
    • Feb 2008
    • 53

    #1

    Can't Get Information to Display

    I have used the following code so i could display information from mysql table on to the webpage but when i select a subject from the drop down menu nothing appears can someone please help.

    Code

    [PHP]<?php
    $conn = mysql_connect ("localhost","r oot","")
    or die (mysql_error()) ;
    mysql_select_db ("noble",$co nn) or die (mysql_error()) ;

    if ($_POST[op] != "view") {
    $display_block = "<h1>Select Entry</h1>";

    $get_list = "SELECT Suit_ID, Suit_Brand as display_suit
    FROM suits
    ORDER BY suit_brand";
    $get_list_res = mysql_query($ge t_list) or die (mysql_error()) ;

    if (mysql_num_rows ($get_list_res) < 1) {
    $display_block .= "<p><em>No Records</em></p>";

    }else{
    $display_block .= "
    <form method=\"post\" action=\"$_SERV ER[PHP_SELF]\">
    <p><strong>Sele ct Brand</strong></p>
    <select name\"Sel_id\">
    <option value\"\">-- Select One --</option>";

    while ($recs = mysql_fetch_arr ay($get_list_re s)){
    $id= $recs ['Suit_ID'];
    $display_suit = stripslashes ($recs['display_suit']);

    $display_block .= "<option value=\"$id\">
    $display_suit</option>";
    }
    $display_block .= "
    </select>
    <input type=\"hidden\" name=\"op\" value=\"view\">
    <p><input type=\"submit\" name=\"submit\" value=\"View Selected Entry\"></p>
    </form>";
    }
    } else if ($_POST[op] == "view") {

    if ($_POST[Sel_ID] =="") {
    header("locatio n:selentry.php" );
    exit;

    }

    $get_master = "SELECT Suit_Brand, Suit_Type, Suit_Colour, Suit_Price, Suit_Descriptio n AS
    display_suit
    FROM suits
    WHERE suit_id = $_POST[sel_id]";
    $get_master_res = mysql_query ($get_master);

    $display_suit = stripslashes (mysql_result ($get_master_re s,0,'display_su it'));
    $display_block = "<h1>Showin g Record for $display_suit</h1>";

    if (mysql_num_rows ($get_master_re s)>0) {

    $display_block .= "<p><strong>Inf ormation:</strong></p>
    <ul>";

    while ($add_info = mysql_fetch_arr ay($get_master_ res)){
    $Brand = $add_info[Suit_Brand];
    $Type = $add_info[Suit_Type];
    $Colour = $add_info[Suit_Colour];
    $Price = $add_info[Suit_Price];
    $Description = $add_info[Suit_Descriptio n];


    $display_block .= "<li>$Brand $Type $Colour $Price ($Description)" ;


    }

    $display_block .= "</ul>";

    }
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet " type="text/css" href="Insert_Fo rms/NobleForms.css"/>
    <title>Shirt Form</title>
    </head>
    <body>
    <?php echo $display_block; ?>
    </body>
    </html>[/PHP]

    Thanks in advance.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    After the first submit the $_POST array contains a value. After the second submit from the generared form the $POST array does no longer contain that value from the first submit, but only the value from the generated form, i.e. the second submit.

    Ronald

    Comment

    Working...