是否可以根据特定的数值数组来定位数组值?我有这张表:
+---------+-------+-------+------------+---------------------+------------------------------+
| deck | count | break | cards | donator | image |
+---------+-------+-------+------------+---------------------+------------------------------+
| prejoin | 20 | 5 | 16, 01, 05 | User2, User1, User7 | img2.jpg, img1.jpg, img7.jpg |
+---------+-------+-------+------------+---------------------+------------------------------+
这就是我到目前为止所拥有的: https: //shizen.hakumei.org/test.php
它仅显示 User7 的名称和图像链接,我计划显示框 01 表示 User1 的名称和图像链接,然后显示框 16 表示 User2 的名称和图像链接。所以基本上就像:
Box 16 = User2 (img2.jpg link)
Box 01 = User1 (img1.jpg link)
Box 05 = User7 (img7.jpg link)
这是我当前必须从给定链接显示表格的代码:
function trim_value(&$value) { $value = trim($value); }
$res = $database->query("SELECT * FROM `table` ORDER BY `deck` LIMIT 1");
while ( $col = mysqli_fetch_assoc($res) ) {
echo '<center>';
$cards = explode(',', $col['cards']);
array_walk($cards, 'trim_value');
if ( $col['cards'] == '' ) { $count = 0; } else { $count = count($cards); }
$donator = explode(',', $col['donator']);
$donator = array_map(trim, $donator);
foreach ( $donator as $usr ) { $usr = trim($usr); }
$image = explode(',', $col['image']);
$image = array_map(trim, $image);
foreach ( $image as $img ) { $img = trim($img); }
echo '<h2>'.$col['deck'].' ('.$count.' / '.$col['count'].')</h2>
<table width="625" cellspacing="0" border="1"><tr>';
for ( $i = 1; $i <= $col['count']; $i++ ) {
$number = $i;
if ( $number < 10 ) { $number = "0$number"; }
$card = $number;
if ( in_array($card, $cards) ) echo '<td width="125" align="center" height="105">'.$card.'<br ><a href="'.$img.'" target="_blank">'.$usr.'</a></td>';
else { echo '<td width="125" align="center" height="105">00</td>'; }
if ( $col['break'] !== '0' && $i % $col['break'] == 0 ) { echo '</tr>'; }
}
echo '</table>
}
提前谢谢了!如果不可能或者有更好的方法,我也愿意接受想法。:)
HUWWW
呼唤远方