Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
All of this needs to be inside my loop so I don't know if I can break it (don't think I can) but I need PHP to read it as HTML.
$movieDetails =
<header class="masthead" role="banner">
<div class="logo-container">
<a class="logo" href="">Movie Details</a>
</div>
</header>
<div class="bubble-container">
<div class="speech-bubble speech-bubble-top">
Text that goes into the bubble
</div>
</div>
You can just close your PHP tag to render text that will display as HTML.
<?php
foreach($movies as $movie) {
?>
<div>
<?php echo htmlspecialchars($movie); ?>
</div>
<?php
}
?>
$movieDetails = <<<HTML
<header class="masthead" role="banner">
<div class="logo-container">
<a class="logo" href="">Movie Details</a>
</div>
</header>
<div class="bubble-container">
<div class="speech-bubble speech-bubble-top">
Text that goes into the bubble
</div>
</div>
HTML;
echo $movieDetails;
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am creating a blog page. I want to create a small highlights section on the home page.
I created the highlight part from the admin panel, when I make changes, it appears from the database, but I cannot pull the information on the front side. Only the name of the blog will appear in the highlights. Where is the problem?
<div class="card text-center my-5">
<div class="card-header baslik-blog">
En Çok Okunan Blog Yazıları
</div>
<ul class="list-group list-group-flush">
<?php
$blogsor=$db->prepare("SELECT * FROM blog where blog_onecikar=:blog_onecikar");
$blogsor->execute(array(
'blog_onecikar' =>1,
));
while($blogcek=$blogsor->fetch(PDO::FETCH_ASSOC)){
?>
<a href="blog-page" class="blog-a">
<li class="list-group-item"><i class="fas fa-angle-double-right float-start"></i>
<?php $blogcek['blog_ad'] ?>
</li>
</a>
<?php } ?>
Tüm Blog Yazıları
</ul>
</div>
change
<?php $blogcek['blog_ad'] ?>
to
<?php echo $blogcek['blog_ad'] ?>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have an Owl slider in my current project, in which up to three images from the database are to be displayed. I can also call up all the data I need without any problems, but if I want to display 2 or 3 pictures in the slider, only the first picture is displayed and the other pictures wont displayed without an error.
What is the problem?
<div class="container" style="margin-top: 10px;">
<div class="owl-carousel owl-theme">
<?php
$operator_one_id = escape($_GET['operator_one']);
$query = "SELECT * FROM strat WHERE player_one_operator_id = $operator_one_id";
$select_operator_one_strat = mysqli_query($connection, $query);
$row = mysqli_fetch_assoc($select_operator_one_strat);
$player_one_operator_id = $row['player_one_operator_id'];
$player_one_image_top = $row['player_one_image_top'];
$player_one_image_ground = $row['player_one_image_ground'];
$player_one_image_base = $row['player_one_image_base'];
echo "<div class='item'><img src='./assets/img/maps/strats/$player_one_image_top' alt='Operator One Top Strat'></div>";
echo "<div class='item'><img src='./assets/img/maps/strats/$player_one_image_ground' alt='Operator One Ground Strat'></div>";
echo "<div class='item'><img src='./assets/img/maps/strats/$player_one_image_base' alt='Operator Base Strat'></div>";
?>
</div>
</div>
![
Left picture 1, right picture 2]1
This is an example of how html is rendered. With the following options you can change almost every class the way you want.
<div class="owl-carousel owl-theme owl-loaded">
<div class="owl-stage-outer">
<div class="owl-stage">
<div class="owl-item">...</div>
<div class="owl-item">...</div>
<div class="owl-item">...</div>
</div>
</div>
</div>
While loop will display all images in database until you not limit query, so, you dont need to specify each image.
Your php codes in while loop should look like this :
<div class="owl-carousel owl-theme owl-loaded">
<div class="owl-stage-outer">
<div class="owl-stage">
<?php while($row = mysqli_fetch_assoc($select_operator_one_strat)){ ?>
<div class="owl-item">
<img src="path-to-image/<?php echo $row['image-name']; ?>" />
</div>
<?php }?>
</div>
</div>
</div>
Documentation : https://owlcarousel2.github.io/OwlCarousel2/docs/api-classes.html
But you are trying to display specific images so your codes should look like this without while loop :
<div class="owl-carousel owl-theme owl-loaded">
<div class="owl-stage-outer">
<div class="owl-stage">
<?php $row = mysqli_fetch_assoc($select_operator_one_strat);?>
<div class="owl-item">
<img src="path-to-image/<?php echo $row['image-1']; ?>" />
</div>
<div class="owl-item">
<img src="path-to-image/<?php echo $row['image-2']; ?>" />
</div>
<div class="owl-item">
<img src="path-to-image/<?php echo $row['image-3']; ?>" />
</div>
<div class="owl-item">
<img src="path-to-image/<?php echo $row['image-4']; ?>" />
</div>
</div>
</div>
</div>
Marquee is another choice
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am having multiple images, for that individual image i am having download button
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<button id='dwn_<? echo $a;?>'>Download</button>
<br>
<? } ?>
</div>
If i click that download button i need to save that corresponding image to my local system.
Kindly give some solution for this.
the easiest way without javascript i think it would ( I edited your code, but i cant try it now)
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<form method="get" action='image_<? echo $a;?>.jpg'>
<button id='dwn_<? echo $a;?>' type="submit">Download</button>
</form>
<br>
<? } ?>
</div>
You can delete the id in button if you only use for download
download.php
.........
<?php
if(isset($_REQUEST) && ($_REQUEST['image_name'])){
$filename = $_REQUEST['image_name'].'.jpg';
// Write download code here
}
display_page.php
............
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<a href="download.php?image_name=<?php echo $a; ?>" >Download</a>
<br>
<? } ?>
</div>
Most easiest way by using html 5
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<a href='image_<? echo $a;?>.jpg' download>
<span id='dwn_<? echo $a;?>'>Download</span >
</a>
<br>
<? } ?>
</div>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have following data in mysql, and I want to echo in this format:
Data:
Name,Image URL,Link
I want to print it dynamically like this : http://screensaver.cf/screensavers.php
I don't know user's screen width, still I want it to appear as much as possible in width.
How can I do this in html and PHP?
My code:
<?php
require("config.php");
?>
<div id="main-wrap">
<div class="container">
<div id="main">
<div id="content"><div id='wsite-content' class='wsite-elements wsite-not-footer'>
<div class="paragraph" style="text-align:left;">
<?php
$sql='SELECT * FROM `games` where 1=1';
$data = mysql_query($sql);
echo '<h4 class="result">Result:</h4>';
while($row = mysql_fetch_row($data)){
$table=WHAT TO DO HERE TO MAKE IT LOOK LIKE THAT???????
echo $table;
echo '<br><br>';
}
?>
</div>
</div>
</div>
</div>
</div>
<?php
include("footer.php");
?>
P.S I know mysql is depreciated and I am constantly working to learn Mysqli, as I am in 8th class, I don't have much time.
<style>.a{float:left;}
</style>
>
in while loop use this
<div class = "a">
<?php <img src='".$row['url']."' width='140' height='140'> ?>
</div>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need the data to have a different style if the sold = 0 in the mysql table
and when i use the code below the website shows a blank white page
(?=$vehicle-> this is the vehicle reference
and sold is the column withing the sql table
<?php
if (?=$vehicle->sold?!= 1)
{
<div class="foo">
<div class="fboverlay"></div>
<a>
<img src="/media.php?productId=<?=$vehicle->vehicle_id?>&file=<?=$vehicle->main_image?>" />
</a>
</div>
}
else {
<img src="/media.php?productId=<?=$vehicle->vehicle_id?>&file=<?=$vehicle->main_image?>" />
}
?>
You need to learn the PHP from the basics. Learn about operators, PHP and HTML secion, etc..
Anyway, i fixed your code. The condition is if $vehicle->sold is not equal to 1. But i think, (in your OP you mentioned it should be 0) you want this: $vehicle->sold == 0
//Use sytnax like this. See php opeartors.
if ($vehicle->sold != 1) {
?> <!-- Close the php -->
<div class = "foo">
<div class = "fboverlay"></div>
<img src = "/media.php?productId=<?= $vehicle->vehicle_id ?>&file=<?= $vehicle->main_image ?>" />
</div>
<?php
//Open the php again
} else {
?> <!-- close the php -->
<img src = "/media.php?productId=<?= $vehicle->vehicle_id ?>&file=<?= $vehicle->main_image ?>" />
<?php //Open again
}