In php page i have 2 buttons 1st button is for retrieving data from db and 2nd button also is for retrieving data from db in execution when i pressed 1st button its showing data and at the same time when i pressed 2nd button its showing data but same time the page losing 1st button data .i want to be displayed both button data at same time can any one help me please????????? ????????????
Code:
<html>
<head>
<title>
Search details Form
</title>
</head>
<body>
<form method = "POST" action = "search2.php">
Dealer ID<input type = "text" id = "DealerId" name = "DealerId">
<input type = "submit" name = "submit1" value = "Search1" >
<?php
if(isset($_POST['submit1']))
{
$name = $_POST['DealerId'];
if($name != "")
{
mysql_connect("localhost", "root", "");
mysql_select_db("rajesh");
$sql = "select * from dealerlist where DealerID like '%".mysql_real_escape_string($name)."%'";
$result = mysql_query($sql);
$numRows = mysql_num_rows($result);
if(empty($numRows))
{
echo "Record are not exits";
}
else{
while($row = mysql_fetch_array($result))
{
?>
<table>
<tr><td>Dealer ID<td><input type = "text" name = "Name" value = "<?php echo $row['DealerID']; ?>">
<tr><td>Dealer Name<td><input type = "text" name = "Age" value = "<?php echo $row['DealerName']; ?>">
<tr><td>Address<td><input type = "text" name = "Sex" value = "<?php echo $row['Street']; ?>"></tr>
</table><br>
ItemNo<input type = "text" name = "ItemNo">
<input type = "submit" name = "submit2" value = "search2">
<?php
}
}
}
}
if(isset($_POST['submit2']))
{
$name1 = $_POST['ItemNo'];
if($name1 != "")
{
mysql_connect("localhost", "root", "");
mysql_select_db("rajesh");
$sql1 = "select * from itemlist where ItemNO like '%".mysql_real_escape_string($name1)."%'";
$result1 = mysql_query($sql1);
$numRows1 = mysql_num_rows($result1);
if(empty($numRows1))
{
echo "Record are not exits";
}
else{
while($row1 = mysql_fetch_array($result1))
{
?>
<table>
<tr><td>Item No<td><input type = "text" name = "ItemNo" value = "<?php echo $row1['ItemNo']; ?>">
<tr><td>Item Name<td><input type = "text" name = "ItemName" value = "<?php echo $row1['ItemName']; ?>">
</table>
<?php
}
}
}
}
?>
Comment