problème de formulaire php/mysql

foodstyling

Membre enregistré
27 Décembre 2003
9
0
Visiter le site
Bonjour,

Je viens de me lancer dans dans le developement web en php et mysql. Ma base fonctionne, mais je n'arrive pas a connecter mes formulaires à ma base. J'ai du faire une erreur, mais je n'arrive pas à la trouver. Je voudrais donc choisir une categorie à l'aide du menu déroulant et ensuite selectionner un mot clé. Le code fonctonne quand je remplis le le mot clé dans le code, mais la recherche dans la page php ne me rends aucun résultat. Merci d'avance à ce qui pourrait sembler une question bête, mais cela fait quelques jours que je cherche san srésultats. Merci d'avance.

Foodstyling

Voici le code de la page:

<?php //

// include some standard functions
include("receptenconnect.inc.php");
// read form variables ($_POST) and URL variables ($_REQUEST)
// these lines are not neccessary in PHP <= 4.0
$sqlType = array_item($_REQUEST, 'sqlType');
$authID = array_item($_REQUEST, 'authID');
$publID = array_item($_REQUEST, 'publID');
$search = array_item($_REQUEST, 'search');
$page = array_item($_REQUEST, 'page');
$formSearch = array_item($_POST, 'formSearch');
$formSubmitRecept = array_item($_POST, 'formSubmitRecept');
$formSubmitAuteur = array_item($_POST, 'formSubmitAuteur');
$formSubmitIngredienten = array_item($_POST, 'formSubmitIngredienten');
$formSubmitCategorie = array_item($_POST, 'formSubmitCategorie');

// remove urlencoding
$search = urldecode($search);

// remove /
if(get_magic_quotes_gpc()) {
$search = stripslashes($search);
$formSearch = stripslashes($formSearch); }


// builds hierarchical category selection list for a form ----------

function build_categories_select($defaultitem) {
$result =
mysql_query("SELECT catID, catName, hierIndent " .
"FROM categories " .
"ORDER BY hierNr");
echo '<select name="formCategorie" size="1">', "\n";
echo '<option value="none">(zoek)</option>', "\n";
while($row=mysql_fetch_object($result)) {
echo "<option ";
if($defaultitem==$row->catID) echo 'selected="selected" ';
echo "value=\"$row->catID\">",
$row->hierIndent>0 ?
str_repeat("   ", $row->hierIndent) : "",
htmlentities($row->catName), "</option>\n";
}
echo "</select>\n";
mysql_free_result($result);
}

// connect to database
$connID = connect_to_recepten();
?>

<!-- start of html document if no connection error has happened -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />

<body onload="CSScriptInit();" bgcolor="#d3d8eb">
<img src="/recepten/Images site/logo-kopie.jpg" alt="Food & Styling Logo" height="189" width="200" border="0"></a></td>
<td content csheight="111" width="100" height="60" colspan="4" valign="top" align="left" xpos="208">
<div align="center">
<title>FOOD & STYLING: Zoek naar recepten volgens ingredient uit onze database</title>
</head><body>
<h2>Zoek naar recepten uit de Food & Styling database</h2>




<?php
// -------- main code starts here ----------------------------------

// show form
if(empty($sqlType) and empty($formSearch))
{

?>

<form method="POST" action="?php print("$PHP_SELF"); ?>
<p>Zoek naar een recept door een categorie te kiezen</p>
<?php
$result =
mysql_query("SELECT catID, catName, hierIndent " .
"FROM categories " .
"ORDER BY hierNr");
echo '<select name="formCategorie" size="1">', "\n";
echo '<option value="none">(kies)</option>', "\n";
while($row=mysql_fetch_object($result)) {
echo "<option ";
if($defaultitem==$row->catID) echo 'selected="selected" ';
echo "value=\"$row->catID\">",
$row->hierIndent>0 ?
str_repeat("   ", $row->hierIndent) : "",
htmlentities($row->catName), "</option>\n";
}
echo "</select>\n";
mysql_free_result($result);
}
?>

<p> En vul vervolgens een ingredient in:
<input name="ingredienten" size="20" maxlength="20" /></p>

<input type="submit" value="Zoek naar"
name="recept" />
</p>

</form>
<?php


$result = mysql_query("SELECT recept FROM recepten WHERE MATCH(ingredienten) AGAINST('peterselie')");
if (!$result) {
echo "<p>error: ", mysql_errno(),
"; " . htmlentities(mysql_error()), " .</p>\n";
}

// show informations about result
$rows = mysql_num_rows($result);
$cols = mysql_num_fields($result);
echo "<p>\$result = $result\n",
"<br />mysql_num_rows(\$result) = $rows\n",
"<br />mysql_num_cols(\$result) = $cols</p>\n";

// show table
echo "<p>\n";
show_table($result);
echo "</p>\n";

?>















</body></html>