Php 使用echo在我的页面中显示图像
这是我将从中获取图像的页面代码(工作完美)Php 使用echo在我的页面中显示图像,php,image,get,Php,Image,Get,这是我将从中获取图像的页面代码(工作完美) 这是我的页面,我把图像放进去 <?php ob_start(); session_start(); include('includes/connect.php'); include('includes/phpCodes.php'); $id = $_GET['id']; function showNews() { $data = array( 'id' => $id )
这是我的页面,我把图像放进去
<?php
ob_start();
session_start();
include('includes/connect.php');
include('includes/phpCodes.php');
$id = $_GET['id'];
function showNews() {
$data = array( 'id' => $id );
$base = "includes/getImage.php";
$url = $base. "?" . "id=36";
echo $url;
echo '<img src=includes/getImage.php class="newsImage">';
echo '<h1><p class="subjecTitle">هنا العنوان</p></h1>
<div class="newsContent">
hihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihi
</div>
';
}
?>
<!DOCTYPE html>
<html>
<head>
<title>عينٌ على الحقيقة</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/mainstyle.css">
<link rel="stylesheet" type="text/css" href="css/showstyle.css">
<script lang="javascript">
function logout( myFrame ) {
myFram.submit();
}
</script>
</head>
<body>
<div class="wrapper">
<?php headerCode(); ?>
<div class="content" dir="rtl">
<?php showNews(); ?>
</div>
</div>
</body>
</html>
عينٌ على الحقيقة
功能注销(myFrame){
myFram.submit();
}
我想我错了,有人能告诉我怎么解决吗?对不起,我的英语不好
echo ' <img src=includes/getImage.php class="newsImage">';
echo';
致:
echo';
请注意src
具有“
,并确保包含/getImage.php
返回图像路径已为您清除:
echo '<img src="includes/getImage.php?id=' . $id . '" class="newsImage">';
echo';
应该100%工作(如果$id参数当然有值)
更新以修复缺少的$id变量:
<?php
ob_start();
session_start();
include('includes/connect.php');
include('includes/phpCodes.php');
$id = $_GET['id'];
function showNews(){
$id = $_GET['id'];
$base = "includes/getImage.php";
$url = $base. "?" . "id=36";
echo $url;
echo '<img src="includes/getImage.php?id=' . $id . '" class="newsImage">';
echo '
<h1><p class="subjecTitle">??? ???????</p></h1>
<div class="newsContent"></div>
';
}
?>
为什么要使用两个不同的页面? 将这两个代码放在一个页面中,并简单地执行此操作
<img src=includes/<?php echo $row['image']; ?> class="newsImage">
class=“newimage”>
我想将id作为参数发送到getImage.php只需如下发送:包含/getImage.php?id=1
在getImage.php
中使用$\u GET['id']
若要获取此ID,请将其转换为;仍然无法获取任何内容检查firebug或view souce,查看源代码中的src
的值;@BassamBadr现在查看检查图像路径。只需确认,图像是否存在?解析错误:语法错误,C:\AppServ\www\Eye\show.php第15行的意外“>”是否确定源代码看起来与我提供的完全相同?这将起作用并且不会生成错误。请按现在的样子显示代码。请查看此工作示例:并按右侧的“run”。将生成一个img标记,而不会出现解析错误。您确定第15行的字符串完全相同吗?它可以工作,但图像没有显示sourc外观这样地
<?php
ob_start();
session_start();
include('includes/connect.php');
include('includes/phpCodes.php');
$id = $_GET['id'];
function showNews(){
$id = $_GET['id'];
$base = "includes/getImage.php";
$url = $base. "?" . "id=36";
echo $url;
echo '<img src="includes/getImage.php?id=' . $id . '" class="newsImage">';
echo '
<h1><p class="subjecTitle">??? ???????</p></h1>
<div class="newsContent"></div>
';
}
?>
<img src=includes/<?php echo $row['image']; ?> class="newsImage">