Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 27-07-2003, 11:02 PM
miss_tlot's Avatar
Novice Webmaster
 
Join Date: Jun 2003
Location: Terengganu
Posts: 10
Rep Power: 0
miss_tlot is on a distinguished road
coding searching yang tak jalan

hai...

baru-baru nie saya ada tanya pasal serching...dan ada sorang brother minta saya letak saya punya coding untu ditengok-tengokkan, so nie coding saya. Coding saya nie tak display apa-apa pun, kosong terus...tak jumpa apa yang saya cari walaupun dalam database ada data tu..so, sesapa yang baik hati tu, harap dapat tolong bagitau apa yang kurang atau lebih yek! TQ

//cari.php
------------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>searching</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="cari_2.php." method="post">
<table width="414" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="153" height="24" valign="top">
<input name=key type=text>
</td>
<td width="144" valign="top">&nbsp; </td>
<td width="117" valign="top">
<input name="submit" type="submit"></td>
</tr>
<tr>
<td height="19" valign="top">*katakunci</td>
<td></td>
</tr>
</table>
</form>
</body>
</html>
------------------------------------------------------------------------------------
//cari_2.php
<?

/* mysql connection */
$host = "lacalhost";
$user = "";
$pass = "";
$db = "sppjibw";
import_request_variables('p', 'form_');
$connect = mysql_connect("localhost","","");
$open = mysql_select_db("sppjibw",$connect);

$key = "$form_key";

if($key=="")
{$key='%';}

if($result=="")
{$result='%';}

/*
if($open) {
echo "Database opened";
} else {
echo mysql_error();
}
*/

if(isset($_POST[‘submit’])) { //if submit button has been pressed
//take variable of form
$key = $_POST[‘key’];
//searching
$selec = mysql_query("SELECT result FROM carian WHERE key LIKE ‘%key%’,$conn");


$sql = mysql_query($selec);
//show the results
echo "Results";
print
$i=1;
while($row = mysql_fetch_array($sql))
{
print $row["result"];
print $row["key"];
$katakunci = $row["key"];
$hasil = $row["result"];
echo "$i $result ";
$i++;
}
if(!$sql) {
?><script language=’JavaScript’>alert(‘No record found’); </script><?
}
}
?>
__________________
Tlot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 28-07-2003, 12:17 AM
zaimlah's Avatar
Inspired Webmaster
 
Join Date: Jul 2001
Location: ttdi
Posts: 129
Rep Power: 91
zaimlah is on a distinguished road
PHP Code:
....
if(isset(
$_POST'submit'])) { //if submit button has been pressed
//take variable of form
$key $_POST['key'];
//searching
$selec mysql_query("SELECT result FROM carian WHERE key LIKE '%$key%',$conn"); //<--- sini dia, '%$key%' bukan '%key%'
.... 
(i think so)
__________________
blog:zaim_bakar_blog | biz:box
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 28-07-2003, 12:18 AM
mysticmind's Avatar
Super Moderator
 
Join Date: Jun 2001
Location: Mystic Kingdoms
Posts: 2,637
Rep Power: 142
mysticmind will become famous soon enough mysticmind will become famous soon enough
Send a message via Yahoo to mysticmind
PHP Code:
/* mysql connection */
$host "lacalhost"
lacalhost?
__________________
Personal's Blog! - Malaysian Artist!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 28-07-2003, 12:20 AM
zaimlah's Avatar
Inspired Webmaster
 
Join Date: Jul 2001
Location: ttdi
Posts: 129
Rep Power: 91
zaimlah is on a distinguished road
one more thing, dia tak keluar apa-apa, atau ada keluar MySQL error? sebab line yg ni agak pelik sikit:

Code:
$selec = mysql_query("SELECT result FROM carian WHERE key LIKE ‘%key%’,$conn");
apa guna, dan dari mana datangnya '$conn' ??


ditambah kemudian (edit post):

see next post
__________________
blog:zaim_bakar_blog | biz:box
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 28-07-2003, 12:31 AM
zaimlah's Avatar
Inspired Webmaster
 
Join Date: Jul 2001
Location: ttdi
Posts: 129
Rep Power: 91
zaimlah is on a distinguished road
mungkin macam ni:

Code:
$selec = mysql_query("SELECT result FROM carian WHERE key LIKE '%$key%'",$connect");
variable yg sebenar ialah $connect, bukan $conn ... dan mesti di luar sql query sebagai argument ke-2....
__________________
blog:zaim_bakar_blog | biz:box
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching for JOBS? JobListed Websites Review and Suggestion 0 17-05-2005 04:58 PM
Coldfusion scheduler tak jalan shakker Website Programming 3 29-03-2005 09:46 AM
searching..... nurulmajdi Website Programming 1 01-03-2004 06:15 PM
kenapa butang menu web site aku tak mau jalan... kerenggeforum Website Design 2 15-08-2003 12:45 PM
mintak bantuan...flash form ke php..tak jalan seman_t Website Programming 1 10-07-2002 06:38 PM



All times are GMT +8. The time now is 10:12 AM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59