search script idea

Discussion in 'PHP' started by mdrobiul, Apr 23, 2009.

  1. #1
    I really stop myself into figuring out the search method.

    I understand that with query we can fetch some rows with result. But how I should make hyperlinks to my page where my is content. Can you put the idea of seach system?

    Finally i have my result into $result array. But how to make hyperlinks to them?
     
    mdrobiul, Apr 23, 2009 IP
  2. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    assuming you have an array called '$results':
    foreach ($results as $result) { echo "<a href='$result'>$result</a>"; }
    Code (markup):
     
    szalinski, Apr 23, 2009 IP
  3. Stylesofts

    Stylesofts Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello,

    Well if you want to link contents from the search result then do like this


    
    $selectQuery = "Your search query"
    $resultQuery = mysql_query($selectQuery);
    $numRowsQuery = @mysql_num_rows($resultQuery);
    if($numRowsQuery>0)
    {
    while($rowQuery = @mysql_fetch_array($resultQuery))
    {
    ?>
    <li><a href='url?page=showContent&contentId=<?php echo $rowQuery['primaryKey']?>'>$rowQuery['tiitle']</a></li>
    <?php
    }
    }
    
    
    PHP:
    Hey we hope it worked for you
    :)

    Regards
    Stylesofts Developing Team.
     
    Stylesofts, Apr 24, 2009 IP
  4. mdrobiul

    mdrobiul Peon

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for your help. Do you mean id to id ?

    Suppose my site page is now located at mysite.com/?cat=12&page=25

    My result is now at $rowQuery

    And my hyperlink will be href="mysite.com/?cat=$rowQuery['cat']&page=$rowquery['pageid']"
     
    mdrobiul, Apr 25, 2009 IP
  5. Stylesofts

    Stylesofts Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hey

    Yes, it is the id..in the database table which u set as the autoincrement..
    :)



    Regards,
    Stylesofts Developing Team
     
    Stylesofts, Apr 28, 2009 IP
  6. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #6
    maybe u can set variable GET in ur pages..like VB system ...

    in ur output query ... ex. for end result

    http://example.com/index.php?highlight=$searchquery

    nad in ur pages... should set to GET variable.. :)

    regards
     
    ghprod, Apr 28, 2009 IP