doudu22272099831 2014-10-13 05:48
浏览 16

jquery中的用户可调整大小的图像,并通过提交按钮保存新的维度到mysql供以后使用

I am calling an image with preset dimensions from a mysql database (this part works fine) and then providing the 'resizable' jquery library giving the user the ability to resize an image within a set area without having to press a submit button. The image resizes fine so everything is working there.

Unfortunately I cannot get the new dimensions to save to the database so on refresh the size goes back to the default size I have set, I have been searching for quite a while now on a solution and I am not too strong on ajax and jquery.

Can anyone help?

var startW = ('<?php echo "$w_pos";?>');
var startH = ('<?php echo "$h_pos";?>');

$(document).ready(function() {
$('.resizable').resizable({

start : function(event,ui) {
    startW = $(this).outerWidth();
    startH = $(this).outerHeight();
},
stop : function(event,ui) {
    endW = $(this).outerWidth();
    endH = $(this).outerHeight();
    alert("Width changed:"+ (startW + ' to ' + endW) + " and Height changed:" + (startH + ' to ' + endH));
    $.post('updatedimensions.php', { endW: 'endW', endH: 'endH' });
}
});
});

updatedimensions.php

if(isset($_POST['endW'])){$w_coord=$_POST['endW']}
if(isset($_POST['endH'])){$h_coord=$_POST['endH']}

//Setup Query
$sql = "UPDATE images SET h_pos = '$h_coord', w_pos = '$w_coord' where id = ".$id."";

//Execute Query
mysqli_query($link, $sql) or die("Error updating Coords :".mysqli_error());
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
    • ¥15 onvif+openssl,vs2022编译openssl64