form select

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wasis85
Forum Newbie
Posts: 2
Joined: Mon Sep 06, 2010 10:08 pm

form select

Post by wasis85 »

Hi guys, i need to modify this below script that i want to insert sql query to my form select so that i can display option based on my database count, i've tried to use for or foreach but it still doesn't working, this script is not main but it very essential to help the main program (shopping cart), can anybody help me? please guys i need it immediately..!
sorry for my bad english..
:(
<?php

define('INCLUDE_CHECK',1);
require "../mysql.php";

if(!$_POST['img']) die("There is no such product!");

$img=mysql_real_escape_string(end(explode('/',$_POST['img'])));
$row=mysql_fetch_assoc(mysql_query("SELECT * FROM tabel_barang WHERE gambar_barang='".$img."' and JUMLAH_BARANG>=0"));

$jumlah_stok = mysql_query("select count(*) as jumlah_barang from tabel_barang");
$info = mysql_fetch_array($jumlah_stok);
$jumlah_jual = $info["jumlah_barang"];
$jo = $jumlah_jual;
echo '{status:1,id:'.$row['ID_BARANG'].',price:'.$row['HARGA_BARANG'].',txt:\'\
\
<table width="100%" id="table_'.$row['ID_BARANG'].'">\
<tr>\
<td width="60%">'.$row['NAMA_BARANG'].'</td>\
<td width="10%">$'.$row['HARGA_BARANG'].'</td>\
<td width="15%"><select name="'.$row['ID_BARANG'].'_cnt" id="'.$row['ID_BARANG'].'_cnt" onchange="change('.$row['ID_BARANG'].');">\
<option value="1">1</option>\
<option value="2">2</option>\
<option value="3">3</option></select>\
\
</td>
\
<td width="15%"><a href="#" onclick="remove('.$row['ID_BARANG'].');return false;" class="remove">remove</a></td>\
</tr>\
</table>\'}';

?>
Post Reply