You are here: Re: sending flash variable to php file « All PHP « IT news, forums, messages
Re: sending flash variable to php file

Posted by Daedalus.OS on 06/08/05 05:32

Now lets talk php ;-)

>The issue is that whenever someone types something into the
> search, say "Blah," it says that there are zero results found for it, but
> then it shows the "next button."

Here is the problem:
// at this time $s= 0, $limit=10, $pages=0.
// if(!((0+10)/10)==0 && 0 != 1) .... this mean that there is another
page...
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
$news=$s+$limit;
echo "&nbsp;<a href=\"$PHP_SELF?s=$news&search=$var\">Next
&gt;&gt;</a>";
}

You should test if there's any results, if there's none then just skip all
other operations that are needed only if a match was found. Learn to use
if/else to avoid testing things you already know.
---------------
Your have useless code from the very begin:
if (!isset($var))
{
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}

$var will always be set, you set it yourself, @$var = $_GET['search']
even if $_GET['search'] is not a valid array element.

Anyway it looks useless to me to tell visitors they don't entered nothing.
Take a look at google, just hit the search button without feeding it
anything ... it does nothing.

Basic Logic:

if(something was passed to search for){
do your search
if(there is result){
process them
}else{
no result;
}
}else{
nothing was entered ... no big deal, assume they just arrives.
}

I send a small rewrite of your code that solve your problem by applying
this logic. Anyway I didn't rewrite it scratch but only change things that
were broken.


Dae

 

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

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