<html>
<head>
<title>Search Questions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$query = '';
$jenis = '';
$searchtype=$HT TP_POST_VARS['searchtype'];
$searchterm=$HT TP_POST_VARS['searchterm'];
$searchterm=tri m($searchterm);
if (!$searchtype || !$searchterm)
{
echo 'You haven\'t entered search details. Please try again';
exit;
}
$searchtype = addslashes($sea rchtype);
$searchterm = addslashes($sea rchterm);
error_reporting (0);
@ $db = mysql_pconnect( 'localhost', 'root', '');
mysql_select_db ('sistem bank soalan');
$jenis = $_GET["jenis"];
if (!$db)
{
echo 'Error: Xle connect pd db..hahaha padan muker!! ;p';
exit;
}
$query = "SELECT * FROM soalan WHERE ".$searchty pe." LIKE '%".$searchterm ."%'" ;
$result = mysql_query($qu ery);
$num_results = mysql_num_rows( $result);
echo '<p>Number of question found: '.$num_results. '</p>';
for ($i=0; $i <$num_results ; $i++)
{
$row = mysql_fetch_arr ay($result);
echo '<p><strong>'.( $i+1).'. No Soalan: ';
echo htmlspecialchar s(stripslashes( $row['id']));
echo'</strong><br />Soalan: ';
echo stripslashes($r ow['soalan']);
echo '<br />Jenis: ';
echo stripslashes($r ow['jenis']);
if ($jenis == "Objektif") {
echo '<br />A: ';
echo stripslashes($r ow['jwpA']);
echo '<br />B: ';
echo stripslashes($r ow['jwpB']);
echo '<br />C: ';
echo stripslashes($r ow['jwpC']);
echo '<br />D: ';
echo stripslashes($r ow['jwpD']);
echo '<br />Jawapan: ';
echo stripslashes($r ow['jwpObj']);
}
else {
echo '<br />Jawapan: ';
echo stripslashes($r ow['jwpSubj']);
}
echo '<br />Aras Kesukaran: ';
echo stripslashes($r ow['araskesukaran']);
echo '<br />Sesi Peperiksaan: ';
echo stripslashes($r ow['sesipeperiksaa n']);
echo '<br />Bahagian: ';
echo stripslashes($r ow['bahagian']);
echo '<br />Add User: ';
echo stripslashes($r ow['adduser']);
echo '</p>';
}
?>
<p align="center"> <font face="BatangChe "><strong> </strong></font></p>
</body>
</html>
NOTES: The above code is for the searching process. In my system there exists two types of question to be searched (means "objektif" and "subjektif" questions). The problem arises when I tried to display the search result. To explain my problem, u may refer the bold-codes. Those code (mainly in bold) do not flows well. Hopefully, anyone can help me to solve this problem.
<head>
<title>Search Questions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$query = '';
$jenis = '';
$searchtype=$HT TP_POST_VARS['searchtype'];
$searchterm=$HT TP_POST_VARS['searchterm'];
$searchterm=tri m($searchterm);
if (!$searchtype || !$searchterm)
{
echo 'You haven\'t entered search details. Please try again';
exit;
}
$searchtype = addslashes($sea rchtype);
$searchterm = addslashes($sea rchterm);
error_reporting (0);
@ $db = mysql_pconnect( 'localhost', 'root', '');
mysql_select_db ('sistem bank soalan');
$jenis = $_GET["jenis"];
if (!$db)
{
echo 'Error: Xle connect pd db..hahaha padan muker!! ;p';
exit;
}
$query = "SELECT * FROM soalan WHERE ".$searchty pe." LIKE '%".$searchterm ."%'" ;
$result = mysql_query($qu ery);
$num_results = mysql_num_rows( $result);
echo '<p>Number of question found: '.$num_results. '</p>';
for ($i=0; $i <$num_results ; $i++)
{
$row = mysql_fetch_arr ay($result);
echo '<p><strong>'.( $i+1).'. No Soalan: ';
echo htmlspecialchar s(stripslashes( $row['id']));
echo'</strong><br />Soalan: ';
echo stripslashes($r ow['soalan']);
echo '<br />Jenis: ';
echo stripslashes($r ow['jenis']);
if ($jenis == "Objektif") {
echo '<br />A: ';
echo stripslashes($r ow['jwpA']);
echo '<br />B: ';
echo stripslashes($r ow['jwpB']);
echo '<br />C: ';
echo stripslashes($r ow['jwpC']);
echo '<br />D: ';
echo stripslashes($r ow['jwpD']);
echo '<br />Jawapan: ';
echo stripslashes($r ow['jwpObj']);
}
else {
echo '<br />Jawapan: ';
echo stripslashes($r ow['jwpSubj']);
}
echo '<br />Aras Kesukaran: ';
echo stripslashes($r ow['araskesukaran']);
echo '<br />Sesi Peperiksaan: ';
echo stripslashes($r ow['sesipeperiksaa n']);
echo '<br />Bahagian: ';
echo stripslashes($r ow['bahagian']);
echo '<br />Add User: ';
echo stripslashes($r ow['adduser']);
echo '</p>';
}
?>
<p align="center"> <font face="BatangChe "><strong> </strong></font></p>
</body>
</html>
NOTES: The above code is for the searching process. In my system there exists two types of question to be searched (means "objektif" and "subjektif" questions). The problem arises when I tried to display the search result. To explain my problem, u may refer the bold-codes. Those code (mainly in bold) do not flows well. Hopefully, anyone can help me to solve this problem.
Comment