Home

Forums

Web development

 

 

 

 
     
 
dna88 Web development and Technology Forum
 
Profile   Register   Memberlist   Usergroups   FAQ   Search  Log in
pass an arrray from one page to another

 
Post new topic   Reply to topic    dna88 Forum Index -> Web scripting language Discussion Forum
Author Message
tanveer
User
User


Joined: 21 Jun 2004
Posts: 85
Location: Dhaka,Bangladesh

Post Post subject: pass an arrray from one page to another Reply with quote

Dear all,
Need some help with php. I have a search form (search.php) where users can enter company name and after submitting, it shows result based on that client. Now in that result page which is (edit.php) there is also a button where after clicking edit that same result will come in edit mode in textboxes. Now when user edits the results of that page how to put them in another page and run an update query.

Here is my php code for <edit.php> where I gave the result in edit mode to users:
Code:


<?PHP
$client_name=$_GET['cname'];
$query="SELECT * FROM lease_proposal WHERE Company LIKE '%$client_name%'";
$result=mysql_query($query);
$rows=mysql_num_rows($result);

$num_fields=mysql_num_fields($result);
         echo
                    ' <tr bgcolor="#CCCCCC">
                     <td align="center">Company </td>
                     <td align="center">Factory </td>
           <td align="center">Relation </div></td>
           <td align="center">Equipment Description </td>
                     <td align="center">Equipment Location </td>
           <td align="center">Acquisition Method </td>
      </tr>';
     while($row=mysql_fetch_row($result)){
                echo "<tr>"; 
        for ($r=0;$r<$num_fields;$r++)
           {       
              echo '<td width="600" align="center">';
?>
         <input type="text" name="company[<?php echo [$r] ?>]" value="<?php echo $row[$r] ?>">

<?php

              echo "</td>";
} // end for loop
            echo "</tr>";
         } // end while loop
?>


Is there any other way cause I used that textbox outside php tags. Hope I made myself clear.
Thanks in advance.

Best regards
-Tanveer
Mon Dec 26, 05 11:20 pm
Back to top
tanveer View user's profile Send private message
tanveer
User
User


Joined: 21 Jun 2004
Posts: 85
Location: Dhaka,Bangladesh

Post Post subject: Reply with quote

At last I solved this problem like this:

Edit.php: This file is used to give the search result in edit mode
Code:

<form name="commit" action="value.php?client=<?=$_GET['cname']?>" method="post"> 
           <table width="571" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="20"><img src="../images/ltop.gif" width="20" height="17"></td>
                  <td width="531"><img src="../images/tmiddle.jpg" width="529" height="17"></td>
                  <td width="26"><img src="../images/b4000000.gif" width="20" height="17"></td>
                </tr>
                <tr>
                  <td background="images/2.gif"><img src="../images/2.gif" width="20" height="367"></td>
                  <td valign="top">
             
             
               
 <p align="center" class="style31">&nbsp;

<?php
     include('../dbconnect.php');
   
   
     $client_name=$_GET['cname'];

     $query="SELECT * FROM lease_proposal WHERE Company LIKE '%$client_name%'";
     $result=mysql_query($query);
      $rows=mysql_num_rows($result);

      $num_fields=mysql_num_fields($result);
      echo '<table cellpadding="0" cellspacing="2" style="border:1px solid; border-color:#003040;font-size: 7pt; font-family: Arial;" width="100%" id="AutoNumber8">';
                   
   while($row=mysql_fetch_row($result))
     {
     
       for($r=0;$r<$num_fields;$r++)
            { 
              echo '<tr><td width="20%" align="left" bgcolor="#F1F1DE">
                   <font face="century gothic" size="2"><b>'  .mysql_field_name($result,$r). ' </b></font></td>';
              echo '<td width="80%" align="left"><font face="arial" size="2">';

?>
             <input name="hold[<?php $r ?>]" type="text" style="border:1px solid #332343" value="<?php echo $row[$r];?>" size="35">
          

<?php
          
              echo "</font></td>";
              echo "</tr>";
            }
    }
          
              echo "</table>";

 ?> 


Value.php: This is the file which catches the array values
Code:

<?php

include('../dbconnect.php');
     

    $query="UPDATE lease_proposal SET  Company='$hold[0]',Factory='$hold[1]',Relation='$hold[2]',Description='$hold[3]',Location='$hold[4]',acq_method='$hold[5]'
     WHERE Company LIKE '%$_GET[client]%'";
      
    $result=mysql_query($query);
                 $rows=@mysql_num_rows($result);
           
       echo "<center> Client Information Updated Successfully </center> ";
       echo "<br><center> <a href='report.php'>Report Page </a>";
      
   
?>


BR
-Tanveer
Fri Dec 30, 05 11:36 pm
Back to top
tanveer View user's profile Send private message
quantum
Site Admin
Site Admin


Joined: 07 Mar 2004
Posts: 1048
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

Thanks for posting the solution.
_________________

Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.
Sat Dec 31, 05 10:46 pm
Back to top
quantum View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    dna88 Forum Index -> Web scripting language Discussion Forum All times are GMT - 7 Hours
Page 1 of 1

 

Partners and Resources

Bangladesh hosting company

Bangladesh web design

Driven by phpBB © phpBB Group