SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    ? big bad opus's Avatar
    Join Date
    Jun 2001
    Location
    DC
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    please help me with my search script

    I had a list of preset keywords on my home page. I want this script to search and return the appropriate listing. Can anyone tell me what I'm doing wrong?

    Code:
    <?php
    include("config.php");
    $link = mysql_connect($dbhost, $dbuser, $dbpass);
    mysql_select_db($db, $link);
    if ($_GET['genre']) {
     $genre = $_GET['genre'];
     $result = mysql_query("SELECT * FROM $dbtable WHERE GENRE LIKE '%$genre%' ORDER BY TITLE");
    
    } elseif ($_GET['ql']) {
     $ql = $_GET['ql'];
     $result = mysql_query("SELECT * FROM $dbtable WHERE  TITLE LIKE '%$ql%' ORDER BY TITLE");
    };
    if (mysql_num_rows($result)) {
     $num_results = mysql_num_rows($result);
    ?>
    <table class="main" width="500" border="0">
     <tr>
      <td align="center">
      <p class="mainlabel">Scripts</p>
      </td>
      <td align="center">
      <p class="mainlabel">Poster</p>
      </td>
     </tr>
     <?php
     while ($row = mysql_fetch_array($result)) {
      list($ID, $TITLE) = $row;
      $movie_title = stripslashes($TITLE);
      echo "<tr>\n<td>\n<p class=\"maintext\"><a href=""\"index.php?module=movies&do=details&id=$movie_id\">$movie_title</a></p>\n</td><td align=\"center\">";
     
       echo "<img src=""\"modules/movies/covers/$ID\">";
      
      echo "</td></tr>";
     };
     ?>
    </table>
    <?php
    } else {
     echo "Oops";
    };
    
    ?>

  2. #2
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A couple of points.

    #1 There is no need to place a semi-colon at the end of your conditional blocks.

    #2 Where are you assigning the variable $movie_id?

    #3 Do you have information that you want retrieved in the database that is compatible with your query?

    PHP Code:
    <?php
     
      
    include("config.php" );
      
    $link mysql_connect($dbhost$dbuser$dbpass);
      
    mysql_select_db($db$link);
      
      if (
    $_GET['genre'])
      {
        
    $genre $_GET['genre'];
        
    $result mysql_query("SELECT * FROM $dbtable WHERE GENRE LIKE '%$genre%' ORDER BY TITLE" );
      }
      elseif (
    $_GET['ql'])
      {
        
    $ql $_GET['ql'];
        
    $result mysql_query("SELECT * FROM $dbtable WHERE TITLE LIKE '%$ql%' ORDER BY TITLE" );
      }
      
      if (
    mysql_num_rows($result)) 
      {
        
    $num_results mysql_num_rows($result);
    ?>
     
    <table class="main" width="500" border="0">
      <tr>
        <td align="center">
          <p class="mainlabel">Scripts</p>
        </td>
        <td align="center">
          <p class="mainlabel">Poster</p>
        </td>
      </tr>
     
    <?php
     
        
    while ($row mysql_fetch_array($result))
        {
          list(
    $ID$TITLE) = $row;
          
    $movie_title stripslashes($TITLE);

          echo 
    '<tr>
                  <td>
                    <p class="maintext">
                      <a href="index.php?module=movies&do=details&id='
    .$movie_id.'">'.$movie_title.'</a>
                    </p>
                  </td>
                  <td align="center">
                    <img src="modules/movies/covers/'
    .$ID.'">
                  </td>
                </tr>
                '
    ;
        }
        
    ?>
     
    </table>
     
    <?php
     
      
    }
      else
      {
        echo 
    'Oops';
      }
     
    ?>
    John


Bookmarks

Posting Permissions

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