473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to make autopost back for 2 buttons on same page using php

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








Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>
  4. Search details Form
  5. </title>
  6. </head>
  7. <body>
  8. <form method = "POST" action = "search2.php">
  9. Dealer ID<input type = "text" id = "DealerId" name = "DealerId">
  10. <input type = "submit" name = "submit1" value = "Search1" >
  11. <?php
  12. if(isset($_POST['submit1']))
  13. {
  14. $name = $_POST['DealerId'];
  15. if($name != "")
  16. {
  17. mysql_connect("localhost", "root", "");
  18. mysql_select_db("rajesh");
  19. $sql = "select * from dealerlist where DealerID like '%".mysql_real_escape_string($name)."%'";
  20. $result = mysql_query($sql);
  21. $numRows = mysql_num_rows($result);
  22. if(empty($numRows))
  23. {
  24.     echo "Record are not exits";
  25. }
  26.  
  27. else{
  28. while($row = mysql_fetch_array($result))
  29. {
  30. ?>
  31. <table>
  32. <tr><td>Dealer ID<td><input type = "text" name = "Name" value = "<?php echo $row['DealerID']; ?>">
  33. <tr><td>Dealer Name<td><input type = "text" name = "Age" value = "<?php echo $row['DealerName']; ?>">
  34. <tr><td>Address<td><input type = "text" name = "Sex" value = "<?php echo $row['Street']; ?>"></tr>
  35. </table><br>
  36. ItemNo<input type = "text" name = "ItemNo">
  37. <input type = "submit" name = "submit2" value = "search2">
  38. <?php
  39. }
  40. }
  41. }
  42. }
  43. if(isset($_POST['submit2']))
  44. {
  45. $name1 = $_POST['ItemNo'];
  46. if($name1 != "")
  47. {
  48. mysql_connect("localhost", "root", "");
  49. mysql_select_db("rajesh");
  50. $sql1 = "select * from itemlist where ItemNO  like '%".mysql_real_escape_string($name1)."%'";
  51. $result1 = mysql_query($sql1);
  52. $numRows1 = mysql_num_rows($result1);
  53. if(empty($numRows1))
  54. {
  55.     echo "Record are not exits";
  56. }
  57. else{
  58. while($row1 = mysql_fetch_array($result1))
  59. {
  60. ?>
  61. <table>
  62. <tr><td>Item No<td><input type = "text" name = "ItemNo" value = "<?php echo $row1['ItemNo']; ?>">
  63. <tr><td>Item Name<td><input type = "text" name = "ItemName" value = "<?php echo $row1['ItemName']; ?>">
  64. </table>
  65. <?php
  66. }
  67. }
  68. }
  69. }
  70. ?>
  71.  
Jan 10 '13 #1
4 2405
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <title>
  3. Search details Form
  4. </title>
  5. </head>
  6. <body>
  7. <form method = "POST" action = "search2.php">
  8. Dealer ID<input type = "text" id = "DealerId" name = "DealerId">
  9. <input type = "submit" name = "submit1" value = "Search1" >
  10. <?php
  11. if(isset($_POST['submit1']))
  12. {
  13. $name = $_POST['DealerId'];
  14. if($name != "")
  15. {
  16. mysql_connect("localhost", "root", "");
  17. mysql_select_db("rajesh");
  18. $sql = "select * from dealerlist where DealerID like '%".mysql_real_escape_string($name)."%'";
  19. $result = mysql_query($sql);
  20. $numRows = mysql_num_rows($result);
  21. if(empty($numRows))
  22. {
  23.     echo "Record are not exits";
  24. }
  25.  
  26. else{
  27. while($row = mysql_fetch_array($result))
  28. {
  29. ?>
  30. <table>
  31. <tr><td>Dealer ID<td><input type = "text" name = "Name" value = "<?php echo $row['DealerID']; ?>">
  32. <tr><td>Dealer Name<td><input type = "text" name = "Age" value = "<?php echo $row['DealerName']; ?>">
  33. <tr><td>Address<td><input type = "text" name = "Sex" value = "<?php echo $row['Street']; ?>"></tr>
  34. </table><br>
  35. ItemNo<input type = "text" name = "ItemNo">
  36. <input type = "submit" name = "submit2" value = "search2">
  37. <?php
  38. }
  39. }
  40. }
  41. }
  42. if(isset($_POST['submit2']))
  43. {
  44. $name1 = $_POST['ItemNo'];
  45. if($name1 != "")
  46. {
  47. mysql_connect("localhost", "root", "");
  48. mysql_select_db("rajesh");
  49. $sql1 = "select * from itemlist where ItemNO  like '%".mysql_real_escape_string($name1)."%'";
  50. $result1 = mysql_query($sql1);
  51. $numRows1 = mysql_num_rows($result1);
  52. if(empty($numRows1))
  53. {
  54.     echo "Record are not exits";
  55. }
  56. else{
  57. while($row1 = mysql_fetch_array($result1))
  58. {
  59. ?>
  60. <table>
  61. <tr><td>Item No<td><input type = "text" name = "ItemNo" value = "<?php echo $row1['ItemNo']; ?>">
  62. <tr><td>Item Name<td><input type = "text" name = "ItemName" value = "<?php echo $row1['ItemName']; ?>">
  63. </table>
  64. <?php
  65. }
  66. }
  67. }
  68. }
  69. ?>
<html>
Jan 10 '13 #2
Rabbit
12,516 Expert Mod 8TB
If you want to run both, don't check to see which button was clicked.
Jan 11 '13 #3
First of all thanks mr.rabbit for responding to my question i have given u code and wts the problem pls follow of my code and reply once again .actually i want 2 buttons results to be there in page.
Jan 12 '13 #4
Rabbit
12,516 Expert Mod 8TB
Yes, I know. I answered your question.
Jan 13 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: John Davis | last post by:
<html> <body> <Form action="calc.asp" method="post" name="calc"> <P>NUM1: <input type="text" name="num1"> <P>NUM2: <input type="text" name="num2"> <P>RESULT: <input type="text" name="result">...
1
by: Eric Caron | last post by:
Hi, In a typical "show-list-click-one-and-edit" scenario, I use a DataGrid on the "list" page using the pager option. Say I'm on page 2, click edit on an item and click Cancel on the edit page...
6
by: Tony Doyle | last post by:
All, I have a web form with 3 embedded panels, all working fine. However, I have now added a Checkbox where autopostback=true, and only the ascx pages on my page appear, none of the panels /...
1
by: glady | last post by:
Hi, I would like to have a php form that gets input from user and display data if they have already entered for that particular record in the same form. For example, if i have a form with 20...
6
by: nganapat | last post by:
I am trying to post form values to a https web page programmatically using Httpwebrequest but no matter what I do the same login page is returned instead of the next page. I would very much...
5
by: rlm51 | last post by:
Hey ... how is everyone ... I want to put a button on a page that does a "back to previous page" using a href="<?php $_SERVER ?>" /> attached to the button but it doesn't work. Do I have an...
3
by: wzb6 | last post by:
Hi, I am trying to post form values to a https web page programmatically using Httpwebrequest but no matter what I do the same login page is returned instead of the next page. I would very much...
3
by: sumit85424 | last post by:
Sir, i am working on a project and my issue is that when i log in a page of my application afer sometime when i click on any item session expires( i know that) but when again i log into it it...
1
by: A K C MOHAN | last post by:
I have 10 php pages, each page containing ten fields approximately. When I navigate from one page to another page like nextpage>>> & previouspage<<<. How can I store the field values using sessions...
1
by: korupolu | last post by:
I would like to display the details of all the Input fileds entered by user back in the same page. is it possible? if so, i would also like to alert user not to keep the field empty.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.