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> </h1>
<p> </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> </p>
<p>
<input type="submit" name="Get result" id="Get result" value="Submit">
</p>
</form>
<p> </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"> </td>
</tr>
<tr>
<td>Subject 2</td>
<td> </td>
</tr>
<tr>
<td>Subject 3</td>
<td> </td>
</tr>
<tr>
<td>Subject 4</td>
<td> </td>
</tr>
<tr>
<td>Subject 5</td>
<td> </td>
</tr>
<tr>
<td>Total</td>
<td> </td>
</tr>
<tr>
<td>Result</td>
<td> </td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<!-- end .content --></div>
<div class="footer">
<p>Powered By @ 2014</p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
Comment