Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
im not familiar with PHP, but I'd like to create in Wordpress something like:
if page id="123"
show this -> <div class"option one">my content</div>
if page id="124"
show this -> <div class"option two">my other content</div>
if page id="125"
show this -> <div class"option three">my other content 2</div>
The code will be placed in my page.php
So what is the exact php code?
for example you have page_id 123, 124 ...etc then
Do it as:
<?php if ( is_page(123) ) {
?>
<div class="option one">my content</div>
<?php } elseif( is_page(124) ) {
?>
<div class="option one">abc content</div>
<?php }
else {
echo '<div class="option one">any content</div>';
}
?>
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 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
}
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
If I defined some div in a code like this:
if(...)
{
// code
// code again
if(...)
{
// code
<div> first div </div>
//code code
}
}
<div> second div </div>
So "first div" always appears before the "second div", how can I switch the order of div's displaying? Thanks.
how about this (you need div id's)
$('#secondDiv').insertBefore('#firstDiv').remove();
Change your code to:
if(...)
{
// code
// code again
if(...)
{
// code
<div id='firstDiv'> first div </div>
//code code
}
}
<div id='secondDiv'> second div </div>
You can show the second <div> in a predetermined place by appending it to another div. For example:
HTML:
<div id="fake-second"></div>
<div id="first"> first div </div>
<div id="second"> second div </div>
jQuery:
$("#fake-second").append($("#second").html());
$("#second").hide();
JS Fiddle Demo
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