在sql查询的html中提交
submit in html on sql query
我需要运行这个sql查询,它会给我一个Id和Dates的列表我想点击每个结果,并将Id值带到下一个表单我在上面写了这个查询,但我在debager中看到隐藏的ID得到了他的值,但没有传递到下一个表单我想我的submit()
有问题。我该把他放在哪里?
function ShowAllCarts($user_email) {
$connB = new ProductDAO();
$connB->Connect();
$pro_query = "SELECT * FROM Cart WHERE `Email`='$user_email';";
$db_result = $connB->ExecSQL($pro_query);
$html_result = '<div data-role="content"> <ul data-role="listview" data-theme="b"> ';
$html_result .= '<form action="PreviouscartProduct.php" method="POST"/>';
while($row_array = $db_result->fetch_array(MYSQLI_ASSOC))
{
$Id= $row_array['Id'];
$Date= $row_array['Date'];
//$html_result //
$html_result .="<li><a href='PreviouscartProduct.php'>Cart number: $Id from Date: $Date><input type='hidden' name='Id' value'<?=$Id?>'</input></a></li>'";
$html_result .= '<a onclick="this.form.submit();" </a>;
}
$html_result .= '</form>';
$html_result .= ' </ul> </div>';
$connB->Disconnect();
return $html_result;
}
//display all carts
$func_result = ShowAllCarts($Email);
您需要使用checkbox
元素:
$html_result .="<li>"
."<checkbox name='cartItem[$Id]' value='$Date'>"
. "Cart number: $Id from Date: $Date"
. "</li>'"
;
然后,在PreviouscartTroduct.php中,您可以在cartItem:上迭代
$cartItems = $_POST[ 'cartItem' ];
foreach( $cartItems as $id => $date ) {
... do something ...
}
如果你只想拿一件东西,为什么不使用这个:
$html_result .="<li>"
. "<a href='PreviouscartProduct.php?cartID=$Id&date=$Date'>"
. "Cart number: $Id from Date: $Date"
. "</a>"
. "</li>'"
;
这里面有很多HTML语法错误,请检查验证器中的输出
首先,在.form.submit();之后,打开标记不会关闭;,它应该读取
$html_result .= '<a onclick="this.form.submit();">Anchor Text Here</a>';
编辑:锚元素需要引用表单。给表单元素一个name属性并使用类似的东西
onclick="document.nameattributehere.submit();return false"
在链接上。
结束编辑。
此外,在上面的行中,当您获得输入的value属性时,您已经在使用PHP解析器,因此不需要
<?= and ?>
最后,在同一个标签中,您不需要关闭输入标签
</input>
只需用关闭打开标签
/>
这只是浏览一下,运行验证器以查找其他错误,我相信问题会更清楚。
相关文章:
- 如何在提交html表单后保持相同的位置
- 使用 WebView for Android 提交 HTML 表单
- 纯javascript的进度图像加载程序仅当用户单击提交html表单时
- 为什么这个javascript/jQuery没有提交html表单
- 提交HTML表单,该表单使用带有cURL的javascript进程
- 在 javascript 中提交 HTML 表单上的多个输入值
- 异步数据加载后提交HTML表单的正确方法是什么
- 通过 AJAX 请求提交 HTML 表单
- 在提交 HTML 表单后从数组中提取数据(按键事件)
- SilverStripe 通过 Ajax 提交 HTML 表单
- 我可以使用 Ajax 和 Visual Composer (Raw HTML 和 Raw JS) 提交 HTML Sal
- 尝试通过javascript提交html表单变量时没有任何反应
- Iframe 发布表单 - 在更改输入字段时提交 html 表单
- 在提交 HTML 表单后保留 JavaScript 中的 innerHTML 值
- 用于在离线时提交 HTML 表单的 Javascript
- 无法在 Angular 2 应用程序中提交 HTML 表单
- 提交 HTML 表单而不打开新窗口
- 在php中提交html表单
- 如何在提交HTML表单时强制不接收数据
- 如何在不重定向的情况下提交 HTML 表单