mysql - How to select a product from SQL where code and id -
i have sql table:
create table if not exists `orders` ( `id` int(11) not null auto_increment, `order_name` text not null, `order_q` text not null, `order_price` text not null, `order_id` text not null, `code` text not null, `order_date` text not null, `stat` text not null, primary key (`id`) ) engine=myisam default charset=cp1256 auto_increment=6 ;
i want print out rows 1 one order 2 rows:
1- order_id 2- code
this script looks shopping script, when clients making order, script automatically printing out invoice.
what should do?
my code:
<? include("config.php"); $print = 'onload="window.print(); "'; $code_num="123456"; $result = mysql_query("select * orders stat='0' && code='$code_num' order id asc limit 1"); while($row = mysql_fetch_array($result)) { echo $row[order_name]; } ?>
i not sure you're trying do, following code trick? haven't tested it, it's pretty straightforward. see sql order keyword , php mysql order keyword.
$query = "select * orders order order_id, code"; $result = mysql_query($query)or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['order_name'];//echo parts need }
Comments
Post a Comment