dqc42632 2014-03-18 18:37
浏览 25

PHP SELECT在哪里

First of all sorry for my bad english.

I have a php script that display a list of products from sql:

$cerereSQL = 'SELECT * FROM `produse`'; 
   $rezultat = mysql_query($cerereSQL);
   while($rand = mysql_fetch_array($rezultat)){
echo '
<form action="editare.php" method="post">
<table width="100%" cellpadding="0" cellspace="0">
<tr style="text-align:center;" height="25">
<td style="border:1px solid black;" width="7%" height="10"><i> '.$rand['indice'].' </i></td>
<td style="border:1px solid black;" width="40%"><i> '.$rand['denumire_produs'].' </i></td>
<td style="border:1px solid black;" width="20%"><i> '.$rand['producator'].' </i></td>
<td style="border:1px solid black;" width="10%"><i> '.$rand['pret'].' </i></td>
<td style="border:1px solid black;" width="6%"><i> '.$rand['valuta'].' </i></td>
<td style="border:1px solid black;" ><i> '.$rand['cod'].' </i></td>
<td width="5%"><input type="submit" name="submit" value="Edit"></td>
</tr>
</table>
</form>';

I want the button (value="Edit") from the end of each row to select exactly the product from the same row, to be edited.

I tried next code but did't work (i have a list with 5000 lines):

switch($_GET['actiune'])
{
case '':

$cerereSQL = 'SELECT * FROM `produse` WHERE denumire_produs="'.$rand['denumire_produs'].'"'; 

I know i have to use: $cerereSQL = 'SELECT * FROMproduseWHERE denumire_produs="......"; but i don't know how to do this, how to make the edit button, open the exactly product from the same row. Can someone please help me with a suggestion?

  • 写回答

2条回答 默认 最新

  • douzhe1264 2014-03-18 18:40
    关注

    Perhaps you mean to do this:

    $cerereSQL = 'SELECT * FROM `produse`'; 
       $rezultat = mysql_query($cerereSQL);
       while($rand = mysql_fetch_array($rezultat)){
    echo '
    <form action="editare.php" method="post">
    <table width="100%" cellpadding="0" cellspace="0">
    <tr style="text-align:center;" height="25">
    <td style="border:1px solid black;" width="7%" height="10"><i> '.$rand['indice'].' </i></td>
    <td style="border:1px solid black;" width="40%"><i> '.$rand['denumire_produs'].' </i></td>
    <td style="border:1px solid black;" width="20%"><i> '.$rand['producator'].' </i></td>
    <td style="border:1px solid black;" width="10%"><i> '.$rand['pret'].' </i></td>
    <td style="border:1px solid black;" width="6%"><i> '.$rand['valuta'].' </i></td>
    <td style="border:1px solid black;" ><i> '.$rand['cod'].' </i></td>
    <td width="5%"><input type="hidden" name="denumire_produs" value="'.$rand['denumire_produs'].'"><input type="submit" name="submit" value="Edit"></td>
    </tr>
    </table>
    </form>';
    

    Then, snag the denumire_produs from $_POST:

    $denumire_produs = intval($_POST['denumire_produs']); // is this an INTeger? Otherwise, use `mysql_real_escape_string` -- or use PDO prepared statements.
    $cerereSQL = 'SELECT * FROM `produse` WHERE denumire_produs="'.$denumire_produs.'"'; 
    

    Is this what you're trying to do?

    评论

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来