dtsc14683 2017-03-10 15:20
浏览 12
已采纳

PHP循环运行遍布我的“mysql”表[重复]

This question already has an answer here:

Hello, I'm trying to run on 15 rows ONLY! each time.

First, this is my code-

PHP:

<div id ="items">
    <?php
    include './DateBaseLogOn.php';
    $sql = "SELECT * FROM items LIMIT 0, 15";
    $RESULT=$conn->query($sql);
    if(!$conn) {
      die("Connection Failed: ".mysqli_connect_error());
    }
    $row = $RESULT->fetch_assoc();
    while($row = mysqli_fetch_array($RESULT))
    {
    echo "<div id =\"itembox\">";
    echo "<div id=\"itempicture\"><img src=\"getImage.php?id=."$row['id']".\" width=\"230\" height=\"140\" /></div>";
    echo "<div id=\"iteminfo\">"."Info:".$row['info'].
    "</br>"."Current price:".$row['price'].
    "</br>"."Time until expired:".$row['exp'].
    "</br>"."Offer avilable until:".$row['timeleft'].
    "</br>"."Place:".$row['location'].
    "</div>";
    echo "<button class=\"sendprice\" onclick=\"location.href=$link\">Place bid</button>";
    echo "</div>";
    }

My questions are:

1. I'm getting an error :

( ! ) Parse error: syntax error, unexpected '$row' (T_VARIABLE), expecting ',' or ';' in C:\wamp\www\index.php on line 87

If i delete the <img src=\"getImage.php?id=."$row['id']".\" width=\"230\" height=\"140\" />

it works but i need to put the image there...

2. how can i tell the while loop to run only on 15 rows? and how can i make it run on the next 15 row with a click of a button (look at the echo row before the last echo row).

</div>
  • 写回答

1条回答 默认 最新

  • dsb12300 2017-03-10 15:22
    关注
    echo "<div id=\"itempicture\"><img src=\"getImage.php?id=."$row['id']".\" width=\"230\" height=\"140\" /></div>";
    

    You have the . after and before $row, inside the quotes. They need to be outside of the quotes.

    EDIT:

    So the solution is:

    echo "<div id=\"itempicture\"><img src=\"getImage.php?id=".$row['id']."\" width=\"230\" height=\"140\" /></div>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)