PDA

View Full Version : Search Function [mission accomplished]


nauz
11-14-2004, 12:11 AM
Okay no one responded to my search function request.
Keep in mind i'm not a PHP coder so any input would be helpful.

I copied a goofy script that I edited to search mysql for title names.
look: http://www.nauglevision.com/pix/search.htm search "dog"

What this gives me is printout:

2004-10-22 12:45:39
JJ Doggle
jj_pola.jpg
- - - - - -

2004-10-29 10:48:51
Sitting Dog
IMG_0124.jpg
- - - - - -



okay so it's successfully searching the table i want and returning the results.
Now, how can i make these results hyplerlinked to the image/page?
I know generating a thumbnail in the search result would be rad but that ain't going to happen.

-OR-
Would there be a way to search the RSS / feed file and give me the results as a link?

Again, any input would be great.
Attached is the PHP file i made the search from:


<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","dodobaseXXX","XXXXX");

//select which database you want to edit
mysql_select_db("XXXXXXX");

$search=$_POST["search"];

//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search
//$result = mysql_query("SELECT * FROM news WHERE message LIKE '%$search%'");
$result = mysql_query("SELECT * FROM pixelpost_pixelpost WHERE headline LIKE '%$search%'");

//grab all the content
while($r=mysql_fetch_array($result))
{
//the format is $variable = $r["nameofmysqlcolumn"];
//modify these to match your mysql table columns

$datetime=$r["datetime"];
$headline=$r["headline"];
$body=$r["body"];
$image=$r["image"];
$category=$r["category"];
$id=$r["id"];

//display the row
echo "$datetime <br> $headline <br> $image <br>- - - - - -<br>";
}
?>



Here's the result i get:

2004-10-22 12:45:39
JJ Doggle
jj_pola.jpg
- - - - - -

2004-10-29 10:48:51
Sitting Dog <--- i want this linked
IMG_0124.jpg
- - - - - -

Great, but how about a link....or a thumbnail? http://www.nauglevision.com/pix/thumbnails/thumb_seq256.jpg ohhhhh, fucking wicked!

Thanks Pixel peeps.
-nauz

pixelpunk
11-14-2004, 07:46 PM
//display the row
echo "$datetime <br> <a href=\"index.php?showimage=$id\">$headline</a> <br> <a href=\"index.php?showimage=$id\"><img src=\"thumbnails/thumb_$image\"></a> <br>- - - - - -<br>";
}
?>

Try that one.

nauz
11-14-2004, 08:00 PM
You rock!

I figured you knew the code inside and out.
Thanks again.

-N

nauz
11-14-2004, 10:14 PM
Yep.

http://www.nauglevision.com/pix/search.htm

javascript:emoticon(':lol:')