Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 5th, 2006, 6:33 AM   #11
ASHORY
Programmer
 
ASHORY's Avatar
 
Join Date: Dec 2004
Location: Egypt
Posts: 30
Rep Power: 0 ASHORY is on a distinguished road
Send a message via ICQ to ASHORY Send a message via MSN to ASHORY Send a message via Yahoo to ASHORY
i thinked about it i made a code but i dont know if it works or not
this code work is to see if the field is changed or not and if its changed update the changed field in the database , then echo's the changed fields in a new table without the non changed ones

here it is

[PHP]
<?
include ("connect.php") ;
$Con_Code="SELECT * From AddressBook";
$Con_Query=mysql_query($Con_Code);
$Con_Num=mysql_num_rows($Con_Query);
$i=0;
while ($i < $Con_Num){
$DB_Name=mysql_result($Con_Query,$i,"ID");
$DB_Name=mysql_result($Con_Query,$i,"Name");
$DB_City=mysql_result($Con_Query,$i,"City");
$Saved_City=$_GET['City'.$i] ;
if ($Saved_City=$DB_City){
$i++;
}
else{
echo '<h1 align=center>'."Saved Entries".'</h1>'.'<br>';
echo '<table border="2" width="100%" cellspacing="0" cellpadding="0" bordercolor="#000000">';
echo '<tr>';
echo '<td>';
echo "ID";
echo '</td>';
echo '<td>';
echo "Name" ;
echo '</td>';
echo '<td>';
echo "City" ;
echo '</td>';
echo '</tr>';
$Up_Code="UPDATE AddressBook SET City='".$Saved_City."' WHERE Name='".$DB_Name."'";
$Up_Query=mysql_query($Up_Code);
$DB_City2=mysql_result($Con_Num,$i,"City");
echo '<tr>';
echo '<td>';
echo $DB_ID;
echo '</td>';
echo '<td>';
echo $DB_Name;
echo '</td>';
echo '<td>';
echo $DB_City2;
echo '</td>';
echo '</tr>';
echo '</table>';
$i++;
}
}
?>
[/PHP]
__________________
"^Ahmed.SHOukRY^"
http://www.ashory.741.com
ASHORY is offline   Reply With Quote
Old Apr 5th, 2006, 8:14 AM   #12
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I may be misjudging things, but I don't think you understand the nature of the normal http interaction. It is not a continuous connection between the client and the server. It is not interactive, as is a phone call, but a request/response transaction, more like a radio. The client makes a request, the server responds. The request is usually for a resource like a page. The client, if it receives the resource, will render it.

Your code does not represent an instantaneous reaction where the HTML is client talk and the PHP is server talk. The entire thing is server preparation of a page. The server is forming a page description with the HTML. The PHP is operating things on the server, and may be actively generating some HTML. When the entire page is complete, at the end of your script, then it is sent to the client for rendering and limited action (in the absence of client-side script). The action may be field modification and submission of the form. That forms a NEW request. The server analyzes that request and responds appropriately, WITH A NEW PAGE.

I did not put update features on my example. The idea was to begin simply. To add update features, you would change the field on the form so that you could indicate to the server, via a form field (post information) or a query variable (get information) that you wished the contents of the form to represent an update to existing information. A good idea would be to include the PersonID in the form. If the PersonID existed in the DB, the information would be changed with an update command. If it did not exist, it would be added with an insert command. The DB would then be queried, a new page prepared (with the complete information), and sent to the client as a response.

I think you need to sit down and think about this, organize your approach, create your design, and code and test it.

Let me reemphasize that PHP code in the middle of HTML code does not represent an interaction with the client. It is strictly page preparation on the fly.

If I am mistaken in my guess, my apologies.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Apr 5th, 2006, 1:26 PM   #13
ASHORY
Programmer
 
ASHORY's Avatar
 
Join Date: Dec 2004
Location: Egypt
Posts: 30
Rep Power: 0 ASHORY is on a distinguished road
Send a message via ICQ to ASHORY Send a message via MSN to ASHORY Send a message via Yahoo to ASHORY
thanks very much dawie but if i needed to change a field value , what can i use - UPDATE or REPLACE ;
__________________
"^Ahmed.SHOukRY^"
http://www.ashory.741.com
ASHORY is offline   Reply With Quote
Old Apr 5th, 2006, 1:39 PM   #14
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
If I remember correctly, and often I don't, REPLACE requires a field name and the current contents of that field. It's possible you have two tables with the same field name. I recommend UPDATE, which requires a table name and a statement for each field name you wish to update. Quite seriously, you need to get a couple of good books or tutorial sites and read up. There are a number of good recommendations on the forum. You are working far to much in the dark.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC