我不需要显示所有记录,而是只过滤以“250”开头的记录。有没有办法更改我现有的表脚本以仅显示以“250”开头的记录?
<?php
$db = new mysqli("localhost", "XXXXXX", "XXXXXX", "naturan8_hero");
$query = "SELECT type, part_no, description, artwork, min, max, qty FROM cartons_current LIMIT 0,100";
$result = $db->query($query, MYSQLI_STORE_RESULT);
$o = '<table id="tablesorter-demo" class="tablesorter" border="0" cellpadding="0" cellspacing="1"><thead><tr><th>TP </th><th>Item Number </th><th>Description</th><th>Artwork No. </th><th class="hidden">PDF </th><th>Min </th><th>Max </th><th>Qty </th> </tr></thead><tbody>';
while(list($type, $part_no, $description, $artwork, $min, $max, $qty) = $result->fetch_row()) {
$o .= '<tr><td>'.$type.'</td><td class="ptn">'.$part_no.'</td><td>'.$description.'</td><td>'.$artwork.' </td><td class="hidden"><a href="/data/hero/upload/'.$part_no.'.pdf" target="_blank">Link </a></td><td align="right" class="min">'.$min.'</td><td align="right" class="max">'.$max.'</td><td align="right" class="quantity"> '.$qty.'</td></tr>';}
$o .= '</tbody></table>';
echo $o;
?>
最佳答案
尝试:
SELECT type, part_no, description, artwork, min, max, qty FROM cartons_current WHERE part_no like '250%'
或者:
从 cartons_current 中选择类型、零件编号、描述、艺术品、最小、最大、数量,其中 left(part_no,3) = '250'
关于php - 我需要仅显示 mySQL 表中以 "250"前缀开头的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10907027/