把數值發送php 讓php執行在資料庫儲存啊

來源:互聯網
上載者:User
第一個是未排序的 第二個是排序後擷取數值的 怎麼能把數值發送給資料庫儲存啊
  {foreach from=$shop item=i} 
    {/foreach} 
  

編號

名 稱

種 類

類 別

圖 片

簡 介

圖 示

介 紹

公 司

開 始

結 束

地 址

休 息

網 址

停 止

操 作

排 序

{$i["id"]} {$i["name"]} {$i["varietyid"]} {$i["classifyid"]} {$i["list_pic"]} {$i["introduction"]} {$i["show_pic"]} {$i["product_introduction"]} {$i["company"]} {$i["business_start"]} {$i["business_end"]} {$i["address"]} {$i["rest_flag"]} {$i["web"]} {$i["del_flag"]} 修改 刪除 上移 下移 置頂


 


回複討論(解決方案)

先序號表單,通過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: "}" <-- thrown in C:\wamp\www\xcx\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 154

你的 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: "}" <-- thrown in C:\wamp\www\xcx\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 154

去掉{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}

{/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

沒問題了 謝謝你們 非常感謝

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.