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

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

AI Hentai Generator
Générez AI Hentai gratuitement.

Article chaud

Outils chauds

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

La journalisation PHP est essentielle pour surveiller et déboguer les applications Web, ainsi que pour capturer des événements critiques, des erreurs et un comportement d&#39;exécution. Il fournit des informations précieuses sur les performances du système, aide à identifier les problèmes et prend en charge le dépannage plus rapide

Laravel simplifie la gestion des données de session temporaires à l'aide de ses méthodes de flash intuitives. Ceci est parfait pour afficher de brefs messages, alertes ou notifications dans votre application. Les données ne persistent que pour la demande ultérieure par défaut: $ demande-

L'extension PHP Client URL (CURL) est un outil puissant pour les développeurs, permettant une interaction transparente avec des serveurs distants et des API REST. En tirant parti de Libcurl, une bibliothèque de transfert de fichiers multi-protocol très respectée, PHP Curl facilite Efficient Execu

Laravel fournit une syntaxe de simulation de réponse HTTP concise, simplifiant les tests d'interaction HTTP. Cette approche réduit considérablement la redondance du code tout en rendant votre simulation de test plus intuitive. L'implémentation de base fournit une variété de raccourcis de type de réponse: Utiliser illuminate \ support \ faades \ http; Http :: faux ([[ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Voulez-vous fournir des solutions instantanées en temps réel aux problèmes les plus pressants de vos clients? Le chat en direct vous permet d'avoir des conversations en temps réel avec les clients et de résoudre leurs problèmes instantanément. Il vous permet de fournir un service plus rapide à votre personnalité

Alipay Php ...

L'article traite de la liaison statique tardive (LSB) dans PHP, introduite dans PHP 5.3, permettant une résolution d'exécution de la méthode statique nécessite un héritage plus flexible. Problème main: LSB vs polymorphisme traditionnel; Applications pratiques de LSB et perfo potentiel

L'article examine l'ajout de fonctionnalités personnalisées aux cadres, en se concentrant sur la compréhension de l'architecture, l'identification des points d'extension et les meilleures pratiques pour l'intégration et le débogage.
