0

我只需要过滤以“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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Item Number&nbsp;&nbsp; &nbsp; &nbsp;</th><th>Description</th><th>Artwork No.   </th><th class="hidden">PDF &nbsp; &nbsp;</th><th>Min &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Max &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Qty&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</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.' &nbsp; &nbsp;</td><td class="hidden"><a href="/data/hero/upload/'.$part_no.'.pdf" target="_blank">Link &nbsp;</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;
?>
4

1 回答 1

1

尝试:

SELECT type, part_no, description, artwork, min, max, qty FROM cartons_current WHERE part_no like '250%'

或者:

SELECT type, part_no, description, artifact, min, max, qty FROM cartons_current WHERE left(part_no,3) = '250'

于 2012-06-06T01:26:09.377 回答