sy mintak tlg ssape yg blh bantu sy dlm web nie.plzzzzzzzzzzzzzzz....
+8
JebatDerhaka
BasicCX
kaizen
Arman
FryShadow
Haibara Ai
slaughters
syira86
12 posters
Coding search php mysql
syira86- Ahli Baharu
- Gender : Female Number of posts : 108
Age : 38
Location : kedah
Job/hobbies : explore
Registration date : 04/03/2009
- Post n°1
Coding search php mysql
salam..sy harap sgt otai2 dpt tlg sy..sy sdg bina web tntg seminar...mslhnye sy xdpt wat utk search fuction...cthnye user akn select date,time n room n dorg akn search utk dptkn full detail tntag seminar megikut ape yg dipilih...
sy mintak tlg ssape yg blh bantu sy dlm web nie.plzzzzzzzzzzzzzzz....
sy mintak tlg ssape yg blh bantu sy dlm web nie.plzzzzzzzzzzzzzzz....
slaughters- PDP Moderator
- Gender : Male Number of posts : 213
Location : Selangor
Registration date : 13/02/2009
- Post n°2
Re: Coding search php mysql
aku pelik a, nape aku takleh nak movekan topic ni ?
Haibara Ai- Ahli Baharu
- Gender : Female Number of posts : 85
Age : 37
Location : Wangsa Maju
Job/hobbies : Bermain dengan coding
Registration date : 12/02/2009
- Post n°3
Re: Coding search php mysql
$sql = "SELECT * FROM namatable WHERE namafield
LIKE '%".$_POST ["txtsearch"]."%' ";
$result = mysql_query($sql);
if (!result){
echo "query failed ". mysql_error();
exit;
LIKE '%".$_POST ["txtsearch"]."%' ";
$result = mysql_query($sql);
if (!result){
echo "query failed ". mysql_error();
exit;
Haibara Ai- Ahli Baharu
- Gender : Female Number of posts : 85
Age : 37
Location : Wangsa Maju
Job/hobbies : Bermain dengan coding
Registration date : 12/02/2009
- Post n°4
Re: Coding search php mysql
kat mana yg tak jadi tu syira?..reply dalam ni la..takyah reply kot pm.. nanti senang user lain dapat bantu sekali..
cube try coding ni lak.. juz tukar yg di bold kan tu je
----------------------------------------------------------------------
<?php
$connectdb = mysql_connect ("localhost", "root", "");
if (!$connectdb) {
echo "unable to connect to DB: ".mysql_error();
exit;
}
if (!mysql_select_db("namaDatabase")) {
echo "unable to select mydbname: " .mysql_error();
exit;
}
echo "
<table cellspacing='0' cellpadding='3'><tr><td>
<br>
<form method='POST' name='frmsearch' action='namaFileini.php'>
<input type='text' name='txtsearch' size='40'>
<input type='submit' name='cmdsearch' value='search'>
</form>
</td></tr></table>";
$sql = "SELECT * FROM namaTable WHERE namaField
LIKE '%".$_POST ["txtsearch"]."%' ";
$result = mysql_query($sql);
if (!result){
echo "query failed ". mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "<table cellspacing= '0' cellpadding='3'><tr><td>";
echo "no rows found, nothing to print so am existing";
echo "</tr></td></table>";
exit;
}
echo "<table width='640' cellspacing='0' cellpadding='3'>";
echo "<tr>
<td width='10%' bgcolor='#c9c9c9'><b>namaField1</b></td>
<td width='60%' bgcolor='#c9c9c9'><b>namaField2</b></td>
</tr>";
while ($_POST = mysql_fetch_array($result)) {
if ($bgcolor == '#f1f1f1') {$bgcolor='#ffffff';}
else {$bgcolor='#f1f1f1';}
echo "
<tr>
<td width='10%' bgcolor='$bgcolor'>".$_POST["namaField1"]."</td>
<td width='10%' bgcolor='$bgcolor'>".$_POST["namaField2"]."</td>
</tr>";
}
echo "</table>";
mysql_free_result($result);
?>
cube try coding ni lak.. juz tukar yg di bold kan tu je
----------------------------------------------------------------------
<?php
$connectdb = mysql_connect ("localhost", "root", "");
if (!$connectdb) {
echo "unable to connect to DB: ".mysql_error();
exit;
}
if (!mysql_select_db("namaDatabase")) {
echo "unable to select mydbname: " .mysql_error();
exit;
}
echo "
<table cellspacing='0' cellpadding='3'><tr><td>
<br>
<form method='POST' name='frmsearch' action='namaFileini.php'>
<input type='text' name='txtsearch' size='40'>
<input type='submit' name='cmdsearch' value='search'>
</form>
</td></tr></table>";
$sql = "SELECT * FROM namaTable WHERE namaField
LIKE '%".$_POST ["txtsearch"]."%' ";
$result = mysql_query($sql);
if (!result){
echo "query failed ". mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "<table cellspacing= '0' cellpadding='3'><tr><td>";
echo "no rows found, nothing to print so am existing";
echo "</tr></td></table>";
exit;
}
echo "<table width='640' cellspacing='0' cellpadding='3'>";
echo "<tr>
<td width='10%' bgcolor='#c9c9c9'><b>namaField1</b></td>
<td width='60%' bgcolor='#c9c9c9'><b>namaField2</b></td>
</tr>";
while ($_POST = mysql_fetch_array($result)) {
if ($bgcolor == '#f1f1f1') {$bgcolor='#ffffff';}
else {$bgcolor='#f1f1f1';}
echo "
<tr>
<td width='10%' bgcolor='$bgcolor'>".$_POST["namaField1"]."</td>
<td width='10%' bgcolor='$bgcolor'>".$_POST["namaField2"]."</td>
</tr>";
}
echo "</table>";
mysql_free_result($result);
?>
syira86- Ahli Baharu
- Gender : Female Number of posts : 108
Age : 38
Location : kedah
Job/hobbies : explore
Registration date : 04/03/2009
- Post n°5
Re: Coding search php mysql
thnx ..sy imterface mcm nie la
slaughters- PDP Moderator
- Gender : Male Number of posts : 213
Location : Selangor
Registration date : 13/02/2009
- Post n°6
Re: Coding search php mysql
enjoy you conference day ?
syira86- Ahli Baharu
- Gender : Female Number of posts : 108
Age : 38
Location : kedah
Job/hobbies : explore
Registration date : 04/03/2009
- Post n°7
Re: Coding search php mysql
salam..slh ker tls enjoy ur conference day???..if slh tlg ajar kn sy...btl2 nk tau cmne nk wat coding utk function search nie...plzzz
FryShadow- Ahli Baharu
- Number of posts : 101
Registration date : 20/02/2009
- Post n°8
Re: Coding search php mysql
Suppose "Enjoy your conference day"
Arman- Ahli Baharu
- Number of posts : 3
Registration date : 09/03/2009
- Post n°9
Re: Coding search php mysql
ni guna HTML atau PHP? sbb tgk kat link tu bukan kat localhost dan berakhir dgn .HTML
klu HTML mmg tak boleh guna coding PHP dan tak boleh berkomunikasi dgn database mysql.
klu HTML mmg tak boleh guna coding PHP dan tak boleh berkomunikasi dgn database mysql.
kaizen- Ahli Baharu
- Number of posts : 11
Registration date : 05/03/2009
- Post n°10
Re: Coding search php mysql
syira ... jika part php lain awak boleh buat...
so saya rasa tiada masalah untuk buat search..
yg penting ia adalah part sql statement..
try main2 sql query kt phpmyadmin.. google mysql like
keyword like.. confirm ada bermacam2 site akan akan ajar how to use " like "
jika date contohnya event.date > '$date'
so saya rasa tiada masalah untuk buat search..
yg penting ia adalah part sql statement..
try main2 sql query kt phpmyadmin.. google mysql like
keyword like.. confirm ada bermacam2 site akan akan ajar how to use " like "
jika date contohnya event.date > '$date'
BasicCX- Ahli Baharu
- Gender : Male Number of posts : 230
Registration date : 25/02/2009
- Post n°11
Re: Coding search php mysql
Tak kira akhir extension .html @ .php boleh panggil database.
Kalau guna HTML boleh guna form untuk post dan retrieve data.
Kalau guna HTML boleh guna form untuk post dan retrieve data.
syira86- Ahli Baharu
- Gender : Female Number of posts : 108
Age : 38
Location : kedah
Job/hobbies : explore
Registration date : 04/03/2009
- Post n°12
Re: Coding search php mysql
salam n thnx cz reply..page 2 mmg dlm php...2 sy bg 2 dlm juz mula2 sy wat...btl2 sy xtau nk wat...dah surf kt internet xde mcm sy..if ade pn coding xbtl pulak...sy pn xtau nk wat ape lg...
syira86- Ahli Baharu
- Gender : Female Number of posts : 108
Age : 38
Location : kedah
Job/hobbies : explore
Registration date : 04/03/2009
- Post n°13
Re: Coding search php mysql
ini code php utk view result pas user clik search tp xsama ape yg disearch cz kuar sume tarikh and time, room
- Code:
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>CONFERENCE SLOT</title>
<meta name="Microsoft Theme" content="none, default">
</head>
<body background="main_bg.gif">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="797" height="543">
<!-- MSTableType="layout" -->
<tr>
<td valign="top" colspan="2" height="74">
<!-- MSCellType="ContentHead" -->
<img border="0" src="Uum.jpg" width="794" height="201"></td>
</tr>
<tr>
<td msopnltype="NavBody" rowspan="2" width="137">
<!-- MSCellType="NavBody" -->
</td>
<td valign="top" height="420" align="center">
<!-- MSCellType="ContentBody" -->
<p align="center"> </p>
<p align="center"> </p>
<p align="center"><b><font size="5">CONFERENCE SLOT</font></b></p>
</td>
</tr>
<tr>
<?php
$db = mysql_connect("localhost","","");
if (!mysql_select_db('seminar'))
die('Error selecting Database!');
$result = mysql_query("SELECT * FROM student");
echo "<table class=mediumtxt border=1 align=center bgcolor=#9FABFD background=FROSBLLT_GIF.jpg>";
echo "<tr><td><b>Code</b></td><td><b>Date</b></td>
<td ><b>Time</b></td>
<td><b>Room</b></td>
<td><b>Conference Title</b></td>
<td><b>Presenter Name</b></td></tr>";
while ($myrow = mysql_fetch_array($result)) {
echo "<tr><td>";
echo $myrow["code"];
echo "</td><td>";
echo $myrow["date"];
echo "</td><td>";
echo $myrow["time"];
echo "</td><td>";
echo $myrow["room"];
echo "</td><td>";
echo $myrow["title"];
echo "</td><td>";
echo $myrow["name"];
echo "</td></tr>";
}
echo "</table>";</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
?></body>
<td valign="top" height="49" width="660">
<!-- MSCellType="ContentFoot" -->
</td>
</html>
kaizen- Ahli Baharu
- Number of posts : 11
Registration date : 05/03/2009
- Post n°14
Re: Coding search php mysql
owh...
saya andaikkan awak post 3 data penting.
contoh
tu example mudah.. tp awak libatkan 3 field .. so kene buat if else dekat query...
try contoh mudah tuh.. jika dapat kuarkan data mengikut room yang di search.. so berjaya peringkat pertama..
saya andaikkan awak post 3 data penting.
contoh
- Code:
<?php
$room=$_POST[room];
$result = mysql_query("SELECT * FROM student where room='$room'");
?>
tu example mudah.. tp awak libatkan 3 field .. so kene buat if else dekat query...
try contoh mudah tuh.. jika dapat kuarkan data mengikut room yang di search.. so berjaya peringkat pertama..
Arman- Ahli Baharu
- Number of posts : 3
Registration date : 09/03/2009
- Post n°15
Re: Coding search php mysql
BasicCX,
.html tak blh execute code php melainkan klu ko tukar supaya server ko blh execute .html tu sebagai .php.
maksud aku kat sini kod php tu ditulis dalam file .html tu.
klu ko buat form dalam .html yg panggil external php file, itu mmg boleh.
.html tak blh execute code php melainkan klu ko tukar supaya server ko blh execute .html tu sebagai .php.
maksud aku kat sini kod php tu ditulis dalam file .html tu.
klu ko buat form dalam .html yg panggil external php file, itu mmg boleh.
syira86- Ahli Baharu
- Gender : Female Number of posts : 108
Age : 38
Location : kedah
Job/hobbies : explore
Registration date : 04/03/2009
- Post n°16
Re: Coding search php mysql
salam..sy xfhm la mksud En.Arman ....mcm 2 la lect sy ajar dlm basic php.....
JebatDerhaka- Ahli Baharu
- Gender : Male Number of posts : 8
Location : FC SungaiRamal
Job/hobbies : Tengok Bola
Registration date : 11/03/2009
- Post n°17
Re: Coding search php mysql
Contoh...apabila user masukkan date ngan time.Kemudian tekan butang cari.
[code]
<?php
$date=$_POST[date];
$time=$_POST[time];
if(isset($submit))
{
$maklumat=mysql_query("SELECT * FROM student WHERE dbdate='$date' AND dbtime='$time'");
$row=mysql_fetch_assoc($maklumat);
?>
[code]
sekadar membantu yang termampu
[code]
<?php
$date=$_POST[date];
$time=$_POST[time];
if(isset($submit))
{
$maklumat=mysql_query("SELECT * FROM student WHERE dbdate='$date' AND dbtime='$time'");
$row=mysql_fetch_assoc($maklumat);
?>
[code]
sekadar membantu yang termampu
syira86- Ahli Baharu
- Gender : Female Number of posts : 108
Age : 38
Location : kedah
Job/hobbies : explore
Registration date : 04/03/2009
- Post n°18
Re: Coding search php mysql
sy dah wat mcm en.kaizen ...mmg jdi tp xdpt wat utk date n time...sy dah cube gune stment if n else tp xjdi n ade error kt while (myrow) 2....
thnx en.jebat reply tp cmne nk wat utk 3 carian data???
thnx en.jebat reply tp cmne nk wat utk 3 carian data???
Farlee- Ahli Baharu
- Gender : Male Number of posts : 38
Age : 40
Location : Kuala Lumpur, Kuala Terengganu (Malaysia)
Job/hobbies : Looking at Computer
Registration date : 16/03/2009
- Post n°19
Re: Coding search php mysql
Kena tulis statement OR atau AND selepas WHERE statement (Cth mcm jebat punya code tu)syira86 wrote:
thnx en.jebat reply tp cmne nk wat utk 3 carian data???
Kalu 3 carian, rujuk 3 column dlm table yg terlibat, x payah pakai star (*), melainkan klu rasa pc tu power giler sgt. Cth:
- Code:
$query=mysql_query("SELECT <columnname1>,<columnname2>,<columnname3> from <tablename> where <columnname1>='<sumting>' OR <columnname2>='<sumting>' OR <columnname3>='<sumting>'");
while($row=mysql_fetch_assoc($query))
{
/*Arahan output 3 column yg terlibat (bleh pilih salah satu atau nk papar kesemuanya)*/
echo $row['<column1>'];
echo $row['<column2>'];
echo $row['<column3>'];
}
Tapi kalu nk spesifik lagi, tu kena tambah lagi "LIKE" statement masa letak "<columnname>="sumthing"" mcm:
- Code:
"<columnname1> LIKE '%<sumting>' OR '%<sumting>%' OR '<sumting>%'"
Hah, klu 3 carian saja dah byk... ini kan pulak (3 column) X (3 kemungkinan keluar satu/dua/tiga padanan) X (3 spesifik carian dlm satu column) = 27 keseluruhan "possibilities"/kemungkinan jawapan nye.
kaizen- Ahli Baharu
- Number of posts : 11
Registration date : 05/03/2009
- Post n°20
Re: Coding search php mysql
untuk search date dan juga time..
better buat specific form search untuk date dan juga time..
contohnya form search..
date specifickan -> user boleh search by month ker??
or buat input field -> user click calendar popup.. user boleh choose date yang user inginkan.
time -> buat field select box waktu time. pastu tgk juga awak simpan dalam database.. time tuh simpan format mcm mana?? 24 hour or 12 hour..
jika 24 hour.. lebih mudah buat select box 1 -24.
event -> just buat input biasa sahaja.. nanti pakai mysql " like ".
better buat specific form search untuk date dan juga time..
contohnya form search..
date specifickan -> user boleh search by month ker??
or buat input field -> user click calendar popup.. user boleh choose date yang user inginkan.
time -> buat field select box waktu time. pastu tgk juga awak simpan dalam database.. time tuh simpan format mcm mana?? 24 hour or 12 hour..
jika 24 hour.. lebih mudah buat select box 1 -24.
event -> just buat input biasa sahaja.. nanti pakai mysql " like ".
Kuzie- Ahli Baharu
- Gender : Male Number of posts : 125
Age : 40
Location : eVeRyWhErE
Registration date : 13/02/2009
- Post n°21
Re: Coding search php mysql
- Code:
<?php
// ** MySQL settings ** //
define('DB_NAME', 'db_myProject');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>
// ** PHP search Date ** //
<?php
$Calendar = $_POST['Calendar1'];
$Select1= $_POST['Select1'];
//Convert Calendar "/" kepada "-"
$format = '%Y-%m-%d';
$Calendar =strtotime($Calendar);
$Calendar = strftime($format, $Calendar );
//Select1 = Listbox form submit. sebagai contoh dalam listbox ada 12am - 12pm dan 12pm - 12am
if ($Select1 =='Morning')
{
$Morning1 = "00:00:00";
$Morning2 = "12:00:00";
}
else
{
$Morning1 = "12:00:01";
$Morning2 = "23:00:59";
}
mysql_select_db("Room", $con);
$result = mysql_query("SELECT * FROM Room where Date2 = '".$Calendar."' and Time2 BETWEEN '".$Morning1."' AND '".$Morning2."' ");
echo "<table border=1>
<tr>
<th>Room</th>
<th>Date</th>
<th>Time</th>
<th></th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Room'] . "</td>";
echo "<td>" . $row['Date2'] . "</td>";
echo "<td>" . $row['Time2'] . "</td>";
echo "<td><a href=Delete.php?Name1=".$row['Room'].">Delete</a></td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
}
?>
syira86- Ahli Baharu
- Gender : Female Number of posts : 108
Age : 38
Location : kedah
Job/hobbies : explore
Registration date : 04/03/2009
- Post n°22
Re: Coding search php mysql
salm..thnx ats reply anda....sy dah gune coding en.farlee....ade error la..
error kt cni bile gune coding farlee
so sy wat mcm nie
jadi tp mslhnye xspecifik la...sume data kuar megikuta ape yg diclik...xde kait dng time,room dan date....
error kt cni bile gune coding farlee
- Code:
while($myrow = mysql_fetch_assoc($maklumat)) {
so sy wat mcm nie
- Code:
<?php
$room=$_POST[room];
$date=$_POST[date];
$time=$_POST[time];
$db = mysql_connect("localhost","","");
if (!mysql_select_db('seminar'))
die('Error selecting Database!');
$maklumat=mysql_query("SELECT code,date,time,room,title,name from student where date='$date' AND time='$time' AND room='$room'");
$row=mysql_fetch_assoc($maklumat);
echo
"<table class=mediumtxt width=771 align=center border=1>";
echo "<tr><td><b>PaperCode</b></td><td><b>Date</b></td>
<td ><b>Time</b></td>
<td><b>Room</b></td>
<td><b>Conference Title</b></td>
<td><b>Presenter Name</b></td></tr>";
while ($myrow = mysql_fetch_assoc($maklumat)) {
echo "<tr><td>";
echo $myrow["code"];
echo "</td><td>";
echo $myrow["date"];
echo "</td><td>";
echo $myrow["time"];
echo "</td><td>";
echo $myrow["room"];
echo "</td><td>";
echo $myrow["title"];
echo "</td><td>";
echo $myrow["name"];
echo "</td></tr>";
}
echo "</table></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
";
?>
jadi tp mslhnye xspecifik la...sume data kuar megikuta ape yg diclik...xde kait dng time,room dan date....
syira86- Ahli Baharu
- Gender : Female Number of posts : 108
Age : 38
Location : kedah
Job/hobbies : explore
Registration date : 04/03/2009
- Post n°23
Re: Coding search php mysql
nie main.php sy for seacrhing
- Code:
<?php
echo"<form method='POST' action='conference_slot2.php'>";
echo"<select name='date'>
<option>23/03/2009</option>
<option>24/03/2009</option>
<option>25/03/2009</option>
</select>
<select name='time'>
<option>9-11am</option>
<option>11-1.3</option>
<option>2-5.30</option>
</select>
<select name='room'>
<option>dkg4/1</option>
<option>dkg4/2</option>
<option>dkg4/3</option>
</select>
<input type='submit' value='Search' name='B1'></form>";
?>
Kuzie- Ahli Baharu
- Gender : Male Number of posts : 125
Age : 40
Location : eVeRyWhErE
Registration date : 13/02/2009
- Post n°24
Re: Coding search php mysql
Ni dah ok ke belum system ni...??ke still ade error?
syira86- Ahli Baharu
- Gender : Female Number of posts : 108
Age : 38
Location : kedah
Job/hobbies : explore
Registration date : 04/03/2009
- Post n°25
Re: Coding search php mysql
tgal function search jer la...yg len sume dah siap...asik search nie ade error