CREATE TABLE `item` (
`ID` int(5) NOT NULL auto_increment,
`Part_No` varchar(20) NOT NULL,
`Detail` text NOT NULL,
`Qty` int(5) NOT NULL,
`Unit` varchar(15) NOT NULL,
`Price` double NOT NULL,
`Amount` double NOT NULL,
`Remark` text NOT NULL,
`Invoice_ID` int(11) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=tis620 AUTO_INCREMENT=55 ;
</tr>
<?
//$n=0;
//$sql_show= "select * from head";
if($_POST['Search'])
//if(isset($search))
{
//$sql="select * from head";
$txt_search = $_POST['txt_search'];
$sql_show.="where Invoice_No like '%$txt_search%' or Number_No like '%$txt_search%' ";
$sql_show = "SELECT * FROM head, item WHERE (head.Invoice_ID = item.Invoice_ID) And (head.Invoice_No='$txt_search')";
$result11= mysql_query($sql_show);
echo $sql_show;
//$ff= mysql_query($sql_show)or die(mysql_error());
//echo $sql_show;
}
$n=1;
while($row_show = mysql_fetch_array($result11))
{
$in_id=$row_show["Invoice_ID"];
//echo $in_id;
?>
<tr>
<td><? echo $n;?></td>
<td><?=$row_show['Pr_No']?></td>
<td><?=$row_show['Number_No']?></td>
<td><?=$row_show['Invoice_No']?></td>
<td><?=$row_show['Receive_Date']?></td>
<td><div align="center"><a href="preview_slip.php?in_id=<?=$in_id?>">Preveiw</a></div></td>
</tr>
<?
$n++;
}
?>
</table>
มัน error ผมพึงหัด รบแนะนำด้วยนะครับ
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\part_transfer\search.php on line 40
ตรงนี้ครับ
//$sql="select * from head";
$txt_search = $_POST['txt_search']; $sql_show.="where Invoice_No like '%$txt_search%' or Number_No like '%$txt_search%' ";
$sql_show = "SELECT * FROM head, item WHERE (head.Invoice_ID = item.Invoice_ID) And (head.Invoice_No='$txt_search')";
จากอันแรก คุณ comment ไปแล้ว แต่
$sql_show.="where Invoice_No like '%$txt_search%' or Number_No like '%$txt_search%' ";
กับ
$sql_show = "SELECT * FROM head, item WHERE (head.Invoice_ID = item.Invoice_ID) And (head.Invoice_No='$txt_search')";