Results 1 to 3 of 3

Thread: tak jadi jugakkk....

  1. #1
    Join Date
    Jun 2003
    Location
    Terengganu
    Posts
    10
    Rep Power
    0

    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

  2. #2
    Join Date
    Oct 2002
    Posts
    22
    Rep Power
    0
    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>

  3. #3
    Join Date
    Jul 2001
    Location
    ttdi
    Posts
    130
    Rep Power
    221

    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Saya nak jadi freelance...
    By Syahrizal in forum Mamak Stall
    Replies: 30
    Last Post: 12-06-2009, 04:56 PM
  2. DERMAWAN jadi JUTAWAN
    By agam2007 in forum Revenue and Monetization
    Replies: 11
    Last Post: 06-09-2007, 02:00 PM
  3. Who say farmer tak boleh jadi kaya.
    By masli in forum Websites Review and Suggestion
    Replies: 2
    Last Post: 08-08-2007, 06:55 PM
  4. apa dah jadi?????
    By ergoomo in forum Website Design
    Replies: 2
    Last Post: 25-07-2003, 01:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

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