我有代码,它输出我需要的图像和文本。问题是我尝试了所有CSS样式,可以尝试使其在左侧输出图像,在右侧输出文本。有人可以帮我吗,似乎是在警报块输出时,$ service-> serviceName似乎是一起输出而不是单个输出。
template.php
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><?php echo $title; ?></title>
<link rel="stylesheet" type="text/css" href="Styles/Stylesheet.css" />
</head>
<body>
<div id="banner">
</div>
<div id="alertblock"></div>
<footer>
<p>All rights reserved</p>
</footer>
</div>
</body>
</html>
index.php
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-3.3.1.min.js">,</script>
<script src="js/sendrequest.js"></script>
<script>$(document).ready(function(){
sendRequest();
setInterval(function(){
sendRequest();
},60000);
})</script>
</head>
<body>
</body>
<?php
include 'Template.php';
?>
</html>
test.php
<?php
//$emails = imap_search($inbox, 'ALL');
$emails = imap_sort($inbox, SORTARRIVAL,1);
$output = '';
$jsonfile = file_get_contents("test.json");
$decoded = json_decode($jsonfile);
//print_r($jsonfile);
foreach ($decoded as $service) {
//print_r($service);
echo "<div id=".$service->id."Service>";
echo $service->serviceName;
foreach ($emails as $mail) {
$looptimes =0;
$headerInfo = imap_headerinfo($inbox, $mail);
//$output .= $headerInfo->subject . '<br/>';
//print_r($headerInfo->subject);
if ($headerInfo->subject == $service->downSubject) {
// prints out image
echo '<img src="Images/red.png";/>','<br>','<br>';
break;
}elseif ($headerInfo->subject == $service->upSubject) {
echo'<img src="Images/green.png"; />','<br>','<br>';
break;
}
else
{
$looptimes++;
}
}
sendrequest.js
function sendRequest()
{
$("#alertblock").load("php/test.php", function () {
$(this).unwrap();
});
}
答案 0 :(得分:0)
通过设置代码的方式很难理解代码在做什么,并且不清楚要实现的目标。您能否在没有PHP的情况下发布您在浏览器中获得的HTML,以便人们可以看到问题?
首先回显的是左侧。您要先回显图像然后再回显文本吗?
示例:
<div id="idService">
text first, before image
<img src="http://flatable.phoenixcoded.net/default/assets/images/user.png"; /><br><br>
<img src="http://flatable.phoenixcoded.net/default/assets/images/user.png"; />text after image<br><br>
</div>