Home  >  Article  >  Backend Development  >  tp 数据写入数据库问题

tp 数据写入数据库问题

WBOY
WBOYOriginal
2016-06-23 13:53:361035browse

我正在做留言板。。但是有两个数据就是一直搞不进数据库。。
 







请给个分数吧!

  • 20

  • value="40" name="user_comment_good">40

  • value="60" name="user_comment_good">60

  • value="80" name="user_comment_good">80

  • value="100" name="user_comment_good">100


  id="stars2-input" name="b" value="" size="2" name="user_comment_good">


<script></script> src="/App/Home/View/Index/review.js">




href="/App/Home/View/Index/review.css">
   
一个是form 后面的参数{$vo.univ_name} 我传到后面控制器之后怎么都保存不到数据库
还有一个就是上面的js  是星星判断分数的样式,我怎么才能把分数保存到数据库啊。。
我是新手一枚 完全没做过php的 。。。求助
控制器:
public function send_submit($id){
$User = M ( 'univ_user_remark' ); // 实例化模型
$this->user_name = $id;
if( $User->create ())// 获取post提交过来的表单(注意可能只是post可以)
{
 //展示数据库状况
$User->add ();

$this->assign('waitSecond',100);
$this->success("留言成功","/index.php/Home/Index/detail/id/$id");
}else
               {
                $this->error($User->getError());
                }
$this->display();

}


回复讨论(解决方案)

你给分的是链接不是表单元素,也没看到点击链接后的 js 处理代码

你给分的是链接不是表单元素,也没看到点击链接后的 js 处理代码


var Stars = function(cid, rid, hid, config) {		var lis = T$$(T$(cid), 'li'), curA;		for ( var i = 0, len = lis.length; i < len; i++) {			lis[i]._val = i;			lis[i].onclick = function() {				// 用户点击五角星时生成相应的分数				score = T$$(this, 'a')[0].getAttribute('value');				T$(rid).innerHTML = '<em>' + (T$(hid).value = score)						+ '分</em> - ' + config.info[this._val];				curA = T$$(T$(cid), 'a')[T$(hid).value / config.step - 1];				// ajax传递变量至php 保存到mysql				var xmlhttp;				if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome,					// Opera, Safari					xmlhttp = new XMLHttpRequest();				} else {// code for IE6, IE5					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");				}				// 执行数据库操作php脚本				// 注意此处url变量输入只能够使用?不能使用/				var url = "/App/Home/View/Index/review.php?score=" + score						+ "&univ_id=" + univ_id;				//alert(url);// 检验js传值是否成功				xmlhttp.open("GET", url, true);				xmlhttp.send();			};
这个是js部分的代码。。你说的表单那个 木有太懂。。。

你这段 js 只定义了 Stars 函数,但没执行
并且是 ajax 单独提交,与表单提交无关

你得把点击差生的值放到  中才能和表单一起提交

哪里控制的form的提交?

哪里控制的form的提交?



一个button  

你这段 js 只定义了 Stars 函数,但没执行
并且是 ajax 单独提交,与表单提交无关

你得把点击差生的值放到  中才能和表单一起提交



有点小复杂。。。我再研究研究。。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn