• 0

search script


Question

9 answers to this question

Recommended Posts

  • 0
  soil said:
:unsure: like when u search the forum it shows all the topics with that title name.

585472280[/snapback]

you'll probably want to use php. i made something like that for my website (link below). it's really simple and all you need is:

searching for 'neowin' in 'Post titles' in database called 'Forum'

SELECT col1, col2 etc. FROM 'Forum WHERE ('Post titles' LIKE 'neowin');

you can also add in ORDER functions to sort by date or whatever you like.

Link to comment
https://www.neowin.net/forum/topic/285296-search-script/#findComment-585472299
Share on other sites

  • 0

i'm at work right now so i can't access my code back home, but all you need is just a simple select statement to search the database for the info you need.

so in php it goes something like this:

$sql = "SELECT * FROM .... etc. etc." // insert your sql query here

mysql_query($sql);

don't forget to connect to the localhost first!

Link to comment
https://www.neowin.net/forum/topic/285296-search-script/#findComment-585472442
Share on other sites

  • 0

how does it get the info from the form tho?

i found this 1 on the net but couldnt get it to work...

<form method=post action="search.php">arch For:
<p>
User Name: <input type=text name=user size=25 maxlength=25>
<p>
Password: <input type=text name=passwd size=25 maxlength=25>
<p>
<input type=submit>
</form>                                             

//search.php
<?
//You should now this but be sure to connect to your database or this is useless. :/
if ($user == "")
{$user = '%';}

if ($passwd == "")
{$passwd = '%';}
// $user and $passwd are the two column names I used.  Change this to fit your database
$result = mysql_query ("SELECT * FROM yourtable
                         WHERE user LIKE '%$user%'
                         AND passwd LIKE '%$passwd%'
                       ");

if ($row = mysql_fetch_array($result)) {

do {
  PRINT "<b>User Name:?????</b>     ";
  print $row["user"];
  print (" ");
  print ("<br>");
  PRINT "<b>Passwd:?????</b>     ";
  print $row["passwd"];
  print ("<p>");
  PRINT "<b>FirstName:?????</b>     ";
  print $row["firstname"];
  print ("<p>");
} while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found!";}

//The end result prints the username / passwd / firstname / lastname / ID / email
//you will have to change these fields also to fit your needs
?>

Edited by soil
Link to comment
https://www.neowin.net/forum/topic/285296-search-script/#findComment-585472495
Share on other sites

  • 0

:unsure: ok ermm i editd it but its not showing what i search forr :no:

  Quote
        <form method="post" name="search" action="index.php?page=search">

 

    <table width="190%" border="0" cellspacing="0" cellpadding="0">

            <tr>

              <td height="20">

<div align="center">

                  <input type=text name=search size=28 maxlength=25 class=dropdown>

                </div></td>

            </tr>

            <tr>

              <td height="20">

<div align="center">

                  <input name="submit" type=submit class=button value="Search">

                </div></td>

            </tr>

          </table>

  </form>

  Quote
<TABLE cellSpacing="1" cellPadding="4" width="100%" border="0">

  <TBODY>

    <TR>

      <TD class=header align=middle width=69 height=10><FONT

                  size=1><a class=link href="index.php?page=files">Added</a></FONT></TD

      <TD width="381" height=10 align=middle class=header><FONT

                  size=1><a class=link href="index.php?page=sort-name">Name</a></FONT></TD

      <TD class=header align=middle width=117 height=10><FONT

                  size=1><a class=link href="index.php?page=sort-author">Author</a></FONT></TD

      <TD class=header align=middle width=76 height=10><FONT

                  size=1><a class=link href="index.php?page=sort-section">Section</a></FONT></TD

      <TD class=header align=middle width=83 height=10><FONT

                  size=1><a class=link href="index.php?page=sort-version">Version</a></FONT></TD

    </TR>

<?php

include("db_config.php");

if ($search == "")

{$search = '%';}

$result = mysql_query ("SELECT * FROM files

                        WHERE search LIKE '%$downloadsignername%'

      WHERE search LIKE '%$info%'

                      ");

if ($row = mysql_fetch_array($result)) {

do {

?>

  <TR>

    <TD width="69" align=middle class=primary ><font size="1"><?php echo date("m-d-Y", $row['date']); ?></font></TD>

    <TD width="381" class=secondary><a class=link href="<?php echo $row['downloadurl']; ?>" target="_blank"><?php echo $row['info']; ?></a></TD>

    <TD width="117" class=primary><div align="center"><a class=link href="mailto:<?php echo $row['downloademail']; ?>"><?php echo $row['downloadsignername']; ?></a></div></TD>

    <TD width="76" align=middle class=secondary><div align="center"><font size="1"><?php echo $row['downloadpic']; ?></font></div></TD>

    <TD width="83" align=middle class=primary><div align="center"><font size="1"><?php echo $row['version']; ?></font></div></TD>

  </TR>

<?php

} while($row = mysql_fetch_array($result));

} else {print "Sorry, no records were found!";}

?>

</table>

Edited by soil
Link to comment
https://www.neowin.net/forum/topic/285296-search-script/#findComment-585472869
Share on other sites

  • 0
  Quote
include("db_config.php");
if ($search == "")
{$search = '%';}
$result = mysql_query ("SELECT * FROM files
                        WHERE search LIKE '%$downloadsignername%'
       WHERE search LIKE '%$info%'
               ");

I'm not sure how PHP is set up on your server, but you might need to use $_POST. Also, a field name should follow 'WHERE' and the search keyword should follow 'LIKE'.

For example

include("db_config.php");
$search = $_POST['search'];
if ($search == "")
    {$search = '%';}
$result = mysql_query ("SELECT * FROM files
                         WHERE downloadsingername LIKE '%$search%'
                         OR info LIKE '%$search%'");

(I'm assuming 'downloadsingername' [you made a typo there, BTW] and 'info' are fields in your table.)

Link to comment
https://www.neowin.net/forum/topic/285296-search-script/#findComment-585473506
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Is Polaroid's Now 3rd Gen camera worth the $99.99 price drop? by Paul Hill For at least a decade there has been a nostalgic feeling gripping people in response to the digitization of everything. We’ve seen this mainly in products like vinyl, and even apps like Slowly that make you wait before your friends receive your “letter”. Another such product trying to capitalize on nostalgia is the Polaroid Now 3rd Generation camera. For a limited time, you can pick it up for just $99.99, instead of $119.99. If you are still searching for a gift for Father’s Day, taking advantage of this limited-time deal would be our suggestion. The Polaroid Now 3rd Generation is available in several colors but only four - Black, Coral, Purple, and Yellow - are available for $99.99, and they all look great. While there is certainly nothing wrong with snapping photos on your phone and storing them in the cloud, you do lose out on the tactileness of a photograph that you get with the Polaroid Now 3rd Generation. Additionally, in recent years, Google has been nagging everyone that their Google Photos storage is about to run out, urging you to delete photos or pay to upgrade, in future clean ups, you might accidentally delete a photo you really wanted to keep, you can’t do that as easily with hard-copy photograph. What it does (and doesn’t) With the 3rd generation of Polaroid Now, you get several improvements over the predecessor. There is a better light meter, upgraded two-lens autofocus, a built-in tripod mount, photo filter compatibility, a self-timer to take snaps with yourself included, and double-exposure modes. This camera remains faithful to the iconic Polaroid design but comes with new colors, four of which are now $99.99 for a limited time. Environmentalism has become all the rage in recent years and consumers want stuff that’s produced more responsibly; to this end, Polaroid has used 40% recycled materials to reduce waste and improve the product’s carbon footprint. The Polaroid Now 3rd Generation uses Polaroid i-Type Film and 600 Film, both of which are sold separately. The cost of the film is probably the biggest issue with this product, it’s priced at $17.99 per 8-pack, so you’re definitely going to want to be mindful about the shots you take. You can cut the cost by buying in bulk. Some of the reviewers were also disappointed with the low-light shots they took indoors. If you are planning to take indoor shots, then be mindful about what other people have said. Outdoors, everything seems in order. The two-lens autofocus system mentioned earlier is a key new feature of this camera. The system combines two fixed focus zones with one lens covering distances from 0.40 meters to 1.3 meters, and the other covering from 1.0 meter to infinity. The camera then automatically switches lenses depending on the best one for the shot. With the self-timer, you can now set up the Polaroid Now 3rd Generation on a tripod and join in with a group photo, or just take a shot of yourself. The double exposure feature lets you layer two images on one piece of film to bring out your creativity to create visually striking and unexpected results. How it compares At this discounted price, the Polaroid Now 3rd Generation is the same price as the 2nd Generation model, but gets newer features. It should also be stated that there’s a Polaroid Now+ 3rd Generation which you can connect to your phone to control with an app, but it’s priced higher. If you’re just looking for a camera that doesn’t complicate things, then the Polaroid Now 3rd Generation is the ideal model. You get the new hardware features, but don’t need to worry about extra connectivity. Who it’s right for The Polaroid Now 3rd Generation is ideal for casual photographers, those looking to snap memories to tangible film, gift-givers looking to buy a parent a Father’s Day gift, or those who love the classic Polaroid aesthetic and want it on a shelf somewhere for decorative purposes. While the camera is now priced well at $99.99, buyers need to consider the on-going cost of the film, which can add up. For anyone who hasn’t used a film camera before, it’s also important for me to point out that prints take a bit of time to develop, some users have also complained about the low-light performance when indoors. If you’re looking for snapping retro outdoor shots, the Polaroid Now 3rd Generation is definitely worth your consideration! Polaroid Now 3rd Generation (Black): $99.99 (Amazon US) - MSRP $119.99 / 17% off Polaroid Now 3rd Generation (Coral): $99.99 (Amazon US) - MSRP $119.99 / 17% off Polaroid Now 3rd Generation (Purple): $99.99 (Amazon US) - MSRP $119.99 / 17% off Polaroid Now 3rd Generation (Yellow): $99.99 (Amazon US) - MSRP $119.99 / 17% off This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • My Machines with Classic Outlook 365, have a banner on top Next Time Outlook is opened, will be autoly switched to NEW Outlook, not sure if i should try to prevent that or just get used to new Outlook at this point Probably gonna try to prevent that now that i read that privacy notice
    • Yeah, no. I won't be "upgrading" to the "mandatory" Windows 11 until all the bugs with DirectX and Hibernate are sorted out. Until then ASUS and Microsoft can both stuff it where the sun don't shine.
    • Microsoft Edge It works as expected, and I see no reason to use another browser.
    • Tech demos are a declaration of desire, an horizon for what they pretend to put on those boxes call consoles (i still laugh at the poor implementation of Hairworks in W3 when you compare it with the demos)...being made on UE5 doesn't give me any confidence considering how poorly it runs in those things, and CDPR is not a marvel in that aspect neither. And about the game, so far is non existent besides the cinematic trailer. If from the get go they have to justify the whys for the protagonist, you start your narrative with the left foot.
  • Recent Achievements

    • First Post
      m10d earned a badge
      First Post
    • Conversation Starter
      DarkShrunken earned a badge
      Conversation Starter
    • One Month Later
      jrromero17 earned a badge
      One Month Later
    • Week One Done
      jrromero17 earned a badge
      Week One Done
    • Conversation Starter
      johnwin1 earned a badge
      Conversation Starter
  • Popular Contributors

    1. 1
      +primortal
      251
    2. 2
      snowy owl
      157
    3. 3
      ATLien_0
      140
    4. 4
      +FloatingFatMan
      139
    5. 5
      Xenon
      128
  • Tell a friend

    Love Neowin? Tell a friend!