Jump to content

why it doesn't search number alone???


scaleautostyle

Recommended Posts

hi everybody.. small issue here and I'm stuck with it..

 

here is my search form

 

http://scale24-25.com/search_form.php

 

if you put 935 in the field it will return the argument that he found nothing.

 

but if you put porsche 935 it will return you the 3 porsche 935 listed in the database.

 

WHY when I put 935 it doesn't return this result???

 

this is the code for the search.php  (  for those who see my other post yes I put the COMPLETE field for every picture. I hope to find something else to replace that)

 

<?php

include_once("db_connection.php");
   if(isset($_POST['submit'])){   
   if(isset($_GET['go'])){   
   if(preg_match("/^[  a-zA-Z]+/", $_POST['name'])){   
   $name=$_POST['name'];   
      
     //-query  the database table   
   $sql="SELECT  kit_id, kit_number, kit_name, description, manufacturer_kit, manufacturer_reel, engine_detail, year_prod_kit, year_prod_reel, scale, image_id, image_id1, image_id2, image_id3, image_id4, image_id5, image_id6, image_id7, image_id8, image_id9, image_id10, image_box1, image_box2, image_box3  FROM kit WHERE kit_number LIKE '%" . $name ."%' OR kit_name LIKE '%" . $name .  "%' OR description LIKE '%" . $name .  "%' OR manufacturer_kit LIKE '%" . $name .  "%' OR year_prod_reel LIKE '%" . $name ."%'";  


  //-run  the query against the mysql query function   
   $result=mysql_query($sql);  
   
  //-make the header of the table   
   
   echo "  <table align=center width=\"1895\" border=\"\">\n";
   echo "    <tr>\n";
   echo"  <td nowrap align=center width='95'>  kit manufacturer  \n";		
   echo"  <td nowrap align=center width='55'>	scale \n";		
   echo"  <td nowrap align=center width='90'>	kit number \n";		
   echo"  <td nowrap align=center width='290'>	kit name \n";		
   echo"  <td nowrap align=center width='400'>	description \n";		
   echo"  <td nowrap align=center width='70'>	year of reel production of car \n";		
   echo"  <td nowrap align=center width='70'>	complete engine detail\n";		
   echo"  <td nowrap align=center width='85'>	Select Picture to get bigger\n";
   echo"  <td nowrap align=center width='85'>	box contain pic #1\n";
   echo"  <td nowrap align=center width='85'>	box contain pic #2\n";
   echo"  <td nowrap align=center width='85'>	box contain pic #3\n";
   echo"  <td nowrap align=center width='81'>	instruction sheet page 1\n";
   echo"  <td nowrap align=center width='82'>	instruction sheet page 2\n";
   echo"  <td nowrap align=center width='81'>	instruction sheet page 3\n";
   echo"  <td nowrap align=center width='81'>	instruction sheet page 4\n";
   echo"  <td nowrap align=center width='81'>	instruction sheet page 5\n";
   echo"  <td nowrap align=center width='81'>	instruction sheet page 6\n";
   echo"  <td nowrap align=center width='81'>	instruction sheet page 7\n";
   echo"  <td nowrap align=center width='81'>	instruction sheet page 8\n";
   echo"  <td nowrap align=center width='81'>	instruction sheet page 9\n";
   echo"  <td nowrap align=center width='81'>	instruction sheet page 10\n";
   echo "    <tr>\n";

   //-create  while loop and loop through result set   
   while($row=mysql_fetch_array($result)){   
                                 $description  =$row['description'];   
                                 $manufacturer_kit=$row['manufacturer_kit'];   
                                 $kit_id=$row['kit_id']; 
	 $kit_number=$row['kit_number'];
	 $kit_name=$row['kit_name'];
	 $engine_detail=$row['engine_detail'];
	 $year_prod_reel=$row['year_prod_reel'];
	 $scale=$row['scale'];
	 $image_box1=$row['image_box1'];
	 $image_box2=$row['image_box2'];
	 $image_box3=$row['image_box3'];
	 $image_id=$row['image_id'];
	 $image_id1=$row['image_id1'];
	 $image_id2=$row['image_id2'];
	 $image_id3=$row['image_id3'];
	 $image_id4=$row['image_id4'];
	 $image_id5=$row['image_id5'];
	 $image_id6=$row['image_id6'];
	 $image_id7=$row['image_id7'];
	 $image_id8=$row['image_id8'];
	 $image_id9=$row['image_id9'];
	 $image_id10=$row['image_id10'];

	   
   //-create  table of item during he while loop
   
echo "  <table align=center width=\"1895\" border=\"\">\n";		   
echo"  <td nowrap align=center width='95'>  $manufacturer_kit  \n";		
echo"  <td nowrap align=center width='55'>	$scale \n";		
echo"  <td nowrap align=center width='90'>	$kit_number \n";		
echo"  <td nowrap align=center width='290'>	$kit_name \n";		
echo"  <td nowrap width='400'>	$description \n";		
echo"  <td nowrap align=center width='70'>	$year_prod_reel \n";		
echo"  <td nowrap align=center width='70'>	$engine_detail \n";	
echo"  <td nowrap width='75'> <a href=".$image_box1.">   <img src='".$image_box1."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_box2.">   <img src='".$image_box2."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_box3.">   <img src='".$image_box3."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_id.">   <img src='".$image_id."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_id1.">   <img src='".$image_id1."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_id2.">   <img src='".$image_id2."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_id3.">   <img src='".$image_id3."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_id4.">   <img src='".$image_id4."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_id5.">   <img src='".$image_id5."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_id6.">   <img src='".$image_id6."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_id7.">   <img src='".$image_id7."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_id8.">   <img src='".$image_id8."' width='75' height='50'/>";
echo"  <td nowrap width='75'> <a href=".$image_id9.">   <img src='".$image_id9."' width='75' height='50'/>";	
echo"  <td nowrap width='75'> <a href=".$image_id10.">   <img src='".$image_id10."' width='75' height='50'/>";		
echo "    </tr>\n";
echo "    </table>\n"; 
echo "    </tr>\n";
echo "    </table>\n"; 

   }   
   }  
   else{   
   echo  "<p>Please enter a search query</p>";   
   }   
   }   
   }
?>  

 

the database info for this one is like this:

 

field: kit_name

type: varchar(30)

 

hope this help

 

yours

 

sebastien

Link to comment
https://forums.phpfreaks.com/topic/206732-why-it-doesnt-search-number-alone/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.