You are here: Help please: just a simple search.. « PHP Programming Language « IT news, forums, messages
Help please: just a simple search..

Posted by ZafT on 08/11/06 05:26

Thanks for any help in advance. I am using this exact same piece of code on
a server running PHP4, but for some reason when I run it on dreamhost using
PHP5, the search does not register and it just lists all items. There's not
much code, so I'm just putting it all in here. The script calls itself.
Can someone please tell me why the
if(!(isset($search)))
is ignored when the form is posted?

Thanks,

Shane


********************************

Search:<form method="post" action="listitem.php">
<input type="text" name="search">
<input type="hidden" name="count" value="20">
<input type="submit" value="search">
</form><BR>


<?php

if(!(isset($search))){
$query="SELECT * FROM item ORDER BY name DESC";
if(!(isset($count))){
$count=20;
}
}

else{
$query="SELECT * FROM item WHERE name LIKE '%$search%' OR description
LIKE '%$search%' ORDER BY name DESC";

if(!(isset($count))){
$count=20;
}
}


$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
$bottom = ($count - 20);


while (($i < $count) && ($i < $num)) {

if ($i < $bottom){
$i++;
}

else{

$name=mysql_result($result,$i,"name");
$location=mysql_result($result,$i,"location");

echo "<LI><A HREF=$location>$name</A>";
echo "</LI> <BR><BR>";


$i++;
}
}


if ($count < $num){

$count = ($count + 20);

if(!(isset($search))){
echo "<A HREF=/listitem.php?count=$count>Next 20</A>";
}
else{
echo "<A HREF=/listitem.php?count=$count&search=$search>Next 20</A>";
}

}
?>

****************************************

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация