Op zoek naar een oplossing!

Status
Niet open voor verdere reacties.

anarkyandy

Gebruiker
Lid geworden
17 aug 2010
Berichten
14
Beste mensen ... ik heb een vraag?

Ik heb namelijk een php script nodig dat de volgende doet ...

Zoek een product in een db (het product is een nummer) ... voeg aan dat product 3 teksten ... zet het product in een winkelwagen met de productnummer,omschrijving & prijs (dat zijn waarden in de db) en de 3 teksten die zijn ingevoeld door de klant.

Ik heb al een script die het doet voor de product zoeken en toevoegen in de winkelwagen. De enige probleem zijn de 3 teksten die ik niet aan de product kan koppelen.
De script die ik gebruikt heb is hier te vinden: http://v3.thewatchmakerproject.com/journal/276/building-a-simple-php-shopping-cart

Weet iemand een goede script hiervoor (of een aanpassing aan de script die ik al gebruik).... het zal mijn leven reden ...

thx to all

ANDY
 
Laatst bewerkt:
Wat is je budget? Dit klinkt als iets dat buiten het niveau van een kant-en-klaar scriptje ligt dus je zult of je hele script om moeten gooien, of zelf moeten programmeren, of iemand moeten inhuren om het doen... ;)
 
codes

De volgorde is als volgd:

eerst: SearchTypeplaat.php
dan: Winkelwagentype.php (bij deze moet dan functionstype.inc.php op werken)

dit is de functionstype.inc.php

PHP:
function showCart1() {		
	global $db;	
	$text = $_POST['text'];
	$rev = $_POST['rev'];
	$serie = $_POST['serie'];
	$cart1 = $_SESSION['cart1'];
	if ($cart1) {
		$items = explode(',',$cart1);
		$contents = array();
		foreach ($items as $item) {
			$contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;
		}
		$output[] = '<form action="Winkelwagentype.php?action=update" method="post" id="cart1">';		
		$output[] = '<table width="800px">';
		foreach ($contents as $id=>$qty){
			 
			 foreach ($contents1 as $text){
				 foreach ($contents1 as $rev){
					 foreach ($contents1 as $serie){
			$sql = 'SELECT * FROM typeplaatjes WHERE id = '.$id;
			$result = $db->query($sql);
			$row = $result->fetch();
			extract($row);
			
			$output[] = '<tr>';
			$output[] = '<td width="50px"><a href="Winkelwagentype.php?action=delete&id='.$id.'" class="r">Verwijder</a></td>';
			$output[] = '<td width="100px">'.$typenr.'</td>';
			$output[] = '<td width="100px">'.$omschrijving.'</td>';
			$output[] = '<td width="100px">'.$text.'</td>';
			$output[] = '<td width="80px">'.$rev.'</td>';
			$output[] = '<td width="80px">'.$serie.'</td>';
			$output[] = '<td width="80px"><input type="text" name="qty'.$id.'" value="'.$qty.'" size="8" maxlength="5" /></td>';
			$total += $prijs * $qty;
			$output[] = '</tr>';
					 }
				 }
			 }
		}
		$output[] = '</table>';
		$output[] = '<div><button type="submit">Vernieuwen</button></div>';
		$output[] = '</form>';
		
		$output[] = '<form action="../Winkelwagentype.php?action=update4" method="post" id="cart1">';
		$output[] = '<p><h4>Productieorder Nummer</h4></p><input type="text" name="prodordernr'.$cart1.'" value="'.$prodordernr.'" size="10" maxlength="10" />';
		$output[] = '</form>';
	}
	else {
		$output[] = '<p>Winkelwagen is leeg.</p>';
	}
	return join('',$output);
}

Dit is de Winkelwagentype.php

PHP:
<?php
// Include MySQL class
require_once('inc/mysql.class.php');
// Include database connection
require_once('inc/globaltype.inc.php');
// Include functions
require_once('inc/functionstype.inc.php');
// Start the session
session_start();
// Process actions
$cart1 = $_SESSION['cart1'];
$action = $_GET['action'];			
switch ($action) {
	case 'add':		
		if ($cart1) {
			$cart1 .= ','.$_GET['id'];
		} else {
			$cart1 = $_GET['id'];
		}
		break;
	case 'delete':
		if ($cart1) {
			$items = explode(',',$cart1);
			$newcart1 = '';
			foreach ($items as $item) {
				if ($_GET['id'] != $item) {
					if ($newcart1 != '') {
						$newcart1 .= ','.$item;
					} else {
						$newcart1 = $item;
					}
				}
			}
			$cart1 = $newcart1;
		}
		break;	
	case 'update':
	if ($cart1) {
		$newcart1 = '';
		foreach ($_POST as $key=>$value) {
			if (stristr($key,'qty')) {
				$id = str_replace('qty','',$key);
				$items = ($newcart1 != '') ? explode(',',$newcart1) : explode(',',$cart1);
				$newcart1 = '';
				foreach ($items as $item) {
					if ($id != $item) {
						if ($newcart1 != '') {
							$newcart1 .= ','.$item;
						} else {
							$newcart1 = $item;
						}
					}
				}
				for ($i=1;$i<=$value;$i++) {
					if ($newcart1 != '') {
						$newcart1 .= ','.$id;
					} else {
						$newcart1 = $id;
					}
				}
			}
		}
	}
	$cart1 = $newcart1;
	break;
}
$_SESSION['cart1'] = $cart1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MultiWerkplaatsHJ</title>
<style type="text/css">
body {
	background-image: url(Images/background.png);
	background-repeat: no-repeat;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-attachment: scroll;
	background-position: top center;
}
.cushycms {
	height: 603px;
	width: 503px;
	position: relative;
	font-family: "Times New Roman", Times, serif;
	font-style: normal;
	line-height: normal;
	font-weight: normal;
}
.cushycms h1 {
	font-size: 24px;
}
.cushycms {
	font-size: 14px;
	position: relative;
	padding-top: 80px;
	padding-bottom: 80px;
	padding-left: 0px;
	width: 820px;
}
</style>
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
<script type="text/javascript">
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
</head>

<body onload="MM_preloadImages('Images/homeb2.png','Images/processenb2.png','Images/productenb2.png','Images/overonsb2.png','Images/contactb2.png')">
<div align="center">
  <p><img src="Images/Header.png" alt="" name="Header" width="886" height="181" hspace="0" vspace="0" border="0" align="middle" /></p>
</div>
<div align="center"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Homeb','','Images/homeb2.png',1)"><img src="Images/homeb.png" alt="Home" name="Homeb" width="180" height="53" border="0" id="Homeb" /></a><a href="Producten.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Processen','','Images/productenb2.png',1)"><img src="Images/productenb.png" alt="Processen" name="Processen" width="178" height="53" border="0" id="Processen" /></a><a href="Overons.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Producten','','Images/overonsb2.png',1)"><img src="Images/overonsb.png" alt="Producten" name="Producten" width="178" height="53" border="0" id="Producten" /></a><a href="Contact.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('OverOns','','Images/contactb2.png',1)"><img src="Images/contactb.png" name="OverOns" width="178" height="53" border="0" id="OverOns" /></a><a href="Inloggen.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Contact','','Images/Inloggenb2.png',1)"><img src="Images/Inloggenb.png" alt="Contact" name="Contact" width="180" height="53" border="0" id="Contact" /></a> </div>
<div style="word-spacing: normal; letter-spacing: normal; color: #000; line-height: normal; font-style: normal; font-size: 18px; font-family: 'Times New Roman', Times, serif; position: relative; background-position: top center; background-repeat: no-repeat; background-attachment: scroll; background-image:url(Images/SpaceAchter.png); font-weight: bold;" align="center" title="Welkom">
  <div class="cushycms">
<?php
	echo writeShoppingCart1();			
			?>
			<table width="800px">
			<tr>
			<td width="50px"> </td>
			<td width="100px"><h4>Productnummer<h4></td>
			<td width="100px"><h4>Omschrijving<h4></td>
			<td width="100px"><h4>Text op Plaat<h4></td>
            <td width="80px"><h4>Revisie<h4></td>
            <td width="80px"><h4>Serien Nummer<h4></td>
			<td width="80px"><h4>Aantal<h4></td>
			</table>
<?php
			$text = $_POST['text'];
			$rev = $_POST['rev'];
			$serie = $_POST['serie'];
			
			echo showCart1();

?> 
&nbsp;
<form action="bestellentype.php" method="get">
	<input type="submit" id="button1" name="button1" value="Bevestig bestelling!"/>
</form>

<p><a href="Succes.php">Bestel nog een product</a></p>
  </div>
</div>
</body>



</html>

en dit is de zoekpagina, ofwel SearchTypeplaat.php

PHP:
<?php
// Include MySQL class
require_once('inc/mysql.class.php');
// Include database connection
require_once('inc/globaltype.inc.php');
// Include functions
require_once('inc/functionstype.inc.php');
// Start the session
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MultiWerkplaatsHJ</title>
<style type="text/css">
body {
	background-image: url(Images/background.png);
	background-repeat: no-repeat;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-attachment: scroll;
	background-position: top center;
}
.cushycms {
	height: 603px;
	width: 503px;
	position: relative;
	font-family: "Times New Roman", Times, serif;
	font-style: normal;
	line-height: normal;
	font-weight: normal;
}
.cushycms h1 {
	font-size: 24px;
}
.cushycms {
	font-size: 14px;
	position: relative;
	padding-top: 80px;
	padding-bottom: 80px;
	padding-left: 0px;
	width: 820px;
}
</style>
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>

<script type="text/javascript">
function submitform()
{
    document.forms["myform"].submit();
}
</script>

<script type="text/javascript">
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
</head>

<body onload="MM_preloadImages('Images/homeb2.png','Images/processenb2.png','Images/productenb2.png','Images/overonsb2.png','Images/contactb2.png')">
<div align="center">
  <p><img src="Images/Header.png" alt="" name="Header" width="886" height="181" hspace="0" vspace="0" border="0" align="middle" /></p>
</div>
<div align="center"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Homeb','','Images/homeb2.png',1)"><img src="Images/homeb.png" alt="Home" name="Homeb" width="180" height="53" border="0" id="Homeb" /></a><a href="Producten.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Processen','','Images/productenb2.png',1)"><img src="Images/productenb.png" alt="Processen" name="Processen" width="178" height="53" border="0" id="Processen" /></a><a href="Overons.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Producten','','Images/overonsb2.png',1)"><img src="Images/overonsb.png" alt="Producten" name="Producten" width="178" height="53" border="0" id="Producten" /></a><a href="Contact.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('OverOns','','Images/contactb2.png',1)"><img src="Images/contactb.png" name="OverOns" width="178" height="53" border="0" id="OverOns" /></a><a href="Inloggen.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Contact','','Images/Inloggenb2.png',1)"><img src="Images/Inloggenb.png" alt="Contact" name="Contact" width="180" height="53" border="0" id="Contact" /></a> </div>
<div style="word-spacing: normal; letter-spacing: normal; color: #000; line-height: normal; font-style: normal; font-size: 18px; font-family: 'Times New Roman', Times, serif; position: relative; background-position: top center; background-repeat: no-repeat; background-attachment: scroll; background-image:url(Images/SpaceAchter.png); font-weight: bold;" align="center" title="Welkom">
  <div class="cushycms">
   <div align="left">
     <?php
	
	
	echo writeShoppingCart1();
	
	//get data
	$button = $_GET ['submit'];
	$Search = $_GET ['Search'];
		
	if (!$button)
		echo "U heeft niets ingevult!!";
	else
	{
		if (strlen($Search)<=2)
			echo "U heeft niet het voledige nummer ingevult";
		else
		{					
					//explode our search term
					$search_exploded = explode(" ", $Search);
										
					foreach($search_exploded as $search_each)
					{
						//construct query
						$x++;
						if ($x==1)
							$construct .= " typenr LIKE '%$search_each%'";
						else						
							$construct .= " OR typenr LIKE '%$search_each%'";
					}
			
			//echo out construct
			
			$construct = "SELECT * FROM typeplaatjes WHERE $construct";
			$run = mysql_query($construct);
			
			$foundnum = mysql_num_rows($run);
			
			if ($foundnum==0)
				echo "Er zijn geen producten met de naam <b>$Search</b>";
			else
			{
				echo "$foundnum product(en) gevonden!<p>";
				
				while ($runrows = mysql_fetch_assoc($run))
				{
					//get data						
					$output[] = '<table align="center" width="800px" border="1">';
						$output[] = '<tr>';	
						$output[] = '<td align="center"><h2>Typeplaatje</h2><h3>'.$runrows['typenr'].'</h3></td>';					
						$output[] = '<td align="center"><h2>Omschrijving</h2><h3>' .$runrows['omschrijving'].'</h3></td>';				
						$output[] = '<td align="center"><h2>Prijs(per stuck)</h2><h3>&euro;' .$runrows['prijs'].'</h3></td>';
					$output[] = '</table>';
					$output[] = '<table align="center" width="800px" border="1">';
					$output[] = '<form id="myform" method="post" action="Winkelwagentype.php?action=add&id='.$runrows['id'].'">';
						$output[] = '<td align="center"><h2>Text op plaat</h2><input type="text" name="text" size="20"/></td>';
						$output[] = '<td align="center"><h2>RevisieNummer</h2><input type="text" name="rev" size="20"/></td>';
						$output[] = '<td align="center"><h2>SerieNummer</h2><input type="text" name="serie" size="20"/></td>';						
						$output[] = '</tr>';
					$output[] = '</table>';
					$output[] = '</form>';
						$output[] =	'<tr>';
						$output[] = '<div align="center"><br/><a href="javascript: submitform()">Voeg toe aan Winkelwagen<a/></div>';
						$output[] = '</tr>';
					
					echo join('',$output);
				}
			}
		}
	}
	?>
   	<p>&nbsp;</p>
	<p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
  </div>
</div>
</body>


</html>
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan