0

Hello all,

Guys need some advise and some help regarding displaying data from database...
so, basically this is what i'm trying to do, have a keyword (invoice_no)...i'm suppose to search the database, and the find record...the display the remaining attributes (document_no,pallet_no and so on)


invoice.php

<FORM ACTION=".php" METHOD=get>
<h1>Enter your Invoice No.</h1>
<table>
<tr>
<td>Invoice No. :</td><td><input name="invoice_no" type="text" size"20"></input></td>
</tr>
</table>
<input type="submit" name="Submit" value="Submit" id="invoiceno"></input>
</FORM>
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="testdata"; // Database name
$tbl_name="testdata"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

$invoiceno=$_POST['invoice_no'];

$sql="SELECT * FROM $tbl_name WHERE invoice_no='$invoiceno'";

?>

can't think of anyway to proceed...thank u in advance

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by gopi17
0

Before you even look at getting the query results as @ardav has mentioned, your query will fail anyway as your form variables are wrong to work with what you are trying to do (you have put the method as get then tried to get the value using post - also not sure where your form is supposed to be submitting to with just .php in the action).

Change your form tag to

<form action="nameofpagetosubmitot.php" method="post">
0

okay...i did some reading and changes to the code....but still cant retrieve the value from the other form

<FORM ACTION="displaydata.php" METHOD="post">
<h1>Enter your Invoice No.</h1>
<table>
<tr>
<td>Invoice No. :</td><td><input name="invoiceno" type="text" size"25"></input></td>
</tr>
</table>
<input type="submit" value="Submit"></input>
</FORM>
<?php
session_start();
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="testing"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die(mysql_error());

$invoiceno = $_POST['invoiceno'];
//echo $invoiceno;

// $sql="SELECT * FROM $tbl_name WHERE invoice_no=='$invoiceno'";
// $result = mysql_query ($sql);
// if ($result) {
// while ($row = mysql_fetch_array ($result)) {
// echo $row[0] . "<br>";
// }
// }
?>
0

my bad...was running the php file without inserting the value...it works now...thank u and sorry

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.