我正在尝试制作像wordpress post-new.php
这样的内容,其中有一个系统调用类别,其中所有菜单类别都被保存,我的页面内部我刚刚构建,但我的问题是当我检查多个菜单选项发布然后它不起作用,但进入wordpress我只是看着有一个名为关系的TABLE有各种帖子附加类别和我发布时有一点从类别检查然后我看到post_id =(相同的数字)但是term_taxonomy_id =(不同的数字)和post_id多次相同但是term_taxonomy_id彼此不同,这就是为什么wordpress可以按类别分类,但我的编码不起作用,
这是我的代码和我的sql。
<?php
ob_start();
require('config2.php');
$dbcon = new MySQLi("mysql1.000webhost.com","a9042680_softbaz","asdfghjk99","a9042680_softbaz");
$save_draft = $_POST['save_draft'];
$preview = $_POST['preview'];
$cancel = $_POST['cancel'];
$publish = $_POST['publish'];
$post_title = mysql_real_escape_string($_POST['post_title']);
$post_body = mysql_real_escape_string($_POST['post_body']);
$oks = $_POST['post_body'];
// post_time
// Variable for hours
$hourdiff = "4"; // hours difference between server time and local time
// time is behind the server time
$timeadjust = ($hourdiff * 3600);
$post_time = date("l, d F Y h:i:s a",time() + $timeadjust);
$real_time = date("Y-m-d H:i:s",time() + $timeadjust);
//ip check
$http_client_ip = $_SERVER['HTTP_CLIENT_IP'];
$http_x_forwarded_for = $_SERVER['HTTP_X_FORWARDED_FOR'];
$remote_addr = $_SERVER['REMOTE_ADDR'];
if (!empty($http_client_ip)) {
$ip_address = $http_client_ip;
} else if (!empty($http_x_forwarded_for)) {
$ip_address = $http_x_forwarded_for;
} else {
$ip_address = $remote_addr;
}
//Menu checkbox function
$c_m_menu_id = $_POST['c_m_menu_id'];
$c_s_menu_id = $_POST['c_s_menu_id'];
$c_s_menu_id2 = $_POST['c_s_menu_id2'];
//save_draft function
if($save_draft) {
if($post_title&&$post_body&&$post_time) {
$insert=mysql_query("INSERT INTO post (post_title,post_body,post_time,real_time,ip_address,post_status) VALUES ('$post_title', '$post_body', '$post_time', '$real_time', '$ip_address', 'F')");
header("Location: test4.php");
}else{
header("Location: 000.php");
}
}
//preview function
if($preview){
$fp = fopen('preview.php' ,'w');
fwrite($fp, "<?php
error_reporting(E_ERROR | E_PARSE);
include 'opo.php';
?>
<?php
hera();
?>
$post_title;
$oks;
<?php
foot();
?>
");
echo "<script>window.open(\"http://localhost/myweb/dashbord/preview.php\", '_blank');</script>";
}
//cancel function
//publish function
if($publish) {
if($post_title&&$post_body&&$post_time) {
mysql_query("INSERT INTO post (post_title,post_body,post_time,real_time,ip_address,post_status) VALUES ('$post_title', '$post_body', '$post_time', '$real_time', '$ip_address', 'T')");
mysql_query("INSERT INTO relation (m_menu_id,s_menu_id,s_menu_id2) VALUES ('$c_m_menu_id', '$c_s_menu_id', '$c_s_menu_id2')");
header("Location: test4.php");
}else{
header("Location: 000.php");
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<!-- include jquery -->
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<!-- include libraries BS3 -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" />
<!-- Link Value -->
<script type="text/javascript">
$(document).ready(function() {
$('#myInputText').keyup(function() {
$('#myOutputText').val($(this).val().toLowerCase().replace(/ /g, '-'));
$('#myOutputText2').attr('placeholder',$(this).val());
$('#myOutputText3').val($(this).val().toLowerCase().replace(/ /g, ', '));
$('#myDIVTag').html('<b>' + $(this).val() + '<?php echo ' - '.$_SERVER['SERVER_NAME']; ?></b>');
});
});
$(document).ready(function() {
$('#myInputText2').keyup(function() {
$('#myOutputText4').val($(this).val());
});
});
</script>
<!-- include summernote -->
<link rel="stylesheet" href="dist/summernote.css">
<script type="text/javascript" src="dist/summernote.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.summernote').summernote({
height: 200,
tabsize: 2,
codemirror: {
theme: 'monokai'
}
});
});
</script>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<table width="100%" border="1" cellpadding="5" cellspacing="7">
<tr>
<td width="73%"><h2>Add New Post</h2>
<p>
<label>
<input id="myInputText" type="text" name="post_title" size="79" placeholder="Enter title here" />
</label>
</p>
<p> <?php echo $_SERVER['SERVER_NAME'].'/'; ?><input id="myOutputText" type="text" name="outputBox" /></p>
<p>
<label>
<textarea id="myInputText2" name="post_body" class="summernote"></textarea>
</label>
</p>
<p> </p></td>
<td width="27%" valign="top"><h2>Publish</h2>
<table width="178" cellpadding="2" cellspacing="2">
<tr>
<td width="101" height="33"><label>
<input type="submit" name="save_draft" value="Save Draft" />
</label></td>
<td width="65"><label>
<input type="submit" name="preview" value="Preview" />
</label></td>
</tr>
<tr>
<td><label>
<input type="submit" name="cancel" value="Cancel" />
</label></td>
<td><label>
<input type="submit" name="publish" value="Publish" />
</label></td>
</tr>
</table>
<h2>Featured Image</h2>
<label>
<input type="file" name="fileField2" id="fileField2" />
</label>
<p> </p>
<h2>Categories</h2>
<p>
<?php
$res=$dbcon->query("SELECT * FROM main_menu");
while($row=$res->fetch_array())
{
?>
<li><input type="checkbox" name="c_m_menu_id" value="<?php echo $row['m_menu_id']; ?>"><?php echo $row['m_menu_name']; ?> <!-- 1st -->
<?php
$res_pro=$dbcon->query("SELECT * FROM sub_menu WHERE m_menu_id=".$row['m_menu_id']);
?>
<ul>
<?php
while($pro_row=$res_pro->fetch_array())
{
?><li><input type="checkbox" name="c_s_menu_id" value="<?php echo $pro_row['s_menu_id']; ?>"><?php echo $pro_row['s_menu_name']; ?> <!-- 2nd -->
<?php
$res_pror=$dbcon->query("SELECT * FROM sube_menu WHERE s_menu_id=".$pro_row['s_menu_id']);
?>
<ul>
<?php
while($pro_rowe=$res_pror->fetch_array())
{ ?>
<li><input type="checkbox" name="c_s_menu_id2" value="<?php echo $pro_rowe['s_menu_id2']; ?>"><?php echo $pro_rowe['s_menu_name2']; ?></li> <!-- 3rd -->
<?php } ?>
</ul>
</li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
</p>
</td>
</tr>
<tr>
<td><h2>SEO Tools</h2>
<p>Snippet Preview: <a href="#" id="myDIVTag"></a></p>
<p>Focus Keyword:
<label>
<input name="post_seo_keyword" type="text" id="myOutputText3" size="79" />
</label>
</p>
<p>SEO Title:
<label>
<input name="post_seo_title" type="text" id="myOutputText2" size="79" />
</label>
</p>
<p>Meta description:
<label>
<textarea name="post_seo_description" id="myOutputText4" cols="80" rows="5"></textarea>
</label>
</p></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
SQL:
CREATE TABLE IF NOT EXISTS `relation` (
`posted_id` int(11) unsigned NOT NULL DEFAULT '0',
`m_menu_id` int(11) unsigned NOT NULL DEFAULT '0',
`s_menu_id` int(11) unsigned NOT NULL DEFAULT '0',
`s_menu_id2` int(11) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `relation`
--
INSERT INTO `relation` (`posted_id`, `m_menu_id`, `s_menu_id`, `s_menu_id2`) VALUES
(0, 0, 0, 0),
(0, 0, 0, 4),
(0, 0, 13, 4),
(0, 8, 0, 0),
(0, 8, 12, 2),
(0, 8, 13, 3),
(0, 8, 13, 4),
(0, 9, 13, 3),
(0, 9, 13, 4);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `relation`
--
ALTER TABLE `relation`
ADD PRIMARY KEY (`posted_id`,`m_menu_id`,`s_menu_id`,`s_menu_id2`);
请帮帮我,给我解决方案。这是我的测试测试网站,如果你想看到它我在哪里测试,请转到此链接:softbazz.net63.net/myweb/dashbord/test4.php