You are here: Re: php form info... « PHP Programming Language « IT news, forums, messages
Re: php form info...

Posted by starbuck on 10/21/05 20:40

<pre>

below is the code that i'm using:
i added the echo's above the mysql query
just to see what is actually being assigned to the $where_condition.
it seems that when $search_value is given the 'info' string, the
$where_condition never gets set at all
even though the else statement should set it.
If the users enters a number, the query tries to match that number by
looking for it in the school_number
column. If a user types some text, it tries to match it up in the name
and aka fields.


$search_value = $_POST["textfield"];

if (!$search_value) {
echo("<p>You must type something in the search box to get results: "
.. mysql_error() . "</p>");
exit();
}

if ($search_value != 0) {
if ($search_value / $search_value == 1) {
$where_condition = "schools.school_number = '$search_value'";
}
}
else {
$where_condition = "schools.name like '$search_value%' OR
schools.aka like '$search_value%' OR schools.name like
'%$search_value%' OR schools.aka like '%$search_value%'";
}

echo $search_value;
echo "<br>SELECT *, ceiling(read_scores/20) as read_stars,
ceiling(math_scores/20) as math_stars FROM schools WHERE " .
$where_condition . " ORDER BY borough ASC";

$result = db_query("SELECT *, ceiling(read_scores/20) as read_stars,
ceiling(math_scores/20) as math_stars FROM schools WHERE " .
$where_condition . " ORDER BY borough ASC", $link);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
</pre>

 

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

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