Forum Sementara Putera.com

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Forum Sementara Putera.com

Bersama kita perkemaskan forum ini sementara forum asal dalam pemulihan.

Forum putera dah kembali. Masalah sudah berjaya diselesaikan. Sila lawati http://forum.putera.com/tanya


+8
JebatDerhaka
BasicCX
kaizen
Arman
FryShadow
Haibara Ai
slaughters
syira86
12 posters

    Coding search php mysql

    avatar
    syira86
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 108
    Age : 38
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Coding search php mysql Empty Coding search php mysql

    Post by syira86 Wed Mar 04, 2009 2:34 pm

    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....
    slaughters
    slaughters
    PDP Moderator
    PDP Moderator


    Gender : Male Number of posts : 213
    Location : Selangor
    Registration date : 13/02/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by slaughters Wed Mar 04, 2009 2:47 pm

    aku pelik a, nape aku takleh nak movekan topic ni ?
    Haibara Ai
    Haibara Ai
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 85
    Age : 37
    Location : Wangsa Maju
    Job/hobbies : Bermain dengan coding
    Registration date : 12/02/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by Haibara Ai Wed Mar 04, 2009 9:39 pm

    $sql = "SELECT * FROM namatable WHERE namafield
    LIKE '%".$_POST ["txtsearch"]."%' ";

    $result = mysql_query($sql);
    if (!result){
    echo "query failed ". mysql_error();
    exit;
    Haibara Ai
    Haibara Ai
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 85
    Age : 37
    Location : Wangsa Maju
    Job/hobbies : Bermain dengan coding
    Registration date : 12/02/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by Haibara Ai Fri Mar 06, 2009 10:09 pm

    kat mana yg tak jadi tu syira?..reply dalam ni la..takyah reply kot pm.. nanti senang user lain dapat bantu sekali.. Very Happy
    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);
    ?>
    avatar
    syira86
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 108
    Age : 38
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by syira86 Sat Mar 07, 2009 4:14 pm

    thnx ..sy imterface mcm nie laCoding search php mysql Mainp
    slaughters
    slaughters
    PDP Moderator
    PDP Moderator


    Gender : Male Number of posts : 213
    Location : Selangor
    Registration date : 13/02/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by slaughters Sun Mar 08, 2009 11:36 am

    enjoy you conference day ?
    avatar
    syira86
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 108
    Age : 38
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by syira86 Sun Mar 08, 2009 4:15 pm

    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
    FryShadow
    Ahli Baharu
    Ahli Baharu


    Number of posts : 101
    Registration date : 20/02/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by FryShadow Mon Mar 09, 2009 9:35 pm

    Suppose "Enjoy your conference day" Smile
    avatar
    Arman
    Ahli Baharu
    Ahli Baharu


    Number of posts : 3
    Registration date : 09/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by Arman Mon Mar 09, 2009 10:59 pm

    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.
    avatar
    kaizen
    Ahli Baharu
    Ahli Baharu


    Number of posts : 11
    Registration date : 05/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by kaizen Tue Mar 10, 2009 4:15 pm

    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'
    avatar
    BasicCX
    Ahli Baharu
    Ahli Baharu


    Gender : Male Number of posts : 230
    Registration date : 25/02/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by BasicCX Tue Mar 10, 2009 5:53 pm

    Tak kira akhir extension .html @ .php boleh panggil database.

    Kalau guna HTML boleh guna form untuk post dan retrieve data.
    avatar
    syira86
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 108
    Age : 38
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by syira86 Tue Mar 10, 2009 6:35 pm

    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...
    avatar
    syira86
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 108
    Age : 38
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by syira86 Tue Mar 10, 2009 6:37 pm

    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" -->
          &nbsp;</td>
          <td valign="top" height="420" align="center">
          <!-- MSCellType="ContentBody" -->
          <p align="center">&nbsp;</p>
          <p align="center">&nbsp;</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" -->
          &nbsp;</td>


    </html>
    avatar
    kaizen
    Ahli Baharu
    Ahli Baharu


    Number of posts : 11
    Registration date : 05/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by kaizen Tue Mar 10, 2009 7:02 pm

    owh...
    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..
    avatar
    Arman
    Ahli Baharu
    Ahli Baharu


    Number of posts : 3
    Registration date : 09/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by Arman Tue Mar 10, 2009 7:52 pm

    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.
    avatar
    syira86
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 108
    Age : 38
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by syira86 Wed Mar 11, 2009 8:32 pm

    salam..sy xfhm la mksud En.Arman ....mcm 2 la lect sy ajar dlm basic php.....
    avatar
    JebatDerhaka
    Ahli Baharu
    Ahli Baharu


    Gender : Male Number of posts : 8
    Location : FC SungaiRamal
    Job/hobbies : Tengok Bola
    Registration date : 11/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by JebatDerhaka Wed Mar 11, 2009 10:18 pm

    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
    avatar
    syira86
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 108
    Age : 38
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by syira86 Thu Mar 12, 2009 11:09 am

    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???
    avatar
    Farlee
    Ahli Baharu
    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

    Coding search php mysql Empty Re: Coding search php mysql

    Post by Farlee Mon Mar 16, 2009 9:49 pm

    syira86 wrote:
    thnx en.jebat reply tp cmne nk wat utk 3 carian data???
    Kena tulis statement OR atau AND selepas WHERE statement (Cth mcm jebat punya code tu)

    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>'];
    }
    *Kena rename *.html ke *.php, klu x, HTML x bleh baca kod PHP.

    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.
    avatar
    kaizen
    Ahli Baharu
    Ahli Baharu


    Number of posts : 11
    Registration date : 05/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by kaizen Tue Mar 17, 2009 3:00 pm

    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 ".
    Kuzie
    Kuzie
    Ahli Baharu
    Ahli Baharu


    Gender : Male Number of posts : 125
    Age : 40
    Location : eVeRyWhErE
    Registration date : 13/02/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by Kuzie Wed Mar 18, 2009 3:10 pm

    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);
      }
    ?>
    avatar
    syira86
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 108
    Age : 38
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by syira86 Thu Mar 19, 2009 4:04 pm

    salm..thnx ats reply anda....sy dah gune coding en.farlee....ade error la..



    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....
    avatar
    syira86
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 108
    Age : 38
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by syira86 Thu Mar 19, 2009 4:08 pm

    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
    Kuzie
    Ahli Baharu
    Ahli Baharu


    Gender : Male Number of posts : 125
    Age : 40
    Location : eVeRyWhErE
    Registration date : 13/02/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by Kuzie Thu Mar 19, 2009 4:11 pm

    Ni dah ok ke belum system ni...??ke still ade error? Neutral
    avatar
    syira86
    Ahli Baharu
    Ahli Baharu


    Gender : Female Number of posts : 108
    Age : 38
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Coding search php mysql Empty Re: Coding search php mysql

    Post by syira86 Thu Mar 19, 2009 4:36 pm

    tgal function search jer la...yg len sume dah siap...asik search nie ade error

    Sponsored content


    Coding search php mysql Empty Re: Coding search php mysql

    Post by Sponsored content


      Current date/time is Mon Nov 18, 2024 8:20 am