MYSQL баазаас хайлт хийх
Localhost дээр ашиглахад нэн тохиромжтой скрипт юм. Code:
<? #---------------- Search Through MySQL Database--------------------- # &nb sp; MNG Team, http://www.mng.cc # &nbs p; By Batmunkh Moltov # &nb sp; Free scripts # &n bsp; 2005 #------------------------------------------------------------------ $link=mysql_connect("localhost","root","") or die(); ?> <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content -Type" content="text/html; charset=utf-8"> <title>Search through DB </head> <body> <form name="form1" method="post" action="<?=$PHP_SELF?>?q=1"> <input name="word" type="text" id="word"> <select name="db"> <? $q_db=mysql_query("SHOW DATABASES") or die(); while ($r_db=mysql_fetch_row($q_db)) { echo '<option value="'.$r_db[0].'"'; if(isset($db) && $db==$r_db[0]) { echo ' selected';} echo '>'.str_replace("_"," ",$r_db[0]).'</option>'; } ?> </select> <input type="submit" name="Submit" value="Submit"> </form> <hr size="1" color="#333333 "> <p> <? if(isset ($q) && $q==1) { mysql_select_db($db,$link); $q_tbl=mysql_query("SHOW TABLES") or die (); $niit=0; $a=1; while($r_tbl=mysql_fetch_row($q_tbl)) { echo '<b>'.$r_tbl[0].'</b> '; &nb sp; $q_fields=mysql_query("SHOW FIELDS FROM $db.$r_tbl[0]") or die(mysql_error()); &n bsp; #$num_fields=mysql_num_fields ($q_fields); while($r_f=mysql_fetch_row($q_fields)) { if($r_f[0]=='comment') { &nb sp; $q=mysql_query("select * from $db.$r_tbl[0] WHERE comment LIKE '%$word% '") or die(mysql_error()); $total=mysql_num_rows($q); while ($r=mysql_fetch_array($q)) &nbs p; { &nb sp; echo $a.'-<a href="#?db='.$db.'&tbl='.$r_tbl[0].'&id='.$r['id'].'">'.$r['name'].'</a> '.str_replace($word,"<b>$word",$r['comment']).'<br>'; &nb sp; $a++; ; } &nbs p; $niit=$niit+$total; } } } echo 'Total found records : '.$niit; } ? ></p> </body> </html>