jQuery Mobile的PHP表单订阅 [英] PHP Form Submision with jQuery Mobile

查看:46
本文介绍了jQuery Mobile的PHP表单订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的jquery移动应用程序代码.但是我用php结果创建的表格不起作用.表单未在提交时发布数据.我什至尝试了data-ajax="flase".

This is my code for a jquery mobile application. But the form i created with php result is not working. Form is not posting data on submit. I even tried data-ajax="flase".

<table id="stock">
<? $sql = mysqli_query($con, "SELECT * FROM products WHERE `product_id` = '1'");
    while($row=mysqli_fetch_array($sql)){
        $name = $row['name'];
        $chamecal = $row['chamecal'];
        $price = $row['selling_price'];
        $bprice = $row['buying_price'];
        $quantity = $row['quantity'];
        $manufacturer = $row['manufacturer'];
        $date = $row['date'];
        $edate = $row['expire'];
        $pid = $row['product_id'];
?>
   <form id="stockupdate" method="post" action="medupdate.php">
    <tr>
        <td><?=$name;?></td>
        <td><?=$chamecal;?></td>
        <td><?=$manufacturer;?></td>
        <td><input type="text" name="medbprice" value="<?=$bprice;?>" /></td>
        <td><input type="text" name="medprice" value="<?=$price;?>" /></td>
        <td><?=$date;?></td>
        <td><?=$edate;?></td>
        <td><input type="text" name="medstock" value="<?=$quantity;?>" /></td>
        <td class="ui-screen-hidden"><input type="text" name="pid" value="<?=$pid;?>" /></td>
        <td>
            <input type="submit" title="Update" data-icon="gear" data-theme="f" data-inline="true" data-iconpos="notext" />
        </td>
    </tr>
<?    
    } 
?>
</form>
</table>

值处理程序文件medupdate.php

<?php session_start();?>
<?php include_once('include/config.php');?>
<?
$pid        = $_POST['pid'];
$medbprice  = $_POST['medbprice'];
$medprice   = $_POST['medprice'];
$medstock   = $_POST['medstock'];

$sql = mysqli_query($con, "UPDATE `products` SET `quantity` = '$medstock', `buying_price` = '$medbprice' , `selling_price` = '$medprice' WHERE `product_id` = '$pid'");

if($sql){
echo 1;
}
?>

推荐答案

如果我要冒险猜一猜,那是因为您要放置

If I was to hazard a guess, it's because you're placing

<form id="stockupdate" method="post" action="medupdate.php">

直接在表格元素内(无效标记).将其移到表外(在<table>之前).当您创建无效的标记时,浏览器引擎会尝试对其进行更正,这可能会导致诸如此类的问题.

directly within a table element (which is invalid markup). Move this outside your table (before your <table>). When you create invalid markup, the browsers engine tries to correct it which can lead to issues like this.

这是chrome对您的标记所做的:

This is what chrome does to your markup:

这篇关于jQuery Mobile的PHP表单订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆