require("conn.php");
$sql = "select * from pemohon where kp_baru='$kp';";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
if($row == TRUE)
{
echo $row['kp_baru']; // can display
}
else
{
echo "No KP tiada didalam pangkalan data."; // can't display
}
}
dina85
0
Light Poster
Recommended Answers
Jump to PostWhat is your question?
Jump to Post
$sql = "select * from pemohon where kp_baru='$kp';";
the first semi-colon (;) is un-neccessary.
Tryif($row['kp_baru']=='') { echo "No KP tiada didalam pangkalan data."; } else { echo $row['kp_baru']; }
instead.
Jump to PostI'm not certain, but I think your $row will always be true. It contains an array with the result set from your query.
You need to select a value in each row of your query to check.
Another tip - try and avoidSELECT * FROM ...
Rather select …
All 9 Replies
RoryGren
2
Junior Poster in Training
dina85
0
Light Poster
TonyG_cyprus
36
Newbie Poster
RoryGren
2
Junior Poster in Training
dina85
0
Light Poster
minitauros
151
Junior Poster
Featured Poster
dina85
0
Light Poster
minitauros
151
Junior Poster
Featured Poster
dina85
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.