Script search form
Scris: Joi Noi 10, 2011
imi zice si mie cineva unde gresec aici:
e facut dupa un tutorial de pe youtube...
Problema e ca nu imi afiseaza nimic
imi da eroarea:
Notice: Undefined variable: i in C:\wamp\www\evi.net\cauta-anunt.php on line 19
Multumesc
Cod: Selectaţi tot
<html>
<head>
</head>
<body>
<center>
<h1>evi.net search</h1>
<form action="cauta-anunt.php" method="get">
<input type="text" name="k" size="50" value="<?php echo $_GET["k"]; ?>" />
<input type="submit" value="submit">
</form>
<hr />
<?php
$k = $_GET["k"];
$terms = explode(" ", $k);
$query = "SELECT * FROM anunturi WHERE ";
foreach ($terms as $each){
$i++;
if ($i == 1)
$query .= "textanunt LIKE '$each' ";
else
$query .= "OR textanunt LIKE '$each' ";
}
//conectarea la db
include "connect_to_mysql.php";
$query = mysql_query($query);
$numrows = mysql_num_rows($query)or die(mysql_error());
if ($numrows > 0){
while ($row = mysql_fetch_assoc($query)){
$id = $row['id'];
$titluanunt = $row['titluanut'];
$textanunt = $row['textanunt'];
echo "<h2><a href='anunt.php?id=$id'>$titluanunt</a></h2>
$textanunt<br /><br />";
}
}
else echo "Nici un rezultat pentru \"<br>$k</b>\"";
?>
</body>
</html>
Problema e ca nu imi afiseaza nimic
imi da eroarea:
Notice: Undefined variable: i in C:\wamp\www\evi.net\cauta-anunt.php on line 19
Multumesc