dsa80833 2015-08-10 11:54
浏览 52


I am new here and just registered to ask a question. First of all i am newbie to PHP,so i have not tons of experience in it. My problem is the following:

I got two tables in my database. The first one is called products. The products table gives new products in my shop an unique ID. The second one is the products_to_categories table, in this table the products_id gets an cateogries_id so you know which product belongs to which category.

Now i need to echo the images (products_images in products-table) from the last 4 products (there is also a products_date_added attribute) of a category. All i managed to do until now is to echo the links of the images from the product tables:

$retval = mysql_query( $sql, $conn );
if(! $retval )
  die('Could not get data: ' . mysql_error());
while($row = mysql_fetch_assoc($retval))
    echo "Product Image : {$row['products_image']}  <br> ".
echo "Fetched data successfully


could someone help me to do that? thanks in advance!

  • 写回答

1条回答 默认 最新

  • dongzai3917 2015-08-10 12:00

    Wrap img tags (html) around the links you echo, so

    echo "Product Image : {$row['products_image']}  <br> ".


    echo "Product Image : <img src=\"{$row['products_image']}\"/>  <br> ".

    and as for the results, you can limit the search by using LIMIT 4 and ORDER BY to sort it by the date products_date_added

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 加一个K2暂停音乐的功能
  • ¥15 完成虚拟机环境配置,还有安装kettle
  • ¥15 2024年全国大学生数据分析大赛A题:直播带货与电商产品的大数据分析 问题5. 请设计一份优惠券的投放策略,需要考虑优惠券的数量、优惠券的金额、投放时间段和投放商品种类等因素。求具体的python代码
  • ¥15 有人会搭建生鲜配送自营+平台的管理系统吗
  • ¥15 用matlab写代码
  • ¥30 motoradmin系统的多对多配置
  • ¥15 求组态王串口自定义通信配置方法或代码?
  • ¥15 实验 :UML2.0 结构建模
  • ¥20 用vivado写数字逻辑实验报告撰写,FPGA实验
  • ¥15 为什么shp文件会有这种小方块?