1,105,556 Community Members

Search frm input and edit the form

Member Avatar
subrata_ushasi
Junior Poster
115 posts since Aug 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi ,

I have a form having some text fileds and submit button. One more input box and submit button . If a value is entered in input box and button pressed then that will search data from database and displayed in text boxes ,is done . Now I want to edit data of the same displayed value which is not working .Here is the code :

<?php

$ansssa=$_POST['serno'];

$sql=("SELECT customer.customer_name, customer.dealer_name, customer.city, customer.country, customer.telephone, customer.customer_mail, reminder.reminder, reminder.expiry_date,reminder.permanent_license,reminder.limited_time_license,software_order.product_name, software_order.limit,software_order.serial_number
FROM customer
INNER JOIN reminder ON customer.serial_number = reminder.serial_number
INNER JOIN software_order ON customer.serial_number = software_order.serial_number
AND customer.serial_number ='$ansssa'");
            $qry = mysql_query($sql); 
            $rs = mysql_fetch_array($qry)
           ?>
   <table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="of border">
            <form name="licence" action="<?php $_SERVER['PHP_SELF']?>" method="post" >
              <tr>
                <td><h2>Manage SSA</h2></td>
              </tr>
              <tr>
                <td><table border="0" align="center">
                    <tr>
                      <td width="10px">&nbsp;</td>
                      <td>Input Serial number </td>
                      <td><input type="text" name="serno" id="serno" width="200" /></td>
                      <td width="10px">&nbsp;</td>
                      <td><input type="submit" name="search" id="search" value="Search Value" />
                        <input type="hidden" name="todo" id="todo" value="Search" />
                        <input type="hidden" name="id" value="<?php echo $rs['serial_number']; ?>"></td>
                      <td width="10px">&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                  </table></td>
              </tr>
              <tr>
                <td><table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr> </tr>
                    <tr> </tr>
                  </table></td>
              </tr>
              <tr>
                <td><h2>Customer</h2></td>
              </tr>
              <tr>
                <td><table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="190">Customer name </td>
                      <td width="10px">:</td>
                      <td><input type="text" name="txtcustomername" id="txtcustomername" class="textbox" value="<?php echo $rs['customer_name'];?>"/></td>
                    </tr>
                    <tr> </tr>
                    <tr>
                      <td>Dealer name </td>
                      <td>:</td>
                      <td><input type="text" name="txtdealername" id="txtdealername" class="textbox" value="<?php echo $rs['dealer_name'];?>"/></td>
                    </tr>
                    <tr>
                      <td>Customer's city </td>
                      <td>:</td>
                      <td><input type="text" name="txtcity" id="txtcity" class="textbox" value="<?php echo $rs['city'];?>"/></td>
                    </tr>
                    <tr>
                      <td>Country</td>
                      <td>:</td>
                      <td><input type="text" name="txtcountry" id="txtcountry" class="textbox" value="<?php echo $rs['country'];?>"/></td>
                    </tr>
                    <tr>
                      <td>Email for customer </td>
                      <td>;</td>
                      <td><input type="text" name="txtmail" id="txtmail" class="textbox" value="<?php echo $rs['customer_mail'];?>"/></td>
                    </tr>
                    <tr>
                      <td>Telephone</td>
                      <td>:</td>
                      <td><input type="text" name="txtphone" id="txtphone" class="textbox" value="<?php echo $rs['telephone'];?>"/></td>
                    </tr>
                  </table></td>
              </tr>
              <tr>
                <td><h2>Duration</h2></td>
              </tr>

              <tr>
                <td><h2>Software ordered</h2></td>
              </tr>
              <tr>
                <td><table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td>Serial number</td>
                      <td>:</td>
                      <td><input type="text" name="txtsernumber" id="txtsernumber" class="textbox" value="<?php echo $rs['serial_number'];?>"/></td>
                    </tr>


                    <tr> </tr>
                  </table></td>
              </tr>
              <tr> </tr>
              <tr> </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><table border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td><a href='<?php //$_SERVER['PHP_SELF']?>?cmd=edit&id=<?php //echo $rs['serial_number'];?>'>Edit</a></td>
                     <!-- <td><input type="submit" name="Submit" id="Submit" value="Submit" class="submitbg" style="width:125px;" /></td>-->
                      <td>&nbsp;</td>
                      <td><input type="hidden" name="todo" id="todo" value="Update"  /></td>
                      <td>&nbsp;</td>
                      <td><a href="licence.php" >Go to licence menu</a></td>
                    </tr>
                  </table></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
            </form>
          </table>
<?php
   }
 if($_REQUEST['cmd'])
   {
      $id=$_REQUEST['id'];
      $varcustomer = $_POST['txtcustomername'];
      $vardealername = $_REQUEST['txtdealername'];
      $varcity = $_REQUEST['txtcity'];
      $varcountry = $_REQUEST['txtcountry'];
      $varmail = $_REQUEST['txtmail'];
      $varphone = $_REQUEST['txtphone'];


      $sql = ("UPDATE customer SET                        
                              customer_name='$varcustomer',
                              dealer_name='$vardealername',
                              city ='$varcity',
                              country='$varcountry',
                              customer_mail='$varmail',
                              telephone='$varphone'
                              WHERE serial_number ='$id' ");

      $result = mysql_query($sql);
      echo "Thank you! Information updated.";
   }

   ?>
Member Avatar
cigoL..:)
Light Poster
47 posts since Jul 2011
Reputation Points: -1 [?]
Q&As Helped to Solve: 11 [?]
Skill Endorsements: 2 [?]
 
0
 

I'm sorry, i'm not sure if i understand your question. but where do you want to edit the value? on the textbox? where you store you're fetched values?

Member Avatar
subrata_ushasi
Junior Poster
115 posts since Aug 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks for your quick answer ,the problem is solved . After fetching the value ,to edit on the textbox and submit ,changed value on the textbox will be saved in database. What I did as follows :

Instead of 
if($_REQUEST['cmd']) 
 I did
if($_REQUEST['Submit']) and working.
Question Answered as of 1 Year Ago by cigoL..:)
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: