把数值发送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
没问题了 谢谢你们 非常感谢

Heiße KI -Werkzeuge

Undresser.AI Undress
KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover
Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool
Ausziehbilder kostenlos

Clothoff.io
KI-Kleiderentferner

AI Hentai Generator
Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

Heiße Werkzeuge

Notepad++7.3.1
Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version
Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1
Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6
Visuelle Webentwicklungstools

SublimeText3 Mac-Version
Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Heiße Themen

Lange URLs, die oft mit Schlüsselwörtern und Tracking -Parametern überfüllt sind, können Besucher abschrecken. Ein URL -Verkürzungsskript bietet eine Lösung, die präzise Links erstellt, die ideal für soziale Medien und andere Plattformen sind. Diese Skripte sind für einzelne Websites a wertvoll

Nach seiner hochkarätigen Akquisition durch Facebook im Jahr 2012 nahm Instagram zwei APIs für den Einsatz von Drittanbietern ein. Dies sind die Instagram -Graph -API und die Instagram Basic Display -API. Ein Entwickler, der eine App erstellt, die Informationen von a benötigt

Laravel vereinfacht die Behandlung von temporären Sitzungsdaten mithilfe seiner intuitiven Flash -Methoden. Dies ist perfekt zum Anzeigen von kurzen Nachrichten, Warnungen oder Benachrichtigungen in Ihrer Anwendung. Die Daten bestehen nur für die nachfolgende Anfrage standardmäßig: $ Anfrage-

Dies ist der zweite und letzte Teil der Serie zum Aufbau einer Reaktionsanwendung mit einem Laravel-Back-End. Im ersten Teil der Serie haben wir eine erholsame API erstellt, die Laravel für eine grundlegende Produktlistenanwendung unter Verwendung von Laravel erstellt hat. In diesem Tutorial werden wir Dev sein

Laravel bietet eine kurze HTTP -Antwortsimulationssyntax und vereinfache HTTP -Interaktionstests. Dieser Ansatz reduziert die Code -Redundanz erheblich, während Ihre Testsimulation intuitiver wird. Die grundlegende Implementierung bietet eine Vielzahl von Verknüpfungen zum Antworttyp: Verwenden Sie Illuminate \ Support \ facades \ http; Http :: fake ([ 'Google.com' => 'Hallo Welt',, 'github.com' => ['foo' => 'bar'], 'Forge.laravel.com' =>

Die PHP Client -URL -Erweiterung (CURL) ist ein leistungsstarkes Tool für Entwickler, das eine nahtlose Interaktion mit Remote -Servern und REST -APIs ermöglicht. Durch die Nutzung von Libcurl, einer angesehenen Bibliothek mit Multi-Protokoll-Dateien, erleichtert PHP Curl effiziente Execu

Möchten Sie den dringlichsten Problemen Ihrer Kunden in Echtzeit und Sofortlösungen anbieten? Mit Live-Chat können Sie Echtzeitgespräche mit Kunden führen und ihre Probleme sofort lösen. Sie ermöglichen es Ihnen, Ihrem Brauch einen schnelleren Service zu bieten

Die 2025 PHP Landscape Survey untersucht die aktuellen PHP -Entwicklungstrends. Es untersucht Framework -Nutzung, Bereitstellungsmethoden und Herausforderungen, die darauf abzielen, Entwicklern und Unternehmen Einblicke zu geben. Die Umfrage erwartet das Wachstum der modernen PHP -Versio
