Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript php检索数据以在HTML中填充DIV_Javascript_Php_Html_Css - Fatal编程技术网

Javascript php检索数据以在HTML中填充DIV

Javascript php检索数据以在HTML中填充DIV,javascript,php,html,css,Javascript,Php,Html,Css,我需要建议。以下是我已经拥有的和我的要求 MySQL表有4列。 我使用php检索单个字符串中所有行的数据(代码a) 我有一个HTML格式的DIV设置(代码B-如下图所示) 我希望能够使用检索到的数据在DIV设置中创建多个图像(类似于html中的for循环?)-如何实现我的要求 我该怎么做 代码A while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){ $id = $row["id"]; $firstname = $row

我需要建议。以下是我已经拥有的和我的要求

MySQL表有4列。 我使用php检索单个字符串中所有行的数据(代码a)

我有一个HTML格式的DIV设置(代码B-如下图所示)

我希望能够使用检索到的数据在DIV设置中创建多个图像(类似于html中的for循环?)-如何实现我的要求

我该怎么做

代码A

while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){ 
    $id = $row["id"]; 
    $firstname = $row["firstname"];
    $lastname = $row["lastname"]; 
    $itemdate = strftime("%b %d, %Y", strtotime($row["datemade"])); 
    $dataString .= $id.'|'.$firstname.'|'.$lastname.'|'.$itemdate.'||'; 
}
代码B

 <div id="mainwrapper">
        <div id="box-1" class="box">
        <gt_descA>Teak Chair</gt_descA><gt_descC>$75.34</gt_descC>
            <img id="image-1" src="imagez/designs/thumbs/0/teak_chair001.jpg"/>
                <span class="caption simple-caption">
                <div class="minibuttonR"><a href="index.html" onClick="gotowebpage('11');"></a></div>
                <div class="minibuttonL"><a href="index.html" onClick="gotowebpage('11');"></a></div>
                <div class="minibuttonC"><a href="index.html" onClick="gotowebpage('11');"></a></div>
                <div style="clear:both;"></div>
                </span>
        </div>
        </div>

柚木椅子75.34美元
图像(DIV设置)

我希望能够从检索到的数据和DIV设置中实现这一点
将html代码放入php循环中

例如

while($row=mysqli\u fetch\u数组($query,mysqli\u ASSOC)){
$id=$row[“id”];
$firstname=$row[“firstname”];
$lastname=$row[“lastname”];
$itemdate=strftime(“%b%d,%Y”,strotime($row[“datemake”]);
$dataString.=$id.|'。$firstname.|'。$lastname.|'。$itemdate.| |';
?>
柚木椅子75.34美元

你到底想做什么?我不明白你的意思。我想用HTML中的php值创建图像。好的,那么你在php中有id、名字、姓氏和项目日期变量。你想如何用这个来创建图像。结构是什么?你会看到图像-“柚木椅”=名字变量|“$75.34”是last name VARIABLE,Grey box=item VARIABLE.use,用于在html代码中打印php变量。
while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){ 
$id = $row["id"]; 
$firstname = $row["firstname"];
$lastname = $row["lastname"]; 
$itemdate = strftime("%b %d, %Y", strtotime($row["datemade"])); 
$dataString .= $id.'|'.$firstname.'|'.$lastname.'|'.$itemdate.'||'; 
?>


    <div id="box-1" class="box">
    <gt_descA>Teak Chair</gt_descA><gt_descC>$75.34</gt_descC>
        <img id="image-1" src="imagez/designs/thumbs/0/teak_chair001.jpg"/>
            <span class="caption simple-caption">
            <div class="minibuttonR"><a href="index.html" onClick="gotowebpage('11');"></a></div>
            <div class="minibuttonL"><a href="index.html" onClick="gotowebpage('11');"></a></div>
            <div class="minibuttonC"><a href="index.html" onClick="gotowebpage('11');"></a></div>
            <div style="clear:both;"></div>
            </span>
    </div>
<?php

}