Tolong pilih kategori sesuai, jenis posting (pertanyaan atau bukan) dan sertakan tag/topik yang sesuai misal komputer, php, mysql, dll.
Promosi atau posting tidak pada tempatnya akan kami hapus.
Mencantumkan kode program di posting Anda, tolong ikuti aturan yang sesuai, baca http://diskusiweb.com/discussion/39204/aturan-cara-menyisipkan-kode-program-di-diskusiweb

Baca cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

Help,,Script shoping cart tidak jalan..

Mohon petunjuk master...saya coba pasang script shop cart (keranjang belanja),,di localhost xamp script jalan dengan sempurna...tapi setelah di upload ke hosting, script hanya bisa add cart 1 produk, apa scriptnya salah, atau setingan hostnya yg bermasalah...mohon petunjuknya mastah..

ini contoh scriptnya.
..fungsi.php
<?php
function tulisPro() {
   $pro = $_SESSION['pro'];
   if (!$pro) {
      echo "";
   } else {
      $items = explode(',',$pro);
      echo "<div id='alert'><font size='6px'><b><blink>".count($items)."</blink></b></font><p> <input type='button' title='tutup keranjang belanja' class='button play' value='tutup' onclick=\"document.getElementById('alert').style.display = 'none'\" /></div>
<center><a href='t-order.php?billing=ticket+order' class='button play' title='lanjutkan ke kolom order'>chek out</a></center>";  }}
function lihatPro() {
   $no=1;
   $tot='tot';
   $pro = $_SESSION['pro'];
   if ($pro) {
      $items = explode(',',$pro);
      $konten = array();
      foreach ($items as $item) {
         $konten[$item] = (isset($konten[$item])) ? $konten[$item] + 1 : 1;   }
      $output[] = '<form action="?action=update" method="post" name="'.$id.'">';
      $output[] = '<table border="0"cellpadding="0" cellspacing="0" style="" width="255" height="25" bgcolor="">';
      foreach ($konten as $id=>$jumlah) {
         $sql = 'select*from toko where id = '.$id;
         $sq = mysql_query($sql);
         $s = mysql_fetch_array($sq);
         extract($s);
            $output[] = '<tr>';
            $output[] = '<td><font size="1">p'.$no.'</font></td>';
            $output[] = '<td colspan="3">'.$top.''.$name.''.$kode.''.$on.'</td></tr>';
            $output[] = '<tr><td><input type="text" name="qty'.$id.'" value="'.$jumlah.'" size="1" maxlength="2" /></td>';
            $hrg=number_format($harga,0,',','.');
            $output[] = '<td>Rp.'.$hrg.'</td>';
            $hrjum = $harga*$jumlah;
            $to=number_format($hrjum,0,',','.');
            $output[] = '<td><font color="#003366">Rp.'.$to.'</font></td>';
            $output[] = '<td><a href="?action=delete&id='.$id.'"><img src="images/no.png" width="9"height="10" title="Batalkan Belanja '.$judul.''.$nama.''.$kode.'" /></a></td>';
            $no++;
            $tot += $harga*$jumlah;
            $rp=number_format($tot,0,',','.');
            $output[] = '</tr>';
            $output[] = '<tr><td colspan="4"><hr class="border"></td></tr>';
            $output[] = '<tr><td colspan="4" height="17"></td></tr>';  }
      $output[] = '</table>';
       $output[] = '<center><input class="button play" type="submit" value="update belanja" title="update data belanja"/></center>';
       $output[] = '';
       $output[] = '<table  border="0" bordercolor=#4B0082 cellpadding="0" cellspacing="0"  width="" height="14">';
      $output[] = '<tr>';
      $output[] = '<td width="100%" bgcolor="#5F9EAD"><center><h3><font color="#eee">Total Harga Belanja : <br/></font><font color="#66FFff" size="4"><u><b>Rp.'.$rp.'</font></b></u></center></h3</td>';
      $output[] = '<td><img src="images/total.png"  width="35"height="58" /></td</tr></form></table>';
       } else {
      $output[] = '<center><h3>Anda Belum Belanja</h3></center>';
      $output[] = '<a href=""></a>';}
return join('',$output);}
?>
script tampilkan keranjang:

<?php
session_start();
include ('fungsi.php');
$pro = $_SESSION['pro'];
$action = $_GET['action'];
switch ($action) {
   case 'add':
   if ($pro) {
      $pro .= ','.$_GET['id'];
   } else {
      $pro = $_GET['id'];}
   break;
   case 'delete':
   if ($pro) {
      $items = explode(',',$pro);
      $newpro = '';
      foreach ($items as $item) {
         if ($_GET['id'] != $item) {
            if ($newpro != '') {
               $newpro .= ','.$item;
            } else {
               $newpro = $item; }}}
   $pro = $newpro;}
   break;
   case 'update':
   if ($pro) {
   $newpro = '';
   foreach ($_POST as $key=>$value) {
    if (stristr($key,'qty')) {
     $id = str_replace('qty','',$key);
     $items = ($newpro != '') ? explode(',',$newpro) : explode(',',$pro);
     $newpro = '';
     foreach ($items as $item) {
     if ($id != $item) {
     if ($newpro != '') {  $newpro .= ','.$item; } else {
     $newpro = $item;}}}
     for ($i=1;$i<=$value;$i++) {
     if ($newpro != '') {
     $newpro .= ','.$id;} else {
     $newpro = $id;
    }}}}}
   $pro = $newpro;
   break;}
$_SESSION['pro'] = $pro;
echo lihatPro();
?>




Tanggapan

Sign In or Register to comment.