<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.
2 3605
What do you mean by "do not flows well"?? Does it work or does it not?
And display your code within PHP tags next time, it is almost unreadable this way.
Ronald :cool:
[PHP]
<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: Cannot connect to database!! ;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>
[/PHP]
NOTES: Thanks. I mean it cannot funtion well. it doesnt work..urmm.. okay, let me explain bout it first.. there's a table name SOALAN in my system that contain some field such as id, soalan, jwpA, jwpB, jwpC, jwpD, jwpObj, jwpSubj, jenis(which is type), and many more. I've two types(jenis) of questions(soala n) in my system; which is "subjektif" and "objektif".
For type "Objektif", only jwpA, jwpB, jwpC, jwpD and jwpObj that exist the content (its empty for field jwpSubj for this type), meanwhile for type "Subjektif" , its only exist the content for jwpSubj and empty for the others field(i mean jwpA, jwpB, jwpC, jwpD, jwpObj).
So, when i want to call the question(soalan ) field, i want to make a if-else statement to call the different types of question; which is like in the above coding.. hv i make it clear...? i just don't know why it can't funtion well.. i think its because of the system didn't recognize which type the question would be.. hurm.. anyone.. please help me with this.......
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: LRW |
last post by:
I'm not exactly sure how to even ask the question, and I know my terminology
is not good as I'm a SQL beginner, but, here goes.
I need to find a way to make an if statement within an array...or, the
"while" portion of a recordset.
The best way I can ask is show what I mean.
http://oscarguy.mechphisto.net/awardbrowse.php
If you go there and select an award (like Best Picture), leave the year
field alone, and select YES and submit,...
|
by: Scott Beavers |
last post by:
I'm trying to create a form in Excel to sort from the form and take the data
to another worksheet.
I am very new to this and any help would be appreciated.
I have a value in a cell that will direct what sheet I want the cells copied
to, so I thought I could use an If statement but have been unable to right
the code properly, ie...
If "f2" = 1 Then
Sheets("XX1").Select
|
by: M Wells |
last post by:
Hi All,
Just wondering if anyone can tell me if you can test for multiple
conditions as part of an "IF" statement in T-SQL in SQL Server 2000?
ie something like:
IF @merr = 1 or @merr=2
Begin
SELECT statement
|
by: JS |
last post by:
In this sample code:
if(n==0&&args>1){
for(i=num;args>i+1;i++){
s.length = 0;
opt = document.createElement('OPTION');
s.appendChild(opt);
opt.value = "";
opt.text = "\74-- Vælg --";
}
|
by: Sidney Cadot |
last post by:
Hi all,
In a discussion with Tak-Shing Chan the question came up whether the
as-if rule can cover I/O functions. Basically, he maintains it can, and
I think it doesn't.
Consider two programs:
/*** a.c ***/
| |
by: Stephen |
last post by:
Is there a standard way to remove the warning that a C compiler might
produce from the statement:
if (a = b) {}
I don't want to do:
if ((a = b) != 0) {}
Because my "a = b" is actually contained in a macro that might be used
|
by: Mark Sullivan |
last post by:
When I trace through a csharp program I came to a situation where a certain values
has an "undefined value" as shown in the debugger DbgClr.
I want to check this but the following statements did not recognize this "non"-value
if (type.Particle != Undefined.Value) { ....
or
if (type.Particle != null) { .....
|
by: Jacob.Bruxer |
last post by:
Hi,
I'm pretty new to Visual Basic and programming in general. I want to
know if it's possible to create an If statement that asks if a value is
an integer. If it's an integer it does one thing, if it's a decimal
value it does something else. Something like the following...
If i = integer Then
..... a....
Else
...... b .....
|
by: marsarden |
last post by:
write code like:
int main(void)
{
int a=10;
if(a<20)
{}
}
Compiler ok on dev-cpp . don't we have to add a ";" after if
|
by: vl106 |
last post by:
A static code analysis tool gave me a warning on
if (ptr && ptr->data) { ... }
I assumed the tool doesn't get the "short circuit behaviour" in
the if statement.
But a collegue said it may be the missing check ot ptr against
NULL.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |