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

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 28-07-2003, 06:25 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
tak jadi jugakkk....

Haii...

thanx a lot di atas bantuan yang telah diberikan dan saya telahpun membaiki coding saya tu sebagaimana yang brother2 semua komen...but poorly, tak keluar jugak...
yang keluar hanya 'Database opened'....please...saya betul2 urgent nie...dah tak lama lagi nak present...pleaseeee....

------------------------------------------------------------------------------------
//find.php
------------------------------------------------------------------------------------

<html>
<head>
<title>searching</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="search.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" value="Cari">
</td>
</tr>
<tr>

<td></td>
</tr>
</table>
</form>
</body>
</html>

------------------------------------------------------------------------------------
search.php
------------------------------------------------------------------------------------
<html>
<head>
</head>
<body>

<?

//MYSQL CONNECTION

$connect = mysql_connect("localhost", "", "");
$open = mysql_select_db("sppjibw",$connect);

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

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

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

//IF SUBMIT BUTTON HAS BEEN PRESSED
if(isset($_POST[‘submit’]))
{
//TAKE VARIABLE OF FORM
$key = $_POST[‘key’];

//SEARCHING
$selec = mysql_query("SELECT result FROM carian WHERE key LIKE ‘%$key%’");
$sql = mysql_query($selec);

//SHOW THE RESULT
echo "Results";
print
$i=1;
while($row = mysql_fetch_array($sql))
{
print $row['result'];
print $row['key'];
$key = $row['key'];
$result = $row['result'];
echo "$i $result ";
$i++;
}
if(!$sql)
{
?>
<script language=’JavaScript’>alert(‘No record found’);
</script>
<?
}
}

?>

</body>
</html>
__________________
Tlot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 28-07-2003, 08:45 PM
nieshaz's Avatar
Novice Webmaster
 
Join Date: Oct 2002
Posts: 22
Rep Power: 0
nieshaz is on a distinguished road
Try ikut tutorial aku nihs ..

CREATE TABLE tablename (
first_name VARCHAR (25),
last_name VARCHAR (25)
);


// Command Untuk Insert Data
// add.html
<html>
<body>
<form action=submitform.php method=GET>

First Name: <input type=text name=first_name size=25 maxlength=25>

Last Name: <input type=text name=last_name size=25 maxlength=25>
<p>
<input type=submit>

</form>
</body>
</html>





//submitform.php
<html>
<body>
<?php

mysql_connect (localhost, username, password);

mysql_select_db (dbname);

mysql_query ("INSERT INTO tablename (first_name, last_name)
VALUES ('$first_name', '$last_name')
");

print ($first_name);

print (" ");

print ($last_name);

print ("<p>");

print ("Thanks for submitting your name.");

?>
</body>
</html>




// Nih untuk search
<html>
<body>

<form action=searchform.php method=GET>

Search For:
<p>
First Name: <input type=text name=first_name size=25 maxlength=25>
<p>
Last Name: <input type=text name=last_name size=25 maxlength=25>
<p>
<input type=submit>

</form>
</body>
</html>




//searchform.php
<html>
<body>

<?php

mysql_connect (localhost, username, password);

mysql_select_db (dbname);

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

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

$result = mysql_query ("SELECT * FROM tablename
WHERE first_name LIKE '$first_name%'
AND last_name LIKE '$last_name%'
");

if ($row = mysql_fetch_array($result)) {

do {
print $row["first_name"];
print (" ");
print $row["last_name"];
print ("<p>");
} while($row = mysql_fetch_array($result));

} else {print "Sorry, no records were found!";}

?>

</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 31-07-2003, 10:18 PM
zaimlah's Avatar
Inspired Webmaster
 
Join Date: Jul 2001
Location: ttdi
Posts: 129
Rep Power: 91
zaimlah is on a distinguished road
Re: tak jadi jugakkk....

jadi ke tak? kalau tak, try this:

Tukarkan this line:
PHP Code:
if($key == "")
{
$key '%';} 
Kepada:
PHP Code:
$key trim($key); 
kalau tak boleh jugak, cakap.
__________________
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
pakai software ape buat gambo jadi mcam ni zball Graphic Design 17 24-04-2007 01:14 AM
Camane nak export flash jadi movie clip ? myravens Website Design 0 12-08-2003 05:07 PM
apa dah jadi????? ergoomo Website Design 2 25-07-2003 01:35 PM
apekah yg mebuatkan database jadi crush ?? full time kille Website Programming 5 01-05-2002 12:49 AM



All times are GMT +8. The time now is 11:00 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