|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
updating tables
Hello
I'm trying to update fields of my table and then displaying them.I'm done with all my form fields except with "OPTION FIELD"(mode).I dont know why.I would be really thankful to somebody if can point out where i did wrong. here is my code: <html> <body bgColor="lightblue"> <?php /*-- testing database connection database type: Interbase --*/ $username = "SYSDBA"; $password = "masterkey"; $connection = @ibase_connect('localhost:C if (!$connection) { exit ("Unable to connect to database: $connection"); } if ($HTTP_POST_VARS){ /*-- the form was submitted, lets process it --*/ /*-- get a count of how many ids we have to process --*/ $cnt = count($HTTP_POST_VARS['id']); /*-- cycle through the arrays and update the database table --*/ for($cntr=0;$cntr<$cnt;$cntr++) { if (!$HTTP_POST_VARS['is_enrolled'][$cntr]) $is_enrolled=0; else $is_enrolled=1; if (!$HTTP_POST_VARS['attach'][$cntr]) $attach=0; else $attach=1; if (!$HTTP_POST_VARS['detach'][$cntr]) $detach=0; else $detach=1; $sql = "UPDATE TBL_HANDSET SET ". "HS_IPUI = '{$HTTP_POST_VARS['ipui'][$cntr]}', ". "HS_TEI = '{$HTTP_POST_VARS['tei'][$cntr]}', ". "HS_ISENROLLED = $is_enrolled, ". "HS_ATTACH = '$attach', ". "HS_DETACH = '$detach', ". "HS_MODE = '{$HTTP_POST_VARS['mode'][$cntr]}', ". "HS_IPUICLASSB0 = '{$HTTP_POST_VARS['ipui_classb'][$cntr]}', ". "HS_IPUICLASSB1 = '{$HTTP_POST_VARS['ipui_classb1'][$cntr]}', ". "HS_UAK = '{$HTTP_POST_VARS['uak'][$cntr]}', ". "HS_LAL = '{$HTTP_POST_VARS['lal'][$cntr]}', ". "HS_AC = '{$HTTP_POST_VARS['ac'][$cntr]}' ". "where HS_ID = {$HTTP_POST_VARS['id'][$cntr]}"; $update_results = ibase_query($sql); if (!$update_results) { /* the query failed*/ echo "Error executing the update statement. <br />Interbase Reported:".ibase_errmsg()." <br/>". "SQL=$update_sql<br />n"; } } } /*-- this section is always shown --*/ /*-- get all records from the table --*/ $select_sql = 'Select HS_ID, HS_DETACH, HS_MODE, '. 'HS_ATTACH, HS_ISENROLLED, HS_IPUI, HS_TEI, HS_AC, HS_IPUICLASSB0, '. 'HS_IPUICLASSB1, HS_UAK, HS_LAL from TBL_HANDSET'; $result_id = ibase_query($select_sql) or die('Error retrieving records from TBL_HANDSET.<br />Interbase Reported: '.ibase_errmsg()); ?> <p class="rbsnormalbold"><b>Edit Handset</b></p> <hr style="line-height:100%; margin-top:0px; margin-bottom:0px;"> <form name="edit handset" action="<?=$HTTP_SERVER_VARS['PHP_SELF']?>" method="POST"> <table cellpadding="0" cellspacing="0" width="909" class="hsnormal"> <tr style="margin:0; padding:0;" align="left" valign="top" class="hsnormal"> <td width="154"> IPUI </td> <td width="154"> TEI </td> <td width="65"> Is Enrolled </td> <td width="65"> Attach </td> <td width="155"> Detach </td> <td width="96"> Mode </td> <td width="156"> IPUI Classb </td> <td width="156"> IPUI Classb1 </td> <td width="147"> UAK </td> <td width="96"> LAL </td> <td width="96"> AC </td> </tr> <?php $counter=0; $old_values=null; while ($row = ibase_fetch_object($result_id)) { $isenrolled=$row->HS_ISENROLLED; $attach=$row->HS_ATTACH; $detach=$row->HS_DETACH; $mode=$row->HS_MODE; $ipui=$row->HS_IPUI; $tei=$row->HS_TEI; $ac=$row->HS_AC; $ipuiclassb=$row->HS_IPUICLASSB0; $ipuiclassb1=$row->HS_IPUICLASSB1; $uak=$row->HS_UAK; $lal=$row->HS_LAL; /*-- output this row in the table --*/ ?> <tr style="margin:0; padding:0;" align="left" valign="top" class="hsnormal"> <td width="156" height="23"> <input type="text" name="ipui[<?=$counter?>]" value="<?=$ipui?>"> </td> <td width="154" height="23"> <input type="text" name="tei[<?=$counter?>]" value="<?=$tei?>"> </td> <td width="69" height="23"> <input type="checkbox" name="is_enrolled[<?=$counter?>]" value="1"<? if ($isenrolled==1)echo "checked";?>> </td> <td width="69" height="23"> <input type="checkbox" name="attach[<?=$counter?>]" value="1"<? if ($attach==1)echo "checked";?>> </td> <td width="65" height="23"> <input type="checkbox" name="detach[<?=$counter?>]" value="1" <? if ($detach==1)echo "checked";?>> </td> <td width="155" height="23"> <select size = 1 name="mode[<?=$counter?>]"> <option value="0"> <?php if($mode==0){ echo 'selected'; }?>>stimulus</option> <option value="0"> <?php if($mode==1){ echo 'selected'; }?>>GAP</option> </select> </td> <td width="155" height="23"> <input type="text" name="ipui_classb[<?=$counter?>]" value="<?=$ipuiclassb?>"> </td> <td width="156" height="23"> <input type="text" name="ipui_classb1[<?=$counter?>]" value="<?=$ipuiclassb1?>"> </td> <td width="156" height="23" align="left" valign="top"> <input type="text" name="uak[<?=$counter?>]" value="<?=$uak?>"> </td> <td width="156" height="23" align="left" valign="top"> <input type="text" name="lal[<?=$counter?>]" value="<?=$lal?>"> </td> <td width="156" height="23" align="left" valign="top"> <input type="text" name="ac[<?=$counter?>]" value="<?=$ac?>"> </td> </tr> <?php $old_values.=' <input type="hidden" name="id['.$counter.']" value="'.$row->HS_ID.'"> '; $counter++; } ?> </table> <?=$old_values?> <input type="submit" name="submit" value="Update"> <input type="reset" value="Reset"> </form> <p class="hsnormal"> </p> <p class="hsnormal"> </p> <p class="hsnormal"> </p> <p class="hsnormal"> </p> <p class="hsnormal"> </p> <p class="hsnormal"> </p> <p class="hsnormal"> </p> <p class="hsnormal"> </p> </body> </html> |
|
#2
|
|||
|
|||
|
RE: updating tables
so... what's your question?
|
|
#3
|
|||
|
|||
|
RE: updating tables
Hi there!
Could you explain "OPTION FIELD"(mode) a lillte bit futher. Do you mean the options for the selectbox?? |
|
#4
|
|||
|
|||
|
I Fixed it.*No mesg*
no mesg
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > updating tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|