把数值发送php 让php执行在数据库保存啊
第一个是未排序的 第二个是排序后获取数值的 怎么能把数值发送给数据库保存啊
<table class="result-tab" width="100%" cellspacing="0" > <tr align="center"> <td align="center"><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pid-编号-a"><a href="javascript://" onclick="sendRequest('pid');">编号</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pname-名-nbsp-称-a"><a href="javascript://" onclick="sendRequest('pname');">名 称</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-种-nbsp-类-a"><a href="javascript://" onclick="sendRequest('pID');">种 类</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-类-nbsp-别-a"><a href="javascript://" onclick="sendRequest('pID');">类 别</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-图-nbsp-片-a"><a href="javascript://" onclick="sendRequest('pID');">图 片</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-简-nbsp-介-a"><a href="javascript://" onclick="sendRequest('pID');">简 介</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-图-nbsp-示-a"><a href="javascript://" onclick="sendRequest('pID');">图 示</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-介-nbsp-绍-a"><a href="javascript://" onclick="sendRequest('pID');">介 绍</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-公-nbsp-司-a"><a href="javascript://" onclick="sendRequest('pID');">公 司</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-开-nbsp-始-a"><a href="javascript://" onclick="sendRequest('pID');">开 始</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-结-nbsp-束-a"><a href="javascript://" onclick="sendRequest('pID');">结 束</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-地-nbsp-址-a"><a href="javascript://" onclick="sendRequest('pID');">地 址</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-休-nbsp-息-a"><a href="javascript://" onclick="sendRequest('pID');">休 息</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-网-nbsp-址-a"><a href="javascript://" onclick="sendRequest('pID');">网 址</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-停-nbsp-止-a"><a href="javascript://" onclick="sendRequest('pID');">停 止</a></h2></td> <td><h2 id="操-nbsp-作">操 作</h2></td> <td><h2 id="排-nbsp-序">排 序</h2></td><td><h2><td><input type=button value=确认 id=bn></td></h2></td> </tr> {foreach from=$shop item=i} <tr align="center"> <td class='xh'>{$i["id"]}</td> <td>{$i["name"]}</td> <td>{$i["varietyid"]}</td> <td>{$i["classifyid"]}</td> <td>{$i["list_pic"]}</td> <td>{$i["introduction"]}</td> <td>{$i["show_pic"]}</td> <td>{$i["product_introduction"]}</td> <td>{$i["company"]}</td> <td>{$i["business_start"]}</td> <td>{$i["business_end"]}</td> <td>{$i["address"]}</td> <td>{$i["rest_flag"]}</td> <td>{$i["web"]}</td> <td>{$i["del_flag"]}</td> <td><a href="user_shop.php?id={$i["id"]}">修改</a> <a href="delete_shop.php?id={$i["id"]}">删除</a> </td> <td><a href="#" class="up">上移</a></td> <td><a href="#" class="down">下移</a></td> <td><a href="#" class="top">置顶</a></td> </tr> {/foreach} </table>
<script language="JavaScript" type="text/javascript">$(function(){ $('#bn').click(function() { var r = []; $('.xh').each(function(i, t) { r.push($(this).html()); }); alert(r); }); var $up = $(".up") $up.click(function() { var $tr = $(this).parents("tr"); if ($tr.index() != 0) { $tr.fadeOut().fadeIn(); $tr.prev().before($tr); } }); var $down = $(".down"); var len = $down.length; $down.click(function() { var $tr = $(this).parents("tr"); if ($tr.index() != len - 1) { $tr.fadeOut().fadeIn(); $tr.next().after($tr); } }); var $top = $(".top"); $top.click(function(){ var $tr = $(this).parents("tr"); $tr.fadeOut().fadeIn(); $(".table").prepend($tr); $tr.css("color","#f60"); });});</script>
回复讨论(解决方案)
先序列号表单,通过post 到php。php通过requst接收处理
先序列号表单,通过post 到php。php通过requst接收处理
您能给个代码么 我不会。。。新手刚学这个
你的 alert(r); 时已经得到了指定序列的数组 r
你只需将其传给 php 程序即可,比如
$.post(location.href, {px:r}); //location.href 表示当前页,其他目标你自己定
php 将收到
array(
'px' => array(1,3,5,2,4}
)
这样的数组
再怎么用就是你的事情了
先序列号表单,通过post 到php。php通过requst接收处理
不知道 您看见没有哈 我那个js文件 alert(r); 后面 是没有接收的页面的 每次添加接收的页面 都是报错 为什么啊
比如 我就在在下面 写: $.post("yidong.php", {xh:r },); 就报错
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "C:\wamp\www\xcx\user\templates\shop.tpl" on line 154 "$.post("yidong.php", {xh:"r" },);" - Unexpected ":", expected one of: "}"
你的 alert(r); 时已经得到了指定序列的数组 r
你只需将其传给 php 程序即可,比如
$.post(location.href, {px:r}); //location.href 表示当前页,其他目标你自己定
php 将收到
array(
'px' => array(1,3,5,2,4}
)
这样的数组
再怎么用就是你的事情了
谢谢 非常感谢您
你的 alert(r); 时已经得到了指定序列的数组 r
你只需将其传给 php 程序即可,比如
$.post(location.href, {px:r}); //location.href 表示当前页,其他目标你自己定
php 将收到
array(
'px' => array(1,3,5,2,4}
)
这样的数组
再怎么用就是你的事情了
那个px就是xh吧 但是在$.post执行的时候 第二个参数 是错误的 也就是{px:r} 是有错误的
错误代码:
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "C:\wamp\www\xcx\user\templates\shop.tpl" on line 154 "$.post("yidong.php",{xh :r},function(data){});" - Unexpected " :", expected one of: "}"
去掉{px:r} 依旧能获取数组 页面是没有变化的 为什么?
$('#bn').click(function() {
var r = [];
$('.xh').each(function(i, t) {
r.push($(this).html());
});
alert(r);
});
改为
$('#bn').click(function() {
var r = [];
$('.xh').each(function(i, t) {
r.push($(this).html());
});
$.post(‘server.php', {px:r}); // server.php 表示接受数据的php
});
然后 server.php 中加入
$data = isset($_POST['px'])? $_POST['px'] : array();
print_r($data); // 打印获取的数据
// 执行写入数据库的操作。
?>
这个需要你自己先搭建php + mysql 运行环境。以及需要了解php,mysql的语法。
搭建环境可以安装wamp2来实现。
你出那个错是因为你的js代码花括号与smarty的定界符冲突了,
可以把smarty的定界符改为{# #} ,或者
{literal}
<script> <br /> ........ <br /></script>
{/literal}
这样保护js不被smarty编译。
$('#bn').click(function() {
var r = [];
$('.xh').each(function(i, t) {
r.push($(this).html());
});
alert(r);
});
改为
$('#bn').click(function() {
var r = [];
$('.xh').each(function(i, t) {
r.push($(this).html());
});
$.post(‘server.php', {px:r}); // server.php 表示接受数据的php
});
然后 server.php 中加入
$data = isset($_POST['px'])? $_POST['px'] : array();
print_r($data); // 打印获取的数据
// 执行写入数据库的操作。
?>
这个需要你自己先搭建php + mysql 运行环境。以及需要了解php,mysql的语法。
搭建环境可以安装wamp2来实现。
到是能输出了 可是移动的动作没了呀 不能移动我怎么获取数据? 能不能交流一下 913666847
没问题了 谢谢你们 非常感谢

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

长URL(通常用关键字和跟踪参数都混乱)可以阻止访问者。 URL缩短脚本提供了解决方案,创建了简洁的链接,非常适合社交媒体和其他平台。 这些脚本对于单个网站很有价值

在Facebook在2012年通过Facebook备受瞩目的收购之后,Instagram采用了两套API供第三方使用。这些是Instagram Graph API和Instagram Basic Display API。作为开发人员建立一个需要信息的应用程序

Laravel使用其直观的闪存方法简化了处理临时会话数据。这非常适合在您的应用程序中显示简短的消息,警报或通知。 默认情况下,数据仅针对后续请求: $请求 -

这是有关用Laravel后端构建React应用程序的系列的第二个也是最后一部分。在该系列的第一部分中,我们使用Laravel为基本的产品上市应用程序创建了一个RESTFUL API。在本教程中,我们将成为开发人员

Laravel 提供简洁的 HTTP 响应模拟语法,简化了 HTTP 交互测试。这种方法显着减少了代码冗余,同时使您的测试模拟更直观。 基本实现提供了多种响应类型快捷方式: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

PHP客户端URL(curl)扩展是开发人员的强大工具,可以与远程服务器和REST API无缝交互。通过利用Libcurl(备受尊敬的多协议文件传输库),PHP curl促进了有效的执行

您是否想为客户最紧迫的问题提供实时的即时解决方案? 实时聊天使您可以与客户进行实时对话,并立即解决他们的问题。它允许您为您的自定义提供更快的服务

2025年的PHP景观调查调查了当前的PHP发展趋势。 它探讨了框架用法,部署方法和挑战,旨在为开发人员和企业提供见解。 该调查预计现代PHP Versio的增长
