easiest way for advance search

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

easiest way for advance search

Post by psychotomus »

whats the easiest way to do this advance search feature. i kind of messed it up =(

http://www.phpldtemplates.org/advance_search.php

Heres what i have now and its limited. i want to be able to search for all tags selected. not exact input of the tags selected.

Code: Select all

$result = mysql_query("SELECT id,screen_url, name FROM themes WHERE
						column1='" . $tags[0] . "' AND
						column2='" . $tags[1] . "' AND
						column3='" . $tags[2] . "' AND
						mixed='" . $tags[3] . "' AND
						white='" . $tags[4] . "' AND
						yellow='" . $tags[5] . "' AND
						grey='" . $tags[6] . "' AND
						pink='" . $tags[7] . "' AND
						red='" . $tags[8] . "' AND
						orange='" . $tags[9] . "' AND
						blue='" . $tags[10] . "' AND
						green='" . $tags[11] . "' AND
						purple='" . $tags[12] . "' AND
						brown='" . $tags[13] . "' AND
						black='" . $tags[14] . "' AND
						left_sidebar='" . $tags[15] . "' AND
						right_sidebar='" . $tags[16] . "' AND
						adsense_ready='" . $tags[17] . "' AND
						no_images='" . $tags[18] . "' AND
						images='" . $tags[19] . "' AND
						plugins='" . $tags[20] . "' AND
						widget='" . $tags[21] . "' AND
						fixed_width='" . $tags[22] . "' AND
						fluid_width='" . $tags[23] . "' ORDER BY RAND() LIMIT 24") or die(mysql_error());
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

I don't know what the hell your trying to do but that just isn't right dude.

Can you please explain what records your trying to pull and why?
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

I am Explaining (Showing An Example) How Simple It is On Zigmoyd(http://zigmoyd.sourceforge.net/man/db.php#browse)
-------------------------------------------------------------

Code: Select all

<?php
$conn = mysql_connect("localhost", "root", "");
$test = new browse("db_name", "themes", $conn);//db_name, table_name, $conn
$test->set("column1", $tags[0]);//Set The GIVEN Fields, and its Value
$test->set("column2", $tags[1]);
$test->set("column3", $tags[2]);
//And Set Other Given Fields (mixed, white and......) Like This
$test->find("id", "screen_url", "name");//Multiple Arguments Can Also be Given
$result = $test->adv_output();//Advanced Output
print_r($result);
?>
Thank You
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

~ psychotomus, read up on Relational Database Normalization. You just need to split your data into multiple tables.
Post Reply