PHP result from SQL by text box value

Started on the old forum in May 2014 · view the original in the archive · old links redirect here

1 reply · 109 views · started 12 years ago · 1 min read

2 participants
loveme Junior · 16 posts #1

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>

<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> 

arnage Lead · 811 posts #2

You need to fetch the result from $result = mysql_query($query);

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close