MySQLで表示され、追加・削除・変更ができない。
MySQLでPHPにデータを追加・削除・変更を作っていたのですが、
表示はどうにかしてできたのですが、
追加・削除・変更のボタンを押してもなにもかわりません。
何回も見たのですが、どこが間違えてるのかさっぱりです。
<?php
require_once("../mydb_ini.php");
$con_mydb = mysql_connect($MYDBSERVER, $MYDBUSER, $MYDBPASSWARD);
$selectmydb = mysql_select_db($MYDBNAME, $con_mydb);
$num=0;
$mydbsql = "select * from newsline";
$rst = mysql_query($mydbsql, $con_mydb);
$num = mysql_affected_rows();
$error = "";
$new_no = "";
$new_category = "";
$new_date = "";
$new_content = "";
$new_url_db = "";
$new_target = "";
$new_disabled = "";
if($_SERVER['REQUEST_METHOD']=="POST"){
if(isset($_POST["submit_add"])){
$new_no = htmlspecialchars($_POST["new_no"], ENT_QUOTES);
$new_category = htmlspecialchars($_POST["new_category"], ENT_QUOTES);
$new_date = htmlspecialchars($_POST["new_date"], ENT_QUOTES);
$new_content = htmlspecialchars($_POST["new_content"], ENT_QUOTES);
$new_url_db = htmlspecialchars($_POST["new_url_db"], ENT_QUOTES);
$new_target = htmlspecialchars($_POST["new_target"], ENT_QUOTES);
$new_disabled = htmlspecialchars($_POST["new_disabled"], ENT_QUOTES);
if($error==""){
$mydbsql = "INSERT INTO newsline VALUES($new_category', '$new_date', '$new_content', '$new_url_db', '$new_target', '$new_disabled')";
}
}
if(isset($_POST["submit_upd"])){
$no = key($_POST[submit_upd]);
$category = htmlspecialchars($_POST["category"][$no], ENT_QUOTES);
$date = htmlspecialchars($_POST["date"][$no], ENT_QUOTES);
$content = htmlspecialchars($_POST["content"][$no], ENT_QUOTES);
$url_db = htmlspecialchars($_POST["url_db"][$no], ENT_QUOTES);
$target = htmlspecialchars($_POST["target"][$no], ENT_QUOTES);
$disabled = htmlspecialchars($_POST["disabled"][$no], ENT_QUOTES);
if($error==""){
$mydbsql = "UPDATE newsline SET category='$category', date='$date', content='$content', url_db='$url_db', target='$target', disabled='$disabled' WHERE no=$no";
}
}
if(isset($_POST["submit_del"])){
$no = key($_POST[submit_del]);
$mydbsql = "DELETE FROM newsline WHERE no=$no";
}
if($error==""){
$mydbsql;
$new_no = "";
$new_category = "";
$new_date = "";
$new_content = "";
$new_url_db = "";
$new_target = "";
$new_disabled = "";
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>無題ドキュメント</title>
</head>
<body>
<?=$error ?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<?php
$mydbsql = "select * from newsline";
while($mydb = mysql_fetch_array($rst)){
$no = $mydb["no"];
$category = $mydb["category"];
$date = $mydb["date"];
$content = $mydb["content"];
$url_db = $mydb["url_db"];
$target = $mydb["target"];
$disabled = $mydb["disabled"];
mb_convert_variables('UTF-8', 'EUC-JP', $category);
mb_convert_variables('UTF-8', 'EUC-JP', $content);
echo <<<EOT
$no:
$new_no:
<input type="text" name="category[$no]" value="$category">
<input type="text" name="date[$no]" value="$date">
<input type="text" name="content[$no]" value="$content">
<input type="text" name="url_db[$no]" value="$url_db">
<input type="text" name="target[$no]" value="$target">
<input type="text" name="disabled[$no]" value="$disabled">
<input type="submit" name="submit_upd[$no]" value="変更">
<input type="submit" name="submit_del[$no]" value="削除">
<br>
EOT;
}
?>
<br>
<input type="text" name="new_category" value="<?=$new_category ?>">
<input type="text" name="new_date" value="<?=$new_date ?>">
<input type="text" name="new_content" value="<?=$new_category ?>">
<input type="text" name="new_url_db" value="<?=$new_url_db ?>">
<input type="text" name="new_target" value="<?=$new_target ?>">
<input type="text" name="new_disabled" value="<?=$new_disabled ?>">
<input type="submit" name="submit_add" value="追加">
</form>
<br>
<?php
if($mydbsql>""){
echo "発行した:<br>$mydbsql";
}
?>
</body>
</html>
補足
そのやり方では、Opera10では動きませんよ。