doubiankang2845 2012-10-30 14:30
浏览 49

更新textarea上的mysql表模糊?

i am trying to make a text area update the information in a table in mysql when the user clicks out the text area. can someone guide me in the right direction please. This is what i have so far. im not getting any errors, but when i update it the changes arnt saving.

HTML CODE

    <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">

<textarea id="title" textarea name="title" rows="10" style="width: 456px; 
    margin-top:3px;
    text-align:left;
    margin-left:-2px;
    height: 120px;
    resize: none; 
    border: hidden;" data-id='$idbio'><?php echo $profile['bio'] ?> </textarea>
</form>

Javascript code

<script type="text/javascript">

$('textarea').on('blur',function () {
    var titleVal = $(this).val(), id = $(this).data('id');        

    $.ajax({
         type: "POST",
         url: "changebio.php",
         data: {title:titleVal , id:id},
         success: function(msg) {
             $('#'+id).html(msg);
         }
   })
});

</script>

changebio.php

 <?php
require_once("session.php"); 
require_once("functions.php");
require('_config/connection.php');
update_profilebio ();
header('Location: http://www.something.com/confirm.php');
?>

function.php

 function update_profilebio() {
            global $connection;
            global $profile_id;
            $query = "UPDATE ptb_profiles
                      SET bio='value'
                        WHERE ptb_profiles.user_id = \"$profile_id\"
                        AND ptb_profiles.user_id = ptb_users.id";
            $update_profilebio_set = mysql_query($query, $connection);
            confirm_query($update_profilebio_set);
            return $update_profilebio_set;

            }
  • 写回答

2条回答 默认 最新

  • dtt27783 2012-10-30 14:47
    关注

    Why are you using "on" method?? You could just do this: "$('textarea').blur(function(){...});", and i don't know what does the "data" method that you used here: "$(this).data('id')", when i want to get a id in my node i just to this: "$(this).attr('id');", and another thing, you get the string from textarea in the first time with the method "val()", and after that, you try to put a string with "html()", there is something wrong with that.

    评论

报告相同问题?

悬赏问题

  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上