customised the locked textboxes and save as new data

Reply

Join Date: Oct 2008
Posts: 2,429
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 437
adatapost's Avatar
adatapost adatapost is offline Offline
Nearly a Posting Maven

Re: customised the locked textboxes and save as new data

 
0
  #11
Jun 13th, 2009
Originally Posted by tulipputih View Post
ok..thanks.this is my code
  1. <?php
  2. $query= mysql_query(" SELECT * FROM lesson
  3. WHERE lessonID='" . $_GET['lessonID'] . "'");
  4.  
  5. while($entry=mysql_fetch_array($query))
  6. {
  7. echo " Subject: ";
  8. echo '<input name="subject" readonly="readonly" value="', $entry['subject'] , '" /><br />';
  9. echo " Year:";
  10. echo '<input name="year" readonly="readonly" value="', $entry['year'] , '" /><br />';
  11.  
  12.  
  13. }
  14.  
  15. ?>
Your code misses :

1. Form tag
2. Single quote never evaluates/expand variables.
3. No submit buttons.

Get a hint from the given code:

page1.php
  1. <?php
  2. $flag="disabled=\"disabled\"";
  3. $cmd=$_REQUEST["cmd"];
  4.  
  5. $query= mysql_query(" SELECT * FROM lesson
  6. WHERE lessonID='" . $_GET['lessonID'] . "'");
  7.  
  8. $no="";
  9. $name="";
  10. if($entry=mysql_fetch_array($query)) {
  11. $no=$entry[0]; $name=$entry[1];
  12. }
  13.  
  14. if(isset($cmd)) {
  15. if($cmd=="Edit")
  16. $flag="";
  17. else
  18. if($cmd=="Update") {
  19. ..... Write code to update a record.
  20. }
  21. }
  22. ?>
  23.  
  24. <form method="post" action="page1.php">
  25. No <input type="text"
  26. <?php echo $flag ?>
  27. name="no"
  28. value="<?php echo $no?>"
  29. />
  30. <br/>
  31. Name <input type="text"
  32. <?php echo $flag ?>
  33. name="name"
  34. value="<?php echo $name?>"
  35. />
  36.  
  37. <input type="submit" name="cmd" value="Edit"/>
  38. <input type="submit" name="cmd" value="Cancel"/>
  39. <input type="submit" name="cmd" <?php echo $flag ?> value="Update"/>
  40. </form>
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: customised the locked textboxes and save as new data

 
0
  #12
Jun 15th, 2009
Thanks Atli & Adatapost for your responses.

Adatapost,
What I intend to do is to insert a new record after customising the display data ( by click edit button).. so, I need to change "update" to "insert"..am I?

& how can the id be increased based on the highest id in the table?

thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,429
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 437
adatapost's Avatar
adatapost adatapost is offline Offline
Nearly a Posting Maven

Re: customised the locked textboxes and save as new data

 
0
  #13
Jun 15th, 2009
Originally Posted by tulipputih View Post
Thanks Atli & Adatapost for your responses.

Adatapost,
What I intend to do is to insert a new record after customising the display data ( by click edit button).. so, I need to change "update" to "insert"..am I?

& how can the id be increased based on the highest id in the table?

thanks
Add another submit button with value="Insert" and name="cmd". Compare value of $cmd and if it is "Insert" then write code to insert a record.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: customised the locked textboxes and save as new data

 
0
  #14
Jun 17th, 2009
hello all,
thanks for your input
& how can the id be increased based on the highest id in the table?
what I mean here is to enable an ID auto increment whenever we insert a new record to the table.
Do I have to query the maximum number in that table,
then ID++.
Is it correct? any proper syntax?
thanks
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 370
Reputation: Atli is an unknown quantity at this point 
Solved Threads: 46
Atli's Avatar
Atli Atli is offline Offline
Posting Whiz

Re: customised the locked textboxes and save as new data

 
0
  #15
Jun 17th, 2009
You can simply add the AUTO_INREMENT option to the column that is supposed to incremented, and leave it out of the INSERT query.
  1. CREATE TABLE test (
  2. `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  3. `value` VARCHAR(255) NOT NULL,
  4. PRIMARY KEY(`id`);
  5. );
  6.  
  7. INSERT INTO test(`value`)
  8. VALUES ('First'), ('Second'), ('Third');
  9.  
  10. SELECT * FROM test;
  11. +----+--------+
  12. | id | value |
  13. +----+--------+
  14. | 1 | First |
  15. | 2 | SECOND |
  16. | 3 | Third |
  17. +----+--------+
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: customised the locked textboxes and save as new data

 
0
  #16
Jun 18th, 2009
owh..thanks
I did used AUTO incerement.
tq.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: customised the locked textboxes and save as new data

 
0
  #17
Jul 3rd, 2009
HI adatapost,
I am sorry for coming to this thread again
several questions to ask:

$flag="disabled=\"disabled\"";
to enable the textboxes after click edit, can we code like this ?
  1. $unflag="enabled=\"enabled\"";
I have tried this but it doesn't work.

when click the EDIT button, the value in textbox
remains..& can be editted.
currently the value is set to empty = $flag="";

thank you
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,429
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 437
adatapost's Avatar
adatapost adatapost is offline Offline
Nearly a Posting Maven

Re: customised the locked textboxes and save as new data

 
0
  #18
Jul 3rd, 2009
  1. $flag="";
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 370
Reputation: Atli is an unknown quantity at this point 
Solved Threads: 46
Atli's Avatar
Atli Atli is offline Offline
Posting Whiz

Re: customised the locked textboxes and save as new data

 
0
  #19
Jul 4th, 2009
There is no enabled attribute. There is no need for it.
If the tag isn't specifically marked as disabled, it will be enabled.
So to enable it, simply remove the disabled attribute, as adatapost demonstrated.
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: customised the locked textboxes and save as new data

 
0
  #20
Jul 4th, 2009
If the tag isn't specifically marked as disabled, it will be enabled.
So to enable it, simply remove the disabled attribute, as adatapost demonstrated
ic, ok..thanks
but I would like to retain the value that is currently displayed.
by using this
  1. $flag="";
the textbox is enable..it's correct..but the value inside is emptied.

thank you
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC