php分解mysql行

php分解mysql行,php,mysql,row,explode,Php,Mysql,Row,Explode,我已经看过了,但找不到我需要的答案 我正在尝试分解mysql中包含多个横幅文件名的行 <?php $str = 'one|two|three|four'; // positive limit print_r(explode('|', $str, 2)); // negative limit (since PHP 5.1) print_r(explode('|', $str, -1)); ?> 我从php教程网站上获取了这些代码。可以使用某种形式的echo命令从mysql行打

我已经看过了,但找不到我需要的答案

我正在尝试分解mysql中包含多个横幅文件名的行

<?php
$str = 'one|two|three|four';

// positive limit
print_r(explode('|', $str, 2));

// negative limit (since PHP 5.1)
print_r(explode('|', $str, -1));
?>

我从php教程网站上获取了这些代码。可以使用某种形式的echo命令从mysql行打印其中的文件名吗

不起作用的是

<?php include '../connect/dbseries.php' ?>
<?php include 'Sbarray.php' ?>

<a href="series.php">back</a>

<?php
$str = print' . $row[Bannerfilenames] .';

// positive limit
print_r(explode('|', $str, 2));

?>

提前谢谢你的帮助
Aaron

要打印
$row['Bannerfilenames']
中的所有文件名,请执行以下任一循环:

$names = explode ("|", $row['Bannerfilenames']);
foreach ($names as $name) echo "$name <br />";
如果可以,请重新设计该数据库并规范化这些表,这意味着将文件名放在一个额外的表中。这是一种更容易处理的方式,也是最先进的。例如:

table banner
----------------
banner_id
name
blabla
etc.

table filenames
-----------------
filename_id
banner_id  <--- store the banner_id from the above table here!
filename
blabla
表格横幅
----------------
条幅标识
名称
布拉布拉
等
表文件名
-----------------
文件名\u id

banner_id$str=print'$行[横幅文件名];回来$行[Bannerfilenames]。数组([0]=>1)这就是它在我的网站上显示的内容。我所寻找的是一种修复此错误的方法。有什么想法吗?谢谢你的帮助,效果很好。第一个更容易,因为数据库是如何创建的。现在,我只需要随机显示其中一个文件名即可。:)去玩:)再次感谢你的帮助。我肯定我会比我想的更早回来。
table banner
----------------
banner_id
name
blabla
etc.

table filenames
-----------------
filename_id
banner_id  <--- store the banner_id from the above table here!
filename
blabla