| | |
customised the locked textboxes and save as new data
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
•
•
ok..thanks.this is my code
php Syntax (Toggle Plain Text)
<?php $query= mysql_query(" SELECT * FROM lesson WHERE lessonID='" . $_GET['lessonID'] . "'"); while($entry=mysql_fetch_array($query)) { echo " Subject: "; echo '<input name="subject" readonly="readonly" value="', $entry['subject'] , '" /><br />'; echo " Year:"; echo '<input name="year" readonly="readonly" value="', $entry['year'] , '" /><br />'; } ?>
1. Form tag
2. Single quote never evaluates/expand variables.
3. No submit buttons.
Get a hint from the given code:
page1.php
PHP Syntax (Toggle Plain Text)
<?php $flag="disabled=\"disabled\""; $cmd=$_REQUEST["cmd"]; $query= mysql_query(" SELECT * FROM lesson WHERE lessonID='" . $_GET['lessonID'] . "'"); $no=""; $name=""; if($entry=mysql_fetch_array($query)) { $no=$entry[0]; $name=$entry[1]; } if(isset($cmd)) { if($cmd=="Edit") $flag=""; else if($cmd=="Update") { ..... Write code to update a record. } } ?> <form method="post" action="page1.php"> No <input type="text" <?php echo $flag ?> name="no" value="<?php echo $no?>" /> <br/> Name <input type="text" <?php echo $flag ?> name="name" value="<?php echo $name?>" /> <input type="submit" name="cmd" value="Edit"/> <input type="submit" name="cmd" value="Cancel"/> <input type="submit" name="cmd" <?php echo $flag ?> value="Update"/> </form>
Failure is not fatal, but failure to change might be. - John Wooden
•
•
•
•
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
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: May 2009
Posts: 81
Reputation:
Solved Threads: 0
hello all,
thanks for your input
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
thanks for your input
•
•
•
•
& how can the id be increased based on the highest id in the table?
Do I have to query the maximum number in that table,
then ID++.
Is it correct? any proper syntax?
thanks
You can simply add the
AUTO_INREMENT option to the column that is supposed to incremented, and leave it out of the INSERT query. sql Syntax (Toggle Plain Text)
CREATE TABLE test ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `value` VARCHAR(255) NOT NULL, PRIMARY KEY(`id`); ); INSERT INTO test(`value`) VALUES ('First'), ('Second'), ('Third'); SELECT * FROM test; +----+--------+ | id | value | +----+--------+ | 1 | First | | 2 | SECOND | | 3 | Third | +----+--------+
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
And use [code] tags!
•
•
Join Date: May 2009
Posts: 81
Reputation:
Solved Threads: 0
HI adatapost,
I am sorry for coming to this thread again
several questions to ask:
to enable the textboxes after click edit, can we code like this ?
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
I am sorry for coming to this thread again
several questions to ask:
•
•
•
•
$flag="disabled=\"disabled\"";
php Syntax (Toggle Plain Text)
$unflag="enabled=\"enabled\"";
when click the EDIT button, the value in textbox
remains..& can be editted.
currently the value is set to empty = $flag="";
thank you
php Syntax (Toggle Plain Text)
$flag="";
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: May 2009
Posts: 81
Reputation:
Solved Threads: 0
•
•
•
•
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
but I would like to retain the value that is currently displayed.
by using this
php Syntax (Toggle Plain Text)
$flag="";
thank you
![]() |
Similar Threads
- Save data from DataGridView to XML (C#)
- Save data class (C++)
- cannot save data to access using vb.net2003 form (VB.NET)
- save data to access database (VB.NET)
- List View save data from it to mysql (VB.NET)
- Windows unable save data..failure of computer hardware or network conn. (Troubleshooting Dead Machines)
Other Threads in the PHP Forum
- Previous Thread: Warning: session_start() [function.session-start]: Cannot send session cache limiter
- Next Thread: auction script
| Thread Tools | Search this Thread |
301 access apache api array autocomplete beginner binary broken button cakephp checkbox class cms code compression cron curl data database dataentry date display dropdown dropdownlist duplicates dynamic echo email error execution file files folder form forms function functions google href htaccess html htmlspecialchars httppost image include insert integration ip javascript joomla jquery limit link links login mail md5 menu methods mlm multiple mysql oop paypal pdf pdfdownload php phpvotingscript query radio random recursion remote script search secure server session sessions source space sql subscription syntax system table tutorial tutorials update upload url validator variable video virus volume votedown web youtube






