如果图像点击我想重定向另一页

时间:2015-04-10 06:40:46

标签: php html

我有滑块图片列表。此列表图像具有id。如果id变为等于24这样的特定数字(这是我想在点击图像后移动另一页的图像)

代码

<?php
$sql = "select * from ".$tblImages." Where cid=1 Order by image_order";
$rs  = mysql_query($sql) or die (mysql_error());
$i=0;
while( $row = mysql_fetch_array($rs)) {
    $autoid = $row['id'];
    $title = $row['title'];
    $sub_title = $row['sub_title'];
    $textarea_top = $row['textarea_top'];
    $textarea_width = $row['textarea_width'];
    $images = $row['images'];
    $image_order = $row['image_order'];
    if($textarea_top !=''){
        $_top =' top:'.$textarea_top.'px;'; 
    }else{$_top ='';}
    if($textarea_width !=''){
        $_width =' width:'.$textarea_width.'px;';   
    }else{$_width ='';}
        echo "if ($autoid == 24) 
             { 
               <a href ="fund.html"> </a> "  
              /*this is the image  become appear in a wall you click
              and have to go another page like fund.html */
             } ;
?>

2 个答案:

答案 0 :(得分:1)

而不是

<a href ="fund.html"> </a> " 

你可以使用

header("Location: /index.php"); 

echo '<script type="text/javascript">
     window.location = url;
</script>';

答案 1 :(得分:1)

而不是这样做:

if ($autoid == 24) 
{ 
  echo "<a href ='fund.html'><img src='your/img/path/here'/></a>";
}

您可以使用JavaScript为您解决问题:

if ($autoid == 24){
  echo "<li id='feature-6' class='feature_thumb' onclick='window.location=\"fund.html\"'>
           <a href='assets/home/slider_5.jpg'>
                <div class='textArea slide_7' style='top:365px; width:600px;'>
                      <h1>Effective Fundraising</h1>
                      <p>the Eternal Struggle of NGO's Countered</p>
                </div>
            </a>
        </li>";
}

参考:http://www.w3schools.com/jsref/event_onclick.asp