Guest User

Untitled

a guest
Aug 29th, 2011
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. <?php
  2.        
  3.     echo "
  4. <h2>Keresés</h2>
  5. <form name='search' method='post'>
  6. Keresés erre: <input type='text' name='find' />
  7. <Select NAME='field'>
  8.      <Option VALUE='nev'>Neve</option>
  9.      <Option VALUE='foosztaly'>Főosztálya</option>
  10.      <Option VALUE='szine'>Színe</option>
  11. </Select>
  12.      <input type='hidden' name='searching' value='yes' />
  13.      <input type='submit' name='search' value='Keres' />
  14. </form>";
  15.  
  16.     if ($searching=='yes') { echo '<h2>Találatok:</h2>'; }
  17.     if ($find = "") { echo "<h3>nincs kulcsszó/h3>"; }
  18.  
  19.     $db = mysql_connect ("localhost","wordpress","BqTtCRGSrEryQtht");
  20.     $mydb = mysql_select_db("wordpress_adatok");
  21.     $find=$_POST['find'];
  22.     $field =$_POST['field'];
  23.    
  24.     //ha ide a field helyére azt írom hogy nev, foosztaly vagy szine akkor ok, de a //váltózval nem működik
  25.  
  26.     $sql="SELECT nev,foosztaly,szine FROM gems WHERE '$field' LIKE '$find'";
  27.    
  28.     $result=mysql_query($sql);
  29.    
  30.     while($row=mysql_fetch_array($result))
  31.     {  
  32.         echo "Név: " . $row['nev'] . " class: " . $row['foosztaly'] . " szine: ". $row['szine'];
  33.         echo "<br>";
  34.     }
  35.    
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment