something weird?

From: Date: Fri, 25 Aug 2000 13:01:10 +0000
Subject: something weird?
Groups: php.general 
Request: Send a blank email to php-general+get-13658@lists.php.net to get a copy of this message
hi all i have a weird problem with the following code... when i load the page it seems to be searching and then listing our whole database before displaying the page..i have to stop the page before i can use it..i just can't figure out where the problem is..i have done some tracing thru mysql but it really doesn't show anything that sticks out..can anyone help pls...many thanks jason i apologise for the length of code :-) <html> <head> <title>Search One Stop Database</title> </head> <body bgcolor=#ffffff topmargin = 0> <font face=verdana,arial,sans serif color=#006699 size=2> <table width = 100% align = "left" border = 0 cellspacing = "0" cellpadding = "5"> <tr>
    <td colspan=3><font size=4 font face=verdana,arial,sans serif color=#006699><b>One
      Stop Catalogue Search</b></font><br>
      <font color="#006699" face="Verdana, Arial, Helvetica, sans-serif" size="1">Input
      the artist,title or catalogue number you are looking for in the search box.</font></font></td>
</tr> <form method=post action="<?php echo $PHP_SELF ?>">
    <tr>
      <td width = 10% bgcolor = #cccccc valign="middle"> <font size=1 font face=verdana,arial,sans serif color=#006699>
        <b>Enter Search: </b></font> </td>
      <td width = 90% bgcolor = #cccccc align="left" valign="middle">
        <input type=text name="keyword" size=25>
        <input type=submit value="Search" name="submit">
      </td>
    </tr>
</form> <br> <?php $keyword = ucwords($keyword); $words = explode(" ", $keyword); if ($words) { $db=mysql_connect("localhost","user","pword"); mysql_select_db("database",$db); $query = "SELECT * FROM prodmast WHERE (descript LIKE '%$words[0]%' OR code LIKE '%$words[0]%')"; if (count($words) > 1){
    foreach($words as $element) {
      $query .= " AND (descript LIKE '%$element%' OR code LIKE '%$element%')";
    }
} $query .= " ORDER BY descript"; //echo ($query); $result = mysql_query($query);
            if ($result)
                        {
                        echo "<tr><td colspan = 2><font size=2 color=#006699 face=verdana, arial, sans serif>Search Results for <b><font size=2 color=#FF0000 face=verdana, arial, sans serif>$keyword</font></b></font></td></tr>\n";
                                        echo "<tr><td colspan = 6>";
                                        echo ("<TABLE width = 100% align = left CELLPADDING=4 CELLSPACING=0 border = 0 FONT FACE=VERDANA SIZE=1 COLOR=#006699>\n");
                                        echo ("<tr bgcolor=#006699>
                                        <td width = 15%><b><font face=Verdana, Helvetica, sans-serif size=-2 color=#ffffff>Catalogue No</font></b></td>
                                        <td width = 50%><b><font face=Verdana, Helvetica, sans-serif size=-2 color=#ffffff>Artist/Title</font></b></td>
                                        <td width = 10%><b><font face=Verdana, Helvetica, sans-serif size=-2 color=#ffffff>Pre GST</font></b></td>
                                        <td width = 10%><b><font face=Verdana, Helvetica, sans-serif size=-2 color=#ffffff>Unit</font></b></td>
                                        <td width = 10%><b><font face=Verdana, Helvetica, sans-serif size=-2 color=#ffffff>Supplier</font></b></td>
                                        <td width = 5%><b><font face=Verdana, Helvetica, sans-serif size=-2 color=#ffffff>Qty</font></b></td>
                                        </tr>\n");
                while ($r = mysql_fetch_array($result)) {
                    $code = $r["code"];
                $descript = $r["descript"];
                $unit = $r["unit"];
                $supp1 = $r["supp1"];
                $instock = $r["instock"];
                $wsale = $r["wsale"];
                                        /* Output to nested tables */
                    echo "<TR>";
                                        echo "<TD width = 15%><FONT COLOR=#000000><FONT SIZE=1>$code</FONT></FONT>";
                    echo "<TD width = 50%><B><FONT COLOR=#FF6600><FONT SIZE=1>$descript</a></FONT></FONT></B>";
                    echo "<TD width = 10%><FONT COLOR=#000000><FONT SIZE=1>\$$wsale</FONT></FONT>";
                    echo "<TD width = 10%><FONT COLOR=#000000><FONT SIZE=1>$unit</FONT></FONT>";
                    echo "<TD width = 10%><FONT COLOR=#000000><FONT SIZE=1>$supp1</FONT></FONT>";
                    echo "<TD width = 5%><FONT COLOR=#000000><FONT SIZE=1>$instock</FONT></FONT>";
                                        echo "</TR>";
                }
            }
                        else
                        {
               echo "No Data.";
                               }
                         }
else if ($code) { $result = mysql_query("SELECT * FROM prodmast WHERE code=$code",$db); $r = mysql_fetch_array($result); echo "Catalogue No.: $code\n<br>"; echo "Artist/Title: $descript\n<br>"; } ?> </table> </font> </body> </html> Regards Jason Savidge IT Manager One Stop Entertainment Brisbane Australia www.onestopent.com.au

« previous php.general (#13658) next »