【问题标题】:how to fetch only image in php while loop如何在php while循环中仅获取图像
【发布时间】:2015-12-13 08:10:01
【问题描述】:

我正在尝试仅从数据库中获取图像。在数据库中,表(post_content)有图像以及我只想要图像的描述。可能吗?请记住,$row['post_content'] 具有图像和说明。

<?php
    $sql = "select * from wp_tableposts;";
    $res = mysql_query($sql);

    while ($row = mysql_fetch_array($res))
    { 
        echo'Post Contant:'. $row['post_content']. '';
    }
?>

【问题讨论】:

  • 如果你的表中没有图片的特殊字段,那么你必须解析post_content
  • 请详细说明我不懂解析post_content
  • 他可能正在考虑使用/破坏$row['post_content']pathinfo($row['post_content']) 或类似功能。看看 php.net 手册页上的pathinfo() 函数。
  • 请提供 post_content 中的数据示例,以及该示例所需的结果。
  • 此数据来自数据库&lt;img class="alignnone size-medium wp-image-8" src="http://localhost/wordpress/wp-content/uploads/2015/12/1977417_1380086445598132_747645780_n-225x300.jpg" alt="1977417_1380086445598132_747645780_n" width="225" height="300" /&gt;this is description

标签: php wordpress loops


【解决方案1】:

解决方案 1(推荐): 在数据库中将描述和图像分成两列

解决方案 2: 使用分隔符(#、/\ 或分隔符)区分同一列中的图像和描述

【讨论】:

    猜你喜欢
    • 2015-09-05
    • 1970-01-01
    • 1970-01-01
    • 2017-02-02
    • 2016-11-27
    • 1970-01-01
    • 2021-10-19
    • 1970-01-01
    • 2013-11-06
    相关资源
    最近更新 更多