Simply im in the middle of creating a search engine to that will pick out data from a certain table depending on what dropdown menu has been choosen! Ive got the search engine and display page working, but am trying to create an individual page for the results which i can get working when only one table is involved..

i think the problem is that the dropdown variable is not being passed on the creation page..

if(isset($_GET['id']]))

i use that to pass on the id so would something similar be used to pass it on

if(isset($_GET['id'], $_GET['dropdown']))

i tried that no knowing what would happen but am getting no results.

Thanks in advance Hope you understand and apologises if in wrong section as its kind of php and dhtml

Recommended Answers

All 7 Replies

Member Avatar for diafol

comma doesn't work.

if(isset($_GET['id']) && isset($_GET['dropdown']))

comma doesn't work.

if(isset($_GET['id']) && isset($_GET['dropdown']))

Cheers for reply i completely forgot thats what you do there..

still not working ever since i added the dropdown menu bit

but i'll keep at it

commented: +++ +1

still not working ever since i added the dropdown menu bit

PinkSmartie , Show more significant piece of code - and highlight what isnt working and where you think it's a mistake! I'll try to sort out the problem))

<?php
		$dropdown = $_GET["dropdown"];
		$button = $_GET["submit"];	
                  $search = $_GET["search"];

			if(!$button)
			echo "You didnt submit a keyword.";

			else
		         {
			   if( strlen($search)<=2)
									
				echo"Search term too short.<hr size='1'>";
									
				else
				{
					echo "You searched for <b>$search</b> <hr size='1'>";
										
						//connect
						include("dbConnect.php");

						// connect to database
						$db = mysql_connect($dbHost, $dbUsername, $dbPassword);
						mysql_select_db($databasename,$db);
										

						$search_exploded = explode(" ", $search);
						foreach($search_exploded as $search_each)
						{
						    $x++;
						    if($x==1)
							$construct .= " keywords LIKE '%$search_each%'";
												
						else
							$construct .= " OR keywords LIKE '%$search_each%'";
													
						}
										
						$construct = "SELECT * FROM $dropdown WHERE $construct";
						$run = mysql_query($construct);
												
						$foundnum = mysql_num_rows($run);
												
						if($foundnum==0)
						echo "No results found.";
												
						else
						{
						 echo "$foundnum results found!<p>";
												  
						while($runrows = mysql_fetch_assoc($run))
						{
						//get data
						$id = $runrows['id'];
						$make = $runrows['make'];
						$model = $runrows['model'];
					         $year = $runrows['year'];
						$partname = $runrows['partname'];
						$name = $runrows['name'];
						$price = $runrows['price'];
														
														
			                		 //-display the result of the array
						echo "<ul>\n";
						echo "<li>"  .$make . " </li>\n";
						echo "<li>"  .$partname . " </li>\n";
						echo "<li>"  .$name . " </li>\n";
				echo "<li>" . "<a  href=\"search.php?id=$id\">   More...  </a><hr size=''></li>\n";
						echo "</ul>";
					       }//while
			                        }//else
												
												
									}
								}
								
			if(isset($_GET['id']) && isset($_GET['dropdown']))
			{
			   {
				$id=$_GET['id'];
				$dropdown = $_GET["dropdown"];													
			          include("dbConnect.php");									                           $db = mysql_connect($dbHost, $dbUsername, $dbPassword);
				mysql_select_db($databasename,$db);
				$sql="SELECT  * FROM dropdown=" .$dropdown." WHERE id=" . $id;

				//run  the query against the mysql query function
					$result=mysql_query($sql);
			
                             	//-create  while loop and loop through result set
	                            while($row=mysql_fetch_array($result))
				{
					$make =$row['make'];
					$model=$row['model'];
					$year=$row['year'];
					$partname = $row['partname'];
					$name = $row['name'];
					$price = $row['price'];
														  
			//-display  the result of the array
					echo  "<ul>\n";
					echo  "<li>Make: " . $make . " </li>\n<br>";
				         echo  "<li>Model:" . $model . "</li>\n<br>";
					echo  "<li>Year:" . $year . "</li>\n<br>";
					echo  "<li>Model:" . $partname . "</li>\n<br>";
					echo  "<li>Year:" . $name . "</li>\n<br>";
                                              echo  "</ul>";
				}
		}
	}

?>

didnt know how much would help but here you go, there may be a few silly mistakes but thats my fault as i wanted to fix the layout before puttin onto this.

anyway the code is searching tables for keywords, depending on what ever dropdown menu is choosen it will look in there. this is my first time doing something like this so it sounded ok in my head.

it will search ok, and display the results the problem is when you click on the more button to dipslay full information nothing is showing up

any suggestions and help would be great thanks in advance

what part doesnt work?

the problem lies between 77 and the end..

code explanation: its searchs for a keyword typed in then decides what table to look in using dropdown menu, this works

itll display a page with a shortened version of results with more button this works.

when u click more the results will not display.. im baffled!

When i take out the dropdown menu code it all works but i really need this code in!

commented: + +1

Just in case anyone wanted to know we worked it out, a good friend philip corkin pointed me in the correct direction the code is as follows

if($foundnum==0)
	echo "No results found.";
												
	else
	{
		 echo "$foundnum results found!<p>";
												  
		if($dropdown == cars)
		{
												  
		while($runrows = mysql_fetch_assoc($run))
		{
			//get data
			$id = $runrows['id'];
			$make = $runrows['make'];
			$model = $runrows['model'];
			$price = $runrows['price'];
			$picture = $runrows['picture'];
															
//-display the result of the array
															 echo "<table>\n";
	echo "<tr><td rowspan=\"5\"><img width=\"200\" height=\"150\" src='$picture'/></td></tr>\n";
	echo "<tr><td>Make: "  .$make . " </td></tr>\n";
	 echo "<tr><td>Model: "  .$model . " </td></tr>\n";
	 echo "<tr><td>Price: £"  .$price . " </td></tr>\n";
	echo "<tr><td>" . "<a href=\"carmain.php?page=more&id=$id\">   More...  </a></td></tr>\n";
	echo "</table><hr size='1'>";
		}
	}
													
	else if($dropdown == parts)
	{
											
	while($runrows = mysql_fetch_assoc($run))
	{
															//get data
															$id = $runrows['id'];
															$make = $runrows['make'];
															$partname = $runrows['partname'];
															$price = $runrows['price'];
															$picture = $runrows['picture'];
															
															
															 //-display the result of the array
															 echo "<table>\n";
															 echo "<tr><td rowspan=\"5\"><img width=\"200\" height=\"150\" src='$picture'/></td></tr>\n";
															echo "<tr><td>Partname: "  .$partname . " </td></tr>\n";
															  echo "<tr><td>Make: "  .$make . " </td></tr>\n";
															   echo "<tr><td>Price: £"  .$price . " </td></tr>\n";
															 echo "<tr><td>" . "<a href=\"partmain.php?page=more&id=$id\">   More...  </a></td></tr>\n";
															 echo "</table><hr size='1'>";
		}
		
													
	else
{
														while($runrows = mysql_fetch_assoc($run))
		{
															//get data
															$id = $runrows['id'];
															$name = $runrows['name'];
															$price = $runrows['price'];
															$picture = $runrows['picture'];
															
															
															  //-display the result of the array
															 echo "<table>\n";
															 echo "<tr><td rowspan=\"4\"><img width=\"200\" height=\"150\" src='$picture'/></td></tr>\n";
															echo "<tr><td>Name: "  .$name . " </td></tr>\n";
															   echo "<tr><td>Price: £"  .$price . " </td></tr>\n";
															 echo "<tr><td>" . "<a href=\"accmain.php?page=more&id=$id\">   More...  </a></td></tr>\n";
															 echo "</table><hr size='1'>";
														}

													}

													
												}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.