0
<?php
include("connect.php"); 
$cat_id=$_REQUEST['cat_id'];
$search_key=$_REQUEST['search_key'];
if($search_key != "")
{ 
$sql=mysql_query("SELECT * FROM tbl_products WHERE title LIKE '%$search_key%' OR short_descrp LIKE '%$search_key%' OR description LIKE '%$search_key%'")or die(mysql_error());
$count=mysql_num_rows($sql);
if($count > 0)
{
while($row_city=mysql_fetch_array($sql))
    {
    //echo $row_city['title']."<br>";
    //echo $row_city['short_descrp'];
    ?>    
 <div class="section group">
<div class="city">
<div style="float:left">
    <img src="images/member_posts/<?=$row_city['image1'];?>" title="<?=$row_city['title'];?>"  height="100" width="160" >
</div>
<div style="float:none">
<p><?=$row_city['title'];?></p>
<h1>Rs : <?=$row_city['amount']?></h1>
<p>Negotiable Status&nbsp;:&nbsp;<?=$row_city['negotiable'];?></p>
<a href="product.php?pro_id=<?=$row_city['id']?>&& cat_id=<?=$cat_id?>" class="link">Read More</a>
</div>
</div>
</div>

   <?php
    }
    }
else
?>
<?php
{
echo '<script type="text/javascript">alert("Keyword Does not match");window.location.href="category.php";</script>';
}
}
else
{
?>
<?php
echo '<script type="text/javascript">alert("Please Type to Search");window.location.href="category.php";</script>';
}
mysql_close($con);
?>


in this code, for me, alert box is not working????? what is the problem??? in my code...

ONclick only working , If i give on submit instead onsubmit its not working....
Tell me where I have error, and What I have to change?

Edited by AntonyRayan: nil

4
Contributors
3
Replies
38
Views
2 Years
Discussion Span
Last Post by joshuajames.delacruz
0

As stated before in some previous threads:

1) Use POST or GET not REQUEST
2) Stop using mysql_* - use mysqli or PDO
3) Separate your PHP and HTML
4) Leave HTML as HTML - no point getting PHP to echo out static markup.

0

using your code i tidied it up a bit the alert box is working.

<?php
    include("connect.php"); 
    $cat_id=$_REQUEST['cat_id'];
    $search_key=$_REQUEST['search_key'];
    if($search_key != ""){ 
            $sql=mysql_query("SELECT * FROM tbl_products WHERE title LIKE '%$search_key%' OR short_descrp LIKE '%$search_key%' OR description LIKE '%$search_key%'")or die(mysql_error());
            $count=mysql_num_rows($sql);
            if($count > 0){
                        while($row_city=mysql_fetch_array($sql))
                        {
                            ?>    
                            <div class="section group">
                            <div class="city">
                            <div style="float:left">
                            <img src="images/member_posts/<?=$row_city['image1'];?>" title="<?=$row_city['title'];?>"  height="100" width="160" >
                            </div>
                            <div style="float:none">
                            <p><?=$row_city['title'];?></p>
                            <h1>Rs : <?=$row_city['amount']?></h1>
                            <p>Negotiable Status : <?=$row_city['negotiable'];?></p>
                            <a href="product.php?pro_id=<?=$row_city['id']?>&& cat_id=<?=$cat_id?>" class="link">Read More</a>
                            </div>
                            </div>
                            </div>
                            <?php
                        }
            }
            else{
            echo '<script type="text/javascript">alert("Keyword Does not match");window.location.href="category.php";</script>';
            }
    }
    else{
            echo '<script type="text/javascript">alert("Please Type to Search");window.location.href="category.php";</script>';
    }

    mysql_close($con);
    ?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.