基于用户选择的在while循环中获取变量? [英] Get variable in while loop based on what user chooses?
本文介绍了基于用户选择的在while循环中获取变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从deleteupload.php中删除一篇文章,因此我想访问product_id,这是提交后每行的唯一标识符。我已经将每个产品都包装在一个表单元素和一个提交按钮中。所以这个页面有多个表单元素。
这是我的代码:
<$ c $ ($ row = mysql_fetch_array($ loop))
{
$ proID = $ row ['product_id'];
echo'< table border ='0'width ='100%'align ='center'class ='centrebox'>< tr>
< td width =' 25%'>。($ row ['product_name'])。 < / td>。
< td width = '35%'>。($ row ['product_disc'])。< / td>;
echo'< td width =40%>< img width =100%height =300src =data:image / jpeg; base64,'。base64_encode $ row ['product_image'])。'/>< / td>< / tr>
< td>< form method =postaction =deleteupload.php>
< input type =submitname =$ proIDvalue =Delete>< / form>< / td>< / table>< br>';
这个while循环遍历sql表和回显列(product_name,product_disc和product_image)。
解决方案
< table border ='0 'width ='100%'align ='center'class ='centrebox'>
<?php
while($ row = mysql_fetch_array($ loop))
{
$ proID = $ row ['product_id'];
?>
< tr>
< td width = '25%'><?php($ row ['product_name'])?>< / td>
< td width = '35%'><?php($ row ['product_disc'])?>< / td>
< td width = '35%'>
< a href =deleteupload.php?action = delete& id =<?php echo $ proID?>>< / a>
< / td>
<?php}?>
< / table>
$ b $ ** deleteupload.php **
<?php
if($ _ GET ['action'] =='delete'){
删除查询
}
?>
I want to delete a single post from deleteupload.php hence I want to access product_id which is the unique identifier of each row after submission. I have wrapped every product in a form element and a submit button. So the page has multiple form elements.
This is my code:
while ($row = mysql_fetch_array($loop)) { $proID = $row['product_id']; echo "<table border='0' width='100%' align='center' class='centrebox'><tr> <td width='25%'>".($row['product_name']) . "</td> " . " <td width='35%'>".($row['product_disc'])."</td>"; echo '<td width="40%"><img width="100%" height="300" src="data:image/jpeg;base64,'.base64_encode( $row['product_image'] ).'"/></td></tr> <td><form method="post" action="deleteupload.php"> <input type="submit" name="$proID" value="Delete"></form></td></table><br>'; }
This while loop iterates through the sql table and echos the columns (product_name, product_disc, and product_image).
解决方案<table border='0' width='100%' align='center' class='centrebox'> <?php while ($row = mysql_fetch_array($loop)) { $proID = $row['product_id']; ?> <tr> <td width='25%'><?php ($row['product_name'])?></td> <td width='35%'><?php ($row['product_disc']) ?></td> <td width='35%'> <a href="deleteupload.php?action=delete&id=<?php echo $proID ?>"></a> </td> <?php } ?> </table> **deleteupload.php** <?php if($_GET['action']=='delete'){ delete query } ?>
这篇关于基于用户选择的在while循环中获取变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文