Page 1 of 1

Edit Update Html Table geneated by mysql_fetch_array

Posted: Tue Jul 01, 2008 4:01 am
by gbdorilag
Hi everyone...!

PHP newbie here... I'm stcuk for 2 days please help...

ive created a code that displays mysql query result to html table by mysql_fetch_array... the table has 4 textfield where it will be inputed by the user.. here's the code.

Code: Select all

 
$searchqry = "SELECT tblchkord.BatchNum, businessunits.UnitName, tblchkord.BRSTN, tblchkord.SOLID, tblchkord.AccNum, tblchkord.AccName, tblchkord.ChkType, tblchkord.ChkSr, tblchkord.NPadOrd,  date_format(tblchkord.ChkDelDate,'%m/%d/%y'), tblchkord.NPadRcCPS,  tblchkord.ChkRcCPSDateTime,tblchkord.NPadRcBr, tblchkord.ChkRcBrDateTime,   tblchkord.ChkOrddate, tblchkord.LastUpdatedBy,    tblchkord.LastUpdatedDatetime, tblchkord.PymtProcess, tblchkord.ChkOrdNum,      tblchkord.VenCode
             FROM tblchkord LEFT OUTER JOIN businessunits ON tblchkord.SOLID = businessunits.SOLID                          
            
$search = mysql_query($searchqry)or die(mysql_error());
 
<form name='frmresult' method='post' action=''>
        <table class='adminlist' width='100%'>
            <tr height='51px'>
                <th width='4%' class='title2'>Pads Rec'd</th>
                <th width='6%' class='title2'>Rec'd Date (mm/dd/yy)</th>
                <th width='1%'> </th>
                <th width='4%' class='title2'>Pads Rec'd</th>
                <th width='7%' class='title2'>Rec'd Date (mm/ss/yy)</th>
                <th width='1%'> </th>
                <th width='4%' class='title2'>Pads Ord'd</th>
                <th width='7%' class='title2'>Printer Delivery Date</th>
                <th width='8%' class='title2'>Batch File No.</th>
                <th width='10%' class='title2'>Branch</th>
                <th width='6%' class='title2'>BRSTN</th>
                <th width='4%' class='title2'>Br. SOL</th>
                <th width='8%' class='title2'>Account No.</th>
                <th width='13%' class='title2'>Account Name</th>
                <th width='4%' class='title2'>Chk Typ</th>
                <th width='8%' class='title2'>Check Series</th>
                <th width='1%'> </th>
                <th width='4%' class='title2'>Pmnt Prcs</th>                        
          </tr> 
 
<?php 
$g = 1;     
$maxrow = mysql_num_rows($search);  
while($row = mysql_fetch_array($search))  
{ 
    echo "  
<tr class='row0' height='51px'>
                <td align='center'><input type='text' name='padscps".$g."' size='1' class='text_area' style='text-align: center' 
                                   id='padscps".$g."' onChange='return ValidateNPadsCPS".$g."()' 
                                   onkeydown='NavNPadsCPS".$g."()' value='".$row[12]."' maxlength='3'/></td>
                <td align='center'><input type='text' name='datecps".$g."' size='8' class='text_area' style='text-align: center' 
                                    id='datecps".$g."' onChange='return ValidateDateCPS".$g."()' 
                                    onkeydown='NavDateCPS".$g."()' value='".$row[13]."'/></td>
                <td </td>
                <td align='center'><input type='text' name='padsbr".$g."' size='1' class='text_area' style='text-align: center' 
                                    id='padsbr".$g."' onChange='return ValidateNPadsBr".$g."()'value='".$row[10]."'maxlength='3'
                                    onkeydown='NavNPadsBr".$g."()' onfocus='return ValidateDateCPS".$g."'/></td>
                                    
                <td align='center'><input type='text' name='datebr".$g."' size='8' class='text_area' style='text-align: center' 
                                    onkeydown='NavDateBr".$g."()' id='datebr".$g."'  onChange='return ValidateDateBr".$g."()' 
                                    value='".$row[11]."'/></td>
                <td </td>
                <td align='center'>".$row[8]."</td>
                <td align='center'>".$row[9]."</td>
                <td align='center'>".$row[0]."</td>
                <td>".$row[1]."</td>
                <td align='center'>".$row[2]."</td>
                <td align='center'>".$row[3]."</td>
                <td>".$row[4]."</td>
                <td>".$row[5]."</td>
                <td align='center'>".$row[6]."</td>
                <td>".$row[7]."</td> 
                <td align='center'><input type='hidden' name='ordnum".$g."' size='8' class='text_area' style='text-align: center' 
                                    id='ordnum".$g."'  value='".$row[18]. "' visible='false' readonly='true' /></td>
                <td align='center'><input type='checkbox' id='pymt".$g."' name='pymt".$g."' disabled='disabled' value='1'";
                    if ($row[17] == 1)
                        {echo "checked/></td>";}
                    else {echo "/></td>";}                                  
            echo "</tr>";
 
            $g++;           
                }           
        ?>
       
        </table>
     </form>    
  </tr>
 </table>
 
 
</div>
</body>
</html>
 
and displays this:

Image


Here's where im stuck..
when the user press UPDATE, after filling the textfields, i want it also to update in the mysql database and dispalays the same page with just update message on top of page..

i dont know how to post the cell values to next page cause it cell(td) will have a many unique names (cause of mysql_fetch_array - i dynamically name each text field generated).
and i have to POST all of them to another variable.. please help...

tnx!