使用php将列表发布到数据库
我有一份清单:使用php将列表发布到数据库,php,database,list,post,Php,Database,List,Post,我有一份清单: <ul> <li>one</li> <li>two</li> </ul> 一个 两个 通常php使用表单将数据输入服务器,但我想将列表发布/发送到数据库。我应该怎么做?使用Jquery获取列表中的值并存储在js变量中。 发送一个ajax请求,将该js变量(列表值)作为参数包含在数据库中 或者将此值保存在中的隐藏字段中并提交该表单我会将列表项转换为变量。从那以后,我会做类似的事情。 这是
<ul>
<li>one</li>
<li>two</li>
</ul>
- 一个
- 两个
通常php使用表单将数据输入服务器,但我想将列表发布/发送到数据库。我应该怎么做?使用Jquery获取列表中的值并存储在js变量中。 发送一个ajax请求,将该js变量(列表值)作为参数包含在数据库中
或者将此值保存在中的隐藏字段中并提交该表单我会将列表项转换为变量。从那以后,我会做类似的事情。 这是如果您使用的是mysql。希望这有帮助
$one = "one";
$two = "two";
$SQLstring = "INSERT INTO tableName " .
"(columnOne,columnTwo)" .
"VALUES('$one', '$two')";
$QueryResult = @mysql_query($SQLstring, $DataBaseConnection);
希望这有帮助。您可以在列表中有一个隐藏的输入,然后在jquery上单击按钮时,您可以得到类似的内容
<li><input type="hidden" value="test" id="test">TEST</li>
<div id="content">
<div id="sub_cont"><!--leave blank this is for the contents of postpage.php after button submit--></div>
</div>
<script>
$(document).ready(function(){
$('#button').click(function() {
$('#sub_cont').fadeIn('fast');
$("#content #sub_cont").load("postpage.php?id="+ $("#test").val());
});
});
</script>
测试
$(文档).ready(函数(){
$(“#按钮”)。单击(函数(){
$('sub#u cont').fadeIn('fast');
$(“#content#sub#cont”).load(“postpage.php?id=“+$(“#test”).val());
});
});
关于postpage.php
$test = $_REQUEST['id'];
<div id="content">
<!--contents/result/etc/display test-->
</div>
$test=$\u请求['id'];
抱歉,代码太懒了。您可以在其他事件上进行实验。是否要将列表存储在数据库中?这不是列表,而是HTML。请提供您的问题的更多背景信息,以帮助其他人更好地理解。死锁:是的,实际上列表是动态列表而不是基本列表…杰克:是的,对不起,我是指HTML列表