とりあえずの備忘録

主にパソコンやインターネットに関するメモ

PHP osCommerceの機能を使いMySQLを操作する UPDATE、DELETE文

準備についてはこちら。

テーブルのデータを更新する

<?php
//必要なファイルの読み込み
require('configure.php');
require('database.php');

//DB接続
tep_db_connect() or die('Unable to connect to database server!');

//SQL文
$sql = "update products" .
     " set products_name = 'ほげほげEX', products_price = '2700'" .
     " where products_id = '245'";

//UPDATE実行
tep_db_query($sql);

//DB切断
tep_db_close();
?>

テーブルのデータを削除する

<?php
//必要なファイルの読み込み
require('configure.php');
require('database.php');

//DB接続
tep_db_connect() or die('Unable to connect to database server!');

//SQL文
$sql = "delete from products where products_id = '245'";

//DELETE実行
tep_db_query($sql);

//DB切断
tep_db_close();
?>