gpt4 book ai didi

PHP:如何在 MySQL 中每 10 行插入一个图像?

转载 作者:行者123 更新时间:2023-11-29 08:54:17 25 4
gpt4 key购买 nike

我想在填充 10 行数据后在一行中插入一个新的随机图像(全部单独)。

我想我应该输入这样的内容:

if($counter % 10 == 0) {
echo 'image file';
}

但不太确定如何将其合并到我的代码中:

 echo "<table border='1' CELLPADDING=5 STYLE='font-size:13px'>";
echo "<tr> <td><H3>No.</H3></td><td><H3>Date</H3></td>";
echo "<td><H3>First Name</H3></td> <td><H3>Last Name</H3></td>";
echo "<td><H3>City</H3></td><td><H3>Province</H3></td></tr>";

//declaring counter
$count=0;

// keeps getting the next row until there are no more to get
while ($row = mysql_fetch_array( $data, MYSQL_ASSOC )) {
//counter equals
$count=$count+1;

// Print out the contents of each row into a table
echo "</td><td>";
echo $count;
echo "</td><td>";
echo $row['DateIn'];
echo "</td><td>";
echo $row['FirstName'];
echo "</td><td>";
echo $row['LastName'];
echo "</td><td>";
echo $row['City'];
echo "</td><td>";
echo $row['Province_State'];
echo "</td></tr>";
}
echo "</table>";

最佳答案

echo "<table border='1' CELLPADDING=5 STYLE='font-size:13px'>";
echo "<tr> <td><H3>No.</H3></td><td><H3>Date</H3></td><td><H3>First Name</H3></td> <td> <H3>Last Name</H3></td> <td><H3>City</H3></td><td><H3>Province</H3></td></tr>";

//declaring counter
$count=0;

// keeps getting the next row until there are no more to get
while ($row = mysql_fetch_array( $data, MYSQL_ASSOC )) {

//counter equals
$count++;

//insert an image every 10 rows
if($count==10){
$count=0;
echo 'yourimage.jpg';
}

// Print out the contents of each row into a table
echo "</td><td>";
echo $count;
echo "</td><td>";
echo $row['DateIn'];
echo "</td><td>";
echo $row['FirstName'];
echo "</td><td>";
echo $row['LastName'];
echo "</td><td>";
echo $row['City'];
echo "</td><td>";
echo $row['Province_State'];
echo "</td></tr>";
}
echo "</table>";

关于PHP:如何在 MySQL 中每 10 行插入一个图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10392719/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com