Hello, I have a script that writes to database "video" & table "videos". In "videos" i have a field called "tags" witch has a example value of "hd, test, 1080p" below is an like to image shack to view a screen shot of my database http://img543.imageshack.us/img543/2808/mysqls.jpg I want a file called search.php witch will access my database and try and match the search keywords with the tags in the field "tags" Please Help Chris
SELECT * FROM `table` WHERE `fieldyouwanttosearching` LIKE '%keyword%' Please read the MySQL documentation, this is just to easy...
i get You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''videos' WHERE 'tags' LIKE 'written'' at line 1
I will admit i know very little about MySQL. The code i'm using is <?php $query9="SELECT * FROM 'videos' WHERE 'tags' LIKE '".$_GET['k']."'"; // query string stored in a variable $rt9=mysql_query($query9); // query executed echo mysql_error(); // if any error is there that will be printed to the screen while($nt9=mysql_fetch_array($rt9)){ echo '<div id="'.$nt9['id'].'" class="box "> <div class="box_image"> <a href="/watch?v='.$nt9['id'].'" rel="bookmark"> <img src="/images/play.png" id="overlayimg" style="background-image: url('.$nt9['small_img_url'].');" alt="" title="'.$nt9['name'].'"/> </a> </div> <div class="box_detail"> <h3><a href="/watch?v='.$nt9['id'].'" rel="bookmark">'.$nt9['name'].'</a></h3> <div class="ratings"><div style="margin-bottom: 5px;"><img src="/images/starOff.png" style="border: 0px none;"><img src="/images/starOff.png" style="border: 0px none;"><img src="/images/starOff.png" style="border: 0px none;"><img src="/images/starOff.png" style="border: 0px none;"><img src="/images/starOff.png" style="border: 0px none;"></div></div> <div class="box_description" style="line-height: normal; display: none; text-align: left;"> <small class="super_light">'.$nt9['upload_date'].'</small> <div style=\'margin-top: 5px; line-height: normal;\'><p>'.$nt9['description'].'</p> </div> <div class="smaller light_blue" style="margin-top: 5px;"> <a href="/category/?cat='.$nt9['category'].'" rel="category">'.$nt9['category'].'</a> </div> </div> </div> </div>'; ?> PHP: if you goto search.php?k=hd i want it to echo the "id", "name", category" and "small_img_url"
use full text search and its much much faster than select query. sometimes select query using LIKE may give weird results.
You need some wild cards in your search query $query9="SELECT * FROM 'videos' WHERE 'tags' LIKE '%".$_GET['k']."%'"; // query string stored in a variable the % is the wild card symbol