动态添加的链接不会在php

时间:2016-05-19 07:26:45

标签: php

我已经添加了图像和相应的链接到数据库并在索引页面上查看,问题是当我点击它进入当前页面的图像时,它没有打开与图像相关的相应链接。但同样在选框中工作正常。

添加图片和链接的代码是

<?php
    include_once("../init.php");
    validation_check($_SESSION['UID'], SITE_HOME_ADMIN);

    $msg='';
    if(isset($_POST['save']))
    {
        $upDir ='../'.VIDEO;
        $videourl = $_POST['videourl'];

        $insertSql =("INSERT INTO videonews (videourl) 
        VALUES ('$videourl')");
        $insertSql="INSERT INTO ".VIDEONEWS." SET 
            `adv_url`           = '".realStrip($_POST['adv_url'])."'";
        $query = mysql_query($insertSql);
        $adv_id = mysql_insert_id();
        $adv = '';
        if($_FILES["adv"]['name']!= ''){
            $fileData  = pathinfo(basename($_FILES["adv"]["name"]));
            $adv = $adv_id . '_adv.' . $fileData ['extension']; 
            move_uploaded_file($_FILES["adv"]["tmp_name"], $upDir . $adv);
        }
        $upSql="UPDATE ".VIDEONEWS." SET `adv` = '".$adv."' WHERE id = '$adv_id'";
        $query = mysql_query($upSql);

        $msg = '<h3>Record Saved</h3>'; 
    }

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Video News</title>
<link rel="stylesheet" type="text/css" href="headerstyle.css" />

<script type="text/javascript">


</script>
</head>
<body>
07/25/2014
<div class="fixx">
  <?php include('header.php');?>
</div>
<div class="tabl">
  <table width="700" border="0">
    <tr>
      <td><form action="news1.php" method="post" enctype="multipart/form-data">
          <table width="900" border="1" cellpadding="10">
            <tr>
              <td colspan="2"><h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADD Files To Video News  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="news1_list.php"> EDIT</a> </h3></td>
            </tr>
            <tr>
              <td colspan="2"><?php echo $msg;?></td>
            </tr>
            <tr>

              <td><input type="file" name="adv" id="adv" /><input type="text" placeholder="URL" name="adv_url" id="adv_url" size="50" /></td></tr>
            </tr>

            <tr>
                <td>Video Link <input type="text" name="videourl" id="videourl" size="100" /></td></tr>
             <tr> <td><input type="submit" name="save" id="save" value="Submit" /></td></tr>

          </table>
        </form></td>
    </tr>
  </table>
</div>
</body>
</html>

检索文件代码是

<?php 

validation_check($_SESSION['UID'], SITE_HOME_ADMIN);
    $msg='';
    $adDir ='./'.VIDEO;

$qr = mysql_query("select * from ".VIDEONEWS) or die('Error in connection');
while($rs = mysql_fetch_array($qr))
{
    $adv = '';
    if($rs['adv']!='') {
        $adv = '<a href="'.$adv['adv_url'].'" target="_blank"><img src="'.$adDir.$rs['adv'].'" style="width:250px; height:150px" >&nbsp; </a>';
    }
    $image = $adv;
 $msg .='<tr>
    <tr>'.$image.'</tr>


  </tr>';
}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Videonews Lists</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="headerstyle.css" />
</head>

<body>

<div class="tabl">
<table width="100%" border="0" align="center" class="main">

    <td>
<table width="95%" border="1" align="center" cellpadding="10">


 <?php echo $msg;?>
</table>
</td></tr></table>
</body>
</html>

检索文件包含在index.php中,以显示帧中的所有图像。

索引页面中的Marquee代码正常工作

<div class="ads-242x90 right">
                <a href="#"> <strong>VIDEO NEWS</strong></a>

                <marquee direction="up" scrollamount="2"  onmouseover="this.stop();"   onmouseout="this.start();">
            <div align="left" >
            <span style="text-transform:uppercase;">  
              <?
                $qryAdv = mysql_query("SELECT * FROM ".VIDEONEWS." WHERE 1");
                if(mysql_num_rows($qryAdv) > 0)
                {
                    while($adv = mysql_fetch_assoc($qryAdv))
                    {
              ?>
             <a href= "#" onClick="window.open('<?=$adv['adv_url']?>', '_blank')"><img src="<?=VIDEO.$adv['adv']?>" width="98%"  height="90" alt=""></a> <br /> 
              <?
                    }
                } else { echo 'NO ADDS FOUND!!!'; }
              ?>
              </marquee>

1 个答案:

答案 0 :(得分:0)

你应该做的第一件事是保护自己免受SQL注入,阅读它。

我认为你的问题在于:

$scope.list_of_holidaytypes = [{holidayName:'Name1' }, {holidayName:'Name2' }];

我认为应该是

$adv = '';  ///you set $adv equal to empty string
if($rs['adv']!='') {      //VVVV here you try to use your empty string
    $adv = '<a href="'.$adv['adv_url'].'" target="_blank"><img src="'.$adDir.$rs['adv'].'" style="width:250px; height:150px" >&nbsp; </a>';
}