Re: [PHP] insert to DB
pls could you point out which instruction should insert record in db thanks... 2005/12/18, Anasta [EMAIL PROTECTED]: It just wont insert new data into DB--any ideas as i have gone over and over. ? mysql_connect(localhost,anasta,silteren); mysql_select_db(mytipperv1); if(!isset($cmd)) { $result = mysql_query(select * from leaderboard order by ID); while($r=mysql_fetch_array($result)) { //grab the title and the rating of the entry $id=$r[ID];//take out the id $Name=$r[Name];//take out the Name $Rating=$r[Rating];//take out the Rating echo $Name a href='edit.php?cmd=editID=$id' Edit/abr; } } ? ? if($_GET[cmd]==edit || $_POST[cmd]==edit) { if (!isset($_POST[submit])) { $id = $_GET[ID]; $sql = SELECT * FROM leaderboard WHERE ID=$id; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ? form action=../craigs_DB/edit.php method=post input type=hidden name=ID value=?php echo $myrow[ID] ? Name: INPUT TYPE=TEXT NAME=Name VALUE=?php echo $myrow[Name] ? SIZE=15 maxlength=15brbr Rating: INPUT TYPE=TEXT NAME=Rating VALUE=?php echo $myrow[Rating] ? SIZE=3 maxlength=3brbr input type=hidden name=cmd value=edit input type=submit name=submit value=submit /form ? } ? ? if ($_POST[$submit]) { $Name = $_POST[Name]; $Rating = $_POST[Rating]; $sql = UPDATE leaderboard SET Name='$Name', Rating='$Rating' WHERE ID=$id; //replace news with your table name above $result = mysql_query($sql); echo Thank you! Information updated.; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] insert to DB
It just wont insert new data into DB--any ideas as i have gone over and over. ? mysql_connect(localhost,anasta,silteren); mysql_select_db(mytipperv1); if(!isset($cmd)) { $result = mysql_query(select * from leaderboard order by ID); while($r=mysql_fetch_array($result)) { //grab the title and the rating of the entry $id=$r[ID];//take out the id $Name=$r[Name];//take out the Name $Rating=$r[Rating];//take out the Rating echo $Name a href='edit.php?cmd=editID=$id' Edit/abr; } } ? ? if($_GET[cmd]==edit || $_POST[cmd]==edit) { if (!isset($_POST[submit])) { $id = $_GET[ID]; $sql = SELECT * FROM leaderboard WHERE ID=$id; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ? form action=../craigs_DB/edit.php method=post input type=hidden name=ID value=?php echo $myrow[ID] ? Name: INPUT TYPE=TEXT NAME=Name VALUE=?php echo $myrow[Name] ? SIZE=15 maxlength=15brbr Rating: INPUT TYPE=TEXT NAME=Rating VALUE=?php echo $myrow[Rating] ? SIZE=3 maxlength=3brbr input type=hidden name=cmd value=edit input type=submit name=submit value=submit /form ? } ? ? if ($_POST[$submit]) { $Name = $_POST[Name]; $Rating = $_POST[Rating]; $sql = UPDATE leaderboard SET Name='$Name', Rating='$Rating' WHERE ID=$id; //replace news with your table name above $result = mysql_query($sql); echo Thank you! Information updated.; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] insert to DB
On Sun, 2005-12-18 at 07:41, Anasta wrote: It just wont insert new data into DB--any ideas as i have gone over and over. Your not doing any inserts, two selects and one update... insert in t1 values('foo','bar','1 1 2 3 5 8 13'); -- s/:-[(/]/:-)/g BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC Key Info: http://gfx-design.com/keys Linux Registered User #339825 at http://counter.li.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] insert to DB
Hi, I think you should read a beginner tutorial about SQL. there are just four things Insert, Delete, Update and select, that need to be known for working with database in normal conditions, after that you can move to create, drop, alter or much more like joins etc. http://www.lmpx.com/mysql_ref.php Zareef Ahmed - Original Message - From: Anasta [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Sunday, December 18, 2005 7:41 AM Subject: [PHP] insert to DB It just wont insert new data into DB--any ideas as i have gone over and over. ? mysql_connect(localhost,anasta,silteren); mysql_select_db(mytipperv1); if(!isset($cmd)) { $result = mysql_query(select * from leaderboard order by ID); while($r=mysql_fetch_array($result)) { //grab the title and the rating of the entry $id=$r[ID];//take out the id $Name=$r[Name];//take out the Name $Rating=$r[Rating];//take out the Rating echo $Name a href='edit.php?cmd=editID=$id' Edit/abr; } } ? ? if($_GET[cmd]==edit || $_POST[cmd]==edit) { if (!isset($_POST[submit])) { $id = $_GET[ID]; $sql = SELECT * FROM leaderboard WHERE ID=$id; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ? form action=../craigs_DB/edit.php method=post input type=hidden name=ID value=?php echo $myrow[ID] ? Name: INPUT TYPE=TEXT NAME=Name VALUE=?php echo $myrow[Name] ? SIZE=15 maxlength=15brbr Rating: INPUT TYPE=TEXT NAME=Rating VALUE=?php echo $myrow[Rating] ? SIZE=3 maxlength=3brbr input type=hidden name=cmd value=edit input type=submit name=submit value=submit /form ? } ? ? if ($_POST[$submit]) { $Name = $_POST[Name]; $Rating = $_POST[Rating]; $sql = UPDATE leaderboard SET Name='$Name', Rating='$Rating' WHERE ID=$id; //replace news with your table name above $result = mysql_query($sql); echo Thank you! Information updated.; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php PHP Expert Consultancy in Development http://www.indiaphp.com Yahoo! : consultant_php MSN : [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php