اینم محتویات صفحه ajax_search.php
<?php
function checkValues($value)
{
// Use this function on all those values where you want to check for both sql injection and cross site scripting
//Trim the value
$value = trim($value);
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Convert all <, > etc. to normal html and then strip these
$value = strtr($value,array_flip(get_html_translation_table(HTML_ENTITIES)));
// Strip HTML Tags
$value = strip_tags($value);
// Quote the value
$value = mysql_real_escape_string($value);
return $value;
}
include("../Config.php");
$rec = checkValues($_REQUEST['val']);
//get table contents
if($rec)
{
$sql = "SELECT * FROM `TableName` WHERE `filde` LIKE '%$rec%'";
}
else
{
$sql = "SELECT * FROM `TableName`";
}
$rsd = mysql_query($sql);
$total = mysql_num_rows($rsd);
while ($rows = mysql_fetch_assoc($rsd))
{
?>
<div class="each_rec"><a href="<?php echo $rows['filde1'];?>" target="_blank"><?php echo $rows['filde2'];?></a></div>
<?php
}
if( $total == 0 )
{
echo '<div class="no-rec">رکورد یافت نشد</div>';
}
?>