PHP result from SQL by text box value

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PHP result from SQL by text box value

    I am trying to get php result based on text box value from mysql database. I tried with the following code. But I am struggle in display result. When user enter valid number it show result with table else it show the label enter correct code./style></head>
    PHP Code:
    <body>

    <div class="container">
    <div class="header"><a href="#"></a>
    <!-- end .header -->WELCOME</div>
    <div class="content">
    <h1>&nbsp;</h1>
    <p>&nbsp;</p>
    <?php
    mysql_connect
    ("localhost""root""root") or die("Connection Failed");
    mysql_select_db("marks")or die("Connection Failed");
    $name $_POST['regno'];
    $query "select * from six where No = '$name'";
    $result mysql_query($query);

    ?>
    <form name="form1" method="post" action="">
    <p>
    <label for="regno"> Register Number</label>
    <input type="text" name="regno" id="regno">
    </p>
    <p>&nbsp;</p>
    <p>
    <input type="submit" name="Get result" id="Get result" value="Submit">
    </p>
    </form>
    <p>&nbsp;</p>
    <table width="471" border="1" align="center">
    <tr>
    <th height="43" colspan="2" scope="col">Register Number :</th>
    </tr>
    <tr>
    <th height="45" colspan="2" scope="col"> Name : </th>
    </tr>
    <tr>
    <th width="140" scope="col">Subject 1</th>
    <td width="315">&nbsp;</td>
    </tr>
    <tr>
    <td>Subject 2</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Subject 3</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Subject 4</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Subject 5</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Total</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Result</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <!-- end .content --></div>
    <div class="footer">
    <p>Powered By @ 2014</p>
    <!-- end .footer --></div>
    <!-- end .container --></div>
    </body>
    Last edited by arnage; 04.07.14, 12:51.

    #2
    You need to fetch the result from $result = mysql_query($query);
    <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

    Comment

    Working...
    X