Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
php script
#15
(02-03-2010, 12:30 PM)Master of The Universe Wrote: It doesn't actually matter where you put it, but let's say you have created another field called, "record", and you have placed it in the database under the field "price"...

The query would look like this.

PHP Code:
$edit_id = (int) $_POST['id'];
    
$sql "UPDATE `coin_info` SET `date` = '{$_POST['date']}',";
    
$sql .= "`price` = '{$_POST['price']}', `record` = '{$_POST['record']}',`condition` = '{$_POST['condition']}',`year` = '{$_POST['year']}',";
    
$sql .= "`silver` = '{$_POST['silver']}',`gold` = '{$_POST['gold']}',`weight` = '{$_POST['weight']}' ";
    
$sql .= "WHERE `id` = '{$edit_id}' LIMIT 1 ;"

You will also need to add the input field in the HTML code, with the name "record"...

Code:
<input type="text" name="record" />

For you other problem, that's how PHP works, but you can change these lines;

PHP Code:
echo "Coin added!""<br />";
# and
echo "Edited {$edit_id}!""<br />";
# and
echo "Deleted ID "$id"<br />"

To this;
PHP Code:
header("Location: coin.php"); 

The will refresh your page, but note that the header function needs to be called before any output has been made, echo or print...
Other wise it will return an error.

please tell me what I'm doing wrong-

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`description` = 'description' WHERE `id` = '7' LIMIT 1' at line 1
Edit failed!

description is the new line I added.
Code:
$edit_id = (int) $_POST['id'];
    $sql = "UPDATE `coin_info` SET `date` = '{$_POST['date']}',";
    $sql .= "`price` = '{$_POST['price']}',`condition` = '{$_POST['condition']}',`year` = '{$_POST['year']}',";
    $sql .= "`silver` = '{$_POST['silver']}',`gold` = '{$_POST['gold']}',`weight` = '{$_POST['weight']}' ";
    $sql .="`description` = '{$_POST['description']}' ";
    $sql .= "WHERE `id` = '{$edit_id}' LIMIT 1 ;";
Reply


Messages In This Thread
php script - by andrewjs18 - 02-02-2010, 02:08 PM
RE: php script - by Gaijin - 02-02-2010, 02:10 PM
RE: php script - by andrewjs18 - 02-02-2010, 02:24 PM
RE: php script - by Gaijin - 02-02-2010, 02:30 PM
RE: php script - by andrewjs18 - 02-02-2010, 02:33 PM
RE: php script - by Gaijin - 02-02-2010, 05:36 PM
RE: php script - by andrewjs18 - 02-02-2010, 10:34 PM
RE: php script - by TheLifelessOne - 02-02-2010, 06:11 PM
RE: php script - by Gaijin - 02-02-2010, 06:14 PM
RE: php script - by Gaijin - 02-02-2010, 10:44 PM
RE: php script - by andrewjs18 - 02-02-2010, 10:51 PM
RE: php script - by Gaijin - 02-02-2010, 10:56 PM
RE: php script - by andrewjs18 - 02-03-2010, 10:18 AM
RE: php script - by Gaijin - 02-03-2010, 12:30 PM
RE: php script - by andrewjs18 - 02-03-2010, 11:35 PM
RE: php script - by Gaijin - 02-04-2010, 05:46 AM
RE: php script - by andrewjs18 - 02-04-2010, 01:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 954 07-27-2020, 11:26 PM
Last Post: tk-hassan
  Req. Upload PHP script. 3 X P L 0 I T 1 1,354 07-14-2012, 05:19 PM
Last Post: 'Snorlax
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,695 10-10-2011, 01:00 PM
Last Post: Greyersting
  optimize mysql through a php script andrewjs18 7 3,378 10-05-2011, 06:31 PM
Last Post: John.
  Creating a simple PHP/MySQL login script ndee 16 10,530 05-14-2011, 02:18 AM
Last Post: モrainee

Forum Jump:


Users browsing this thread: 4 Guest(s)