PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 21st, 2002, 11:34 PM
chinni chinni is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 58 chinni User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
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:CrogrammeGDBDISD.GDB', $username, $password);

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&nbsp;&nbsp;&nbsp;

</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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

</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">

&nbsp;&nbsp;

<input type="reset" value="Reset">

</form>

<p class="hsnormal">&nbsp;</p>

<p class="hsnormal">&nbsp;</p>

<p class="hsnormal">&nbsp;</p>

<p class="hsnormal">&nbsp;</p>

<p class="hsnormal">&nbsp;</p>

<p class="hsnormal">&nbsp;</p>

<p class="hsnormal">&nbsp;</p>

<p class="hsnormal">&nbsp;</p>

</body>

</html>







Reply With Quote
  #2  
Old August 22nd, 2002, 12:24 AM
guyer guyer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Bloomington, IN USA
Posts: 47 guyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to guyer
RE: updating tables

so... what's your question?

Reply With Quote
  #3  
Old August 22nd, 2002, 01:12 AM
Gipz Gipz is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Stockholm, Sweden
Posts: 98 Gipz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to Gipz
RE: updating tables

Hi there!

Could you explain "OPTION FIELD"(mode) a lillte bit futher. Do you mean the options for the selectbox??

Reply With Quote
  #4  
Old August 22nd, 2002, 02:13 PM
chinni chinni is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 58 chinni User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
I Fixed it.*No mesg*

no mesg

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > updating tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek