php-echo-ommitting<;表格>;在第一次迭代中

php-echo-ommitting<;表格>;在第一次迭代中,php,Php,编辑:问题已经解决,代码中以前的部分格式错误 我正在为一个网上购物网站写一个搜索结果页面,我面临一个问题 以下是从我的数据库提取后echo的迭代代码: $count=1; while($prod=$gettingprods->fetch_assoc()){ echo"<div style='text-align:center;margin-left:10px;width:350px;height:225px;display:inline-block;float:left;bo

编辑:问题已经解决,代码中以前的部分格式错误

我正在为一个网上购物网站写一个搜索结果页面,我面临一个问题

以下是从我的数据库提取后echo的迭代代码:

$count=1;
while($prod=$gettingprods->fetch_assoc()){
    echo"<div style='text-align:center;margin-left:10px;width:350px;height:225px;display:inline-block;float:left;border-radius:7px;border-color:red;border-style:inset;margin-bottom:10px'>
    <h5>".$prod['brand_name']." ".$prod['product_name']."</h5>
    <h6>Chez ".$prod['shop_name']."</h6>
    <h5 style='font-color:red'>Prix Unitaire LBP/USD: ".$prod['pis_lbp']."/".sprintf('%.2f',$prod['pis_usd'])."</h5>
    <form action='addtocart.php?val=".$count."' id='prod".$count."' method='post'>
    <p><input type='number' name='qty".$count."' min='1' placeholder='Quantité'/></p>
    <p><div id='buttonNext' name='add".$count."' onclick='submitForm".$count."()'>
Ajouter
</div></p>
    <input type='hidden' name='url".$count."' 
value='".substr($_SERVER['REQUEST_URI'],1)."'/>
    <input type='hidden' name='prod".$count."' value=".$prod['pis_id'].">
    </form>
  </div>
  <script>
  function submitForm".$count."(){
      document.getElementById('prod".$count."').submit();
  }
  </script>";
  $count+=1;
}
问题只发生在第一个div中,下面是页面外观的示例屏幕截图:

任何帮助都将不胜感激。请注意,此时安全性并不重要。谢谢

编辑:以下是检查器的输出代码示例:

<div style="text-align:center;margin-
left:10px;width:350px;height:225px;display:inline-block;float:left;border-
radius:7px;border-color:red;border-style:inset;margin-bottom:10px">
    <h5>Al Wadi Al Akhdar Sweet Corn</h5>
    <h6>Chez Supermarché Test</h6>
    <h5 style="font-color:red">Prix Unitaire LBP/USD: 1500/1.00</h5>

    <p><input type="number" name="qty1" min="1" placeholder="Quantité"></p>
    <p></p><div id="buttonNext" name="add1" onclick="submitForm1()">
Ajouter
</div><p></p>
    <input type="hidden" name="url1" value="searchresults.php?type=shop&amp;query=3">
    <input type="hidden" name="prod1" value="4">

  </div>
<script>
function submitForm1(){
  document.getElementById('prod1').submit();
}
</script>

阿赫达尔河甜玉米
切兹超拱试验
Prix Unitaire LBP/美元:1500/1.00

阿约特

函数submitForm1(){ document.getElementById('prod1').submit(); }

就我所见,这个表单没有输出,我不明白为什么要为每个表单重复提交函数

尝试为所有窗体创建一个函数,请尝试以下操作:

php:

$count=1;
而($prod=$gettingprods->fetch_assoc()){
回声
"
“$prod[‘品牌名称’]”..“$prod[‘产品名称’]”
Chez.“$prod['shop_name']
Prix Unitaire LBP/USD:“..prod['pis_LBP']”./“.sprintf('.2f',$prod['pis_USD'])”

阿约特

"; $count+=1; }
js:


函数提交表单(计数){
document.getElementById('prod'+count).submit();
}

刚刚试过。谢谢你的提醒。关于为什么循环中的第一个没有回声而其他的没有回声,有什么线索吗?@RabihMelko共享html对吗?所以第一个产品没有
标签?它是以每次迭代打印它的方式共享的,但我不明白你在说什么mean@RabihMelko看看你的html,没有
标记是的,在第一个表单中没有任何表单标记,而在其他表单中有。同样在原始资料中,甚至在第一本书上也有形式
<div style="text-align:center;margin-
left:10px;width:350px;height:225px;display:inline-block;float:left;border-
radius:7px;border-color:red;border-style:inset;margin-bottom:10px">
    <h5>Al Wadi Al Akhdar Sweet Corn</h5>
    <h6>Chez Supermarché Test</h6>
    <h5 style="font-color:red">Prix Unitaire LBP/USD: 1500/1.00</h5>

    <p><input type="number" name="qty1" min="1" placeholder="Quantité"></p>
    <p></p><div id="buttonNext" name="add1" onclick="submitForm1()">
Ajouter
</div><p></p>
    <input type="hidden" name="url1" value="searchresults.php?type=shop&amp;query=3">
    <input type="hidden" name="prod1" value="4">

  </div>
<script>
function submitForm1(){
  document.getElementById('prod1').submit();
}
</script>
$count=1;
while($prod=$gettingprods->fetch_assoc()){
    echo
    "<div style='text-align:center;margin-left:10px;width:350px;height:225px;display:inline-block;float:left;border-radius:7px;border-color:red;border-style:inset;margin-bottom:10px'>
        <h5>".$prod['brand_name']." ".$prod['product_name']."</h5>
        <h6>Chez ".$prod['shop_name']."</h6>
        <h5 style='font-color:red'>Prix Unitaire LBP/USD: ".$prod['pis_lbp']."/".sprintf('%.2f',$prod['pis_usd'])."</h5>
        <form action='addtocart.php?val=".$count."' id='prod".$count."' method='post'>
            <p><input type='number' name='qty".$count."' min='1' placeholder='Quantité'/></p>
            <p>
                <div id='buttonNext' name='add".$count."' onclick='submitForm(".$count.")'>
                    Ajouter
                </div>
            </p>
            <input type='hidden' name='url".$count."' value='".substr($_SERVER['REQUEST_URI'],1)."'/>
            <input type='hidden' name='prod".$count."' value=".$prod['pis_id'].">
        </form>
    </div>";
    $count+=1;
}
<script>
    function submitForm(count){
        document.getElementById('prod'+count).submit();
    }
</script>