Arama Fonksiyonu: Hata

0 Cevap php

Birisi bana yardımcı olabilir, bu hataları düzeltmek için nasıl emin değil im.

search.php

Notice: Undefined index: submit in C:\wamp\www\i-document\search.php on line 12
Notice: Undefined index: search in C:\wamp\www\i-document\search.php on line 13

'Arama' tıkladıktan sonra:

Notice: Undefined variable: x in C:\wamp\www\i-document\search.php on line 39
Notice: Undefined variable: construct in C:\wamp\www\i-document\search.php on line 41

Thankz.

Kodlar:

<?php

//Get data

$button = $_GET['submit'];
$search = $_GET['search'];

if (!$button)    echo "You didn't submit a keyword."; else {    if (strlen($search)<=1)
      echo "Search term too short";    else    {
      echo "You searched for <b>$search</b><hr size='1'>";

      //connect to database
      mysql_connect("localhost","root","");
      mysql_select_db("idoc");


            //explode search term
            $search_exploded = explode(" ",$search);

            foreach($search_exploded as $search_each);
            {

                //Construct Query

                $x++;
                if ($x==1)
                   $construct .= "file_name LIKE '%$search_each%'";
                else
                   $construct .= " OR file_name LIKE '%$search_each%'";

            }


      $construct = "SELECT * FROM document WHERE $construct";
      //echo out construct

     // $construct = "SELECT * FROM document WHERE $construct";
     $run = mysql_query($construct);

     $foundnum = mysql_num_rows($run);

     if ($foundnum==0)
        echo "No results found";
     else
     {
        echo "$foundnum results found!<p>";

        while ($runrows = mysql_fetch_assoc($run))
        {
         //Get data
         $ref = $runrows['file_ref'];
      $filename = $runrows['file_name'];    $owner = $runrows['owner'];
         $url = $runrows['url'];
         echo "
        <table>   <tr>
    <td> $ref </td>
    <td> $filename </td>
    <td> $owner </td>
    <td><a href='$url'>$url</a></td>
      </tr>    </table>
         ";
        }

     }
  } }
?>

<form id="form1" method="GET" action="search.php">
  <table width="446" height="135" border="1" align="center">
    <tr>
      <td height="31" colspan="2" align="center" valign="middle" bgcolor="#990000">
        <span class="style1 style2">
          Search :
        </span>
      </td>
    </tr>
    <tr>
      <td width="374" height="96" align="center" valign="middle" bgcolor="#990000">
        <span class="style1 style2">
          <label>
            <div align="left">
              Keyword :
              <input name="search" type="text" id="search" size="40" />
            </div>
          </label>
        </span>
        <td width="56" align="center" valign="middle" bgcolor="#990000">
          <div align="left">
            <input type = "submit" name="submit" value="search" />
          </div>
      </td>
    </tr>
  </table>
</form>

0 Cevap