Het is de bedoeling dat gasten kunnen zoeken op productnaam en de resultaten zullen dan laten zien met welke andere producten het gecombineerd kan worden.
ik heb ajax live search optie.
maak gebruik van database. connectie is gerealiseerd door dreamweaver. (vind ik makkelijk om mee te werken ik weet dat hier de meningen over verdeeld zijn)
als ik de zoekfunctie gebruik krijg ik een foutmelding zie
http://www.kookfreaks.nl/foodpairing/pairing.php
Pairing.php
<?php virtual('/Connections/website.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_website, $website);
$query_itemspairing = "SELECT Naam FROM pairing ORDER BY Naam ASC";
$itemspairing = mysql_query($query_itemspairing, $website) or die(mysql_error());
$row_itemspairing = mysql_fetch_assoc($itemspairing);
$totalRows_itemspairing = mysql_num_rows($itemspairing);
?>
<html>
<head>
<script type="text/javascript">
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","foodpairing.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select name="Producten" id="Producten" onChange="showUser(this.value)">
<?php
do {
?>
<option value="<?php echo $row_itemspairing['Naam']?>"<?php if (!(strcmp($row_itemspairing['Naam'], $row_itemspairing['Naam']))) {echo "selected=\"selected\"";} ?>><?php echo $row_itemspairing['Naam']?></option>
<?php
} while ($row_itemspairing = mysql_fetch_assoc($itemspairing));
$rows = mysql_num_rows($itemspairing);
if($rows > 0) {
mysql_data_seek($itemspairing, 0);
$row_itemspairing = mysql_fetch_assoc($itemspairing);
}
?>
</select>
</form>
<br />
<div id="txtHint"><b>Resultaten worden hier weer gegeven.</b></div>
</body>
</html>
<?php
mysql_free_result($itemspairing);
?>
foodpairing.php
[code]
<?php virtual('/Connections/website.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_website, $website);
$query_zoeken = "SELECT * FROM pairing ORDER BY id ASC";
$zoeken = mysql_query($query_zoeken, $website) or die(mysql_error());
$row_zoeken = mysql_fetch_assoc($zoeken);
$totalRows_zoeken = mysql_num_rows($zoeken);mysql_select_db($database_website, $website);
$query_zoeken = "SELECT Naam FROM pairing ORDER BY Naam ASC";
$zoeken = mysql_query($query_zoeken, $website) or die(mysql_error());
$row_zoeken = mysql_fetch_assoc($zoeken);
$totalRows_zoeken = mysql_num_rows($zoeken);
echo "<table border='1'>
<tr>
<th>product:</th>
<th>kruiden:</th>
<th>fruitsoorten:</th>
<th>zuivel producten:</th>
<th>vlees soorten:</th>
<th>vis soorten:</th>
<th>Overige:<th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td width=200>" . $row['Naam'] . "</td>";
echo "<td width=200>" . $row['Kruiden'] . "</td>";
echo "<td width=200>" . $row['Fruit'] . "</td>";
echo "<td width=200>" . $row['Zuivel '] . "</td>";
echo "<td width=200>" . $row['Vlees'] . "</td>";
echo "<td width=200>" . $row['Vis'] . "</td>";
echo "<td width=200>" . $row['Overig'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_free_result($zoeken);
?>
[code]
result:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/id438/domains/kookfreaks.nl/public_html/foodpairing/foodpairing.php on line 0
wat doe ik verkeerd.
ik kom er niet uit. ben nog niet zo erg ervaren als jullie met dit soort dingen.