第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何防止 php mysqli 中的標(biāo)題重復(fù)

如何防止 php mysqli 中的標(biāo)題重復(fù)

PHP
SMILET 2023-07-08 15:35:05
我已經(jīng)加入了兩個(gè)表images和post表,當(dāng)我將兩個(gè)或多個(gè)圖像上傳到image表post時(shí),表標(biāo)題只有一個(gè),但它重復(fù)圖像,如數(shù)字,我想知道如何解決它,任何人都可以幫助我,謝謝我的英語問題像這樣的帖子表id  title3   example 圖像表是這樣的id  img       post_id1   123.jpg   32   22.jpg    33   11.jpg    34   21.jpg    35   34.jpg    3發(fā)布標(biāo)題one,但它重復(fù) 5 張time圖片,我想阻止它這是我的源代碼<?phpif ($stmt = $con->prepare("  SELECT p.*,i.img,title,id from post AS p LEFT JOIN images AS i ON i.post_id= p.id ")) {$stmt->execute();}$result = $stmt->get_result();if ($result->num_rows>0) {while ($row = $result->fetch_assoc()) {?><?php echo $row['title']; ?><img src="images/<?php echo $row['img']; ?>"height="20"width="20"/><?php}}?>
查看完整描述

3 回答

?
天涯盡頭無女友

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超9個(gè)贊

<?php

if ($stmt = $con->prepare("  SELECT p.*,i.img,title,id 

from post AS p LEFT JOIN images AS i ON i.post_id= p.id ")) {

$stmt->execute();

}

$result = $stmt->get_result();

if ($result->num_rows>0) {

$firstTime=true;

while ($row = $result->fetch_assoc()) {

?>

<?php 

if($firstTime==true){

echo $row['title'];

$firstTime=false;

}

 ?>

<img src="images/<?php echo $row['img']; ?>"height="20"width="20"/>

<?php

}}

?>


查看完整回答
反對(duì) 回復(fù) 2023-07-08
?
Qyouu

TA貢獻(xiàn)1786條經(jīng)驗(yàn) 獲得超11個(gè)贊

列標(biāo)題將重復(fù)等于圖像表中返回的行數(shù),您無法采取任何措施來阻止它。

如果您按標(biāo)題分組,它將返回等于帖子表中行數(shù)的行數(shù)。

但如果你更詳細(xì)地說明你真正想對(duì)結(jié)果做什么,我可能會(huì)幫助你。


查看完整回答
反對(duì) 回復(fù) 2023-07-08
?
素胚勾勒不出你

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超9個(gè)贊

請(qǐng)嘗試這個(gè):-


<?php

$a1 = "";

$stmt = $con->prepare("SELECT p.*,i.img,title,id  

from post AS p INNER JOIN images AS i ON i.post_id=p.id");

$stmt->execute();

$result = $stmt->get_result();


if ($result->num_rows>0) {

while ($row = $result->fetch_assoc()) {

           $title = $row['title'];

            $img = $row['img'];

               }

               

 if($a1!= $title){

 $activity="";

 $activity.="<tr>

            <td>$title</td>

            </tr>;

            }

    $activity.="<tr>

            <td><img src="images/<?php echo $img ?>"height="20"width="20"/></td>

                      </tr>";

    $a1=$title; 

 }

?>


查看完整回答
反對(duì) 回復(fù) 2023-07-08
  • 3 回答
  • 0 關(guān)注
  • 195 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)