Displaying icons using php IF - php

Just wondering, I'm creating a multi-vendor website. So far it has all been going well, however we have a need to display icons as badges if a field contains data.
Here is an example of the code:
<li class="location clearfix">
<div class="pull-left">
<span><i class="fa fa-briefcase"></i><?php _e('abn ',) ?></span>
</div>
<div class="pull-right">
<?php echo $abn; ?>
</div>
</li>
When displaying the field abn it appears fine, although we are wanting an icon displayed if abn contains data. We are needing the Echo to be an IF statement, that if the profile ``abn``` field contains data, that an icon is displayed.
Just wondering, is there any examples that anyone would have using an existing script?
Thanks for helping!

Try this,
add if condition with !empty()
<?php if(!empty($abn)) {?>
<li class="location clearfix">
<div class="pull-left">
<span><i class="fa fa-briefcase"></i><?php _e('abn ',) ?></span>
</div>
<div class="pull-right">
<?php echo $abn; ?>
</div>
</li>
<?php } ?>
you can add this if condition wherever you want to hide or display data.

Related

ACF Content Not Showing

I have created ACF Fields for Wordpress User page Text and image When I try to display on single.php its not showing nither image or text is showing below is screenshot for refrence.
https://prnt.sc/ezFU-JPZH3Rs
<ul class="list-unstyled">
<li>
<div class="row">
<div class="col-4">
<div class="home-blog-author">
<?php
$avatar_image= get_field('user_image', 'user_'. $author_id );
?>
<picture>
<img src="<?php echo $avatar_image['url']; ?>" class="img-fluid" alt="<?php echo $avatar_image['alt']; ?>">
</picture>
</div>
</div>
<div class="col-8 align-self-center ps-0">
<div class="home-author-name">
<h5><?php //echo the_field('user_name', 'user_' .$author_id); ?></h5>
</div>
</div>
</div>
</li>
<li>
<i class="fas fa-calendar-alt"></i>
<span><?php echo get_the_date('d/m/Y'); ?></span>
</li>
</ul>
You know that in your snippet you have the name text commented out, right? Otherwise you have multiple possible failure points. Off the top of my head:
Are you sure you're retuning the html as expected (with or without the ACF data)? If not, then you may have the wrong template or other problems. If so:
Are you sure you have the ACF user_image field set to return an array - and in particular for the user you're testing?
Have you tried returning the ACF field by key rather than field name? That sometimes helps.

How to move articles to the beginning of the first page after the category is chosen

I´m making a site for myself and I´ve been stuck with this issue. The site has several categories, for example geometry -> triangles. When I'm scrolling through articles and do not have a filtered category on yet, everything is ok. But when I filter categories and choose a specific one, for example triangles, all other articles that do not concern triangles get hidden. But that's not the issue. The problem is, if the articles for triangles where on the page 3 while the filter was off and you could see all the articles all together, then even after the filter is on the chosen category will be left on the page 3 and won't move to the first page. How do I fix this?
bodyOfmainPage.php
<main class="index-main">
<section class="articles">
<div class="article_content container container--pall">
<h1 class="heading">მთავარი გვერდი</h1>
<div class="article_grid">
<?php $idM=get_size(); ?>// number of articles
<?php for($id=$idM;$id>0;$id--): ?>
<?php $idN= get_num_size($id);?>
<div class="article_item" href="#" data-id ="<?= intval(($idM - $id)/4 + 1) ?>" data-category="<?= get_data_category($id) ?>">
<div class="article_image" style="background-image: url('<?= get_img_url($id) ?>')"> </div>
<div class="article-text">
<div class="article_date"><?= get_article_date($id) ?></div>
<div class="article_title"><?= get_article_title($id) ?></div>
<div class="article_description"><?= get_article_description($id) ?></div>
<div class="hashtag"><?= get_hashtag($id) ?></div>
<div class="butt">
<a class="AB" href="<?= get_article_link($id) ?>">
<button type="button" class="clickA" >გადასვლა</button></a>
</div>
</div>
</div>
<?php endfor; ?>
</div>
</div>
</section>
<div class="num">
<ul class="contentNum">
<li class="navigation" data-id ="1">1</li>
<li class="navigation" data-id ="2">2</li>
<li class="navigation" data-id ="3">3</li>
<li class="navigation" data-id ="4">4</li>
<li class="navigation" data-id ="5">5</li>
</ul>
</div>
</main>

database values not displaying in carousal in codeigniter php

i have a website in which i used carousel sliders to display images and its values, I have 3 carousel in my homepage, 3 of them have same code, however the first carousel is not displaying name and price like the 2nd and 3rd carousel:
as you can see in the image
the code for this carousel is below:
<section class="carousel_sec">
<div class="container">
<div class="row ">
<h3 class="carousel_heading">Trending Birthday Cakes <button class="pull-right"><span>VIEW ALL</span><!-- <span class="visible-xs">>></span> --></button></h3>
<hr>
<div class="carou">
<div class="demo">
<ul id="landing_products1">
<?php foreach($trending_products1 as $key=>$val) { ?>
<li>
<div class="item">
<div class="pad15 content_div">
<div class="carou_thumb">
<img class="st_img" src="<?php echo ADMIN_IMG.'cakes/'.$val['image'][0]['cake_image'];?>" alt="<?php echo $val['cake_name']; ?>" />
<img class="nd_img" src="<?php echo ADMIN_IMG.'cakes/'.$val['image'][0]['cake_image'];?>" alt="<?php echo $val['cake_name']; ?>" />
<p>
<?php echo $val['cake_name']; ?>
</p>
<?php
$btp_price=0;$offer_price=0;
$btp_price=$val['price'][0]['btp_price'];
$offer_price=$val['price'][0]['offer_price'];
?>
<div class="price text-center" style="width:100%;float:left;">
<span class="amount" style="color:#f2136e;font-size:14px;">
<?php echo PRICE_UNIT;?><?php echo $offer_price;?>
</span> (
<s> <?php echo $btp_price;?></s>)
<span> </span>
<br>
</div>
<!--<br><span><?php echo PRICE_UNIT;100; ?></span></p>-->
</div>
</div>
</div>
</li>
<?php } ?>
</ul>
</div>
</div>
</div>
</div>
</section>
<?php } ?>
while inspecting in browser the value is showing, the live URL is enter link description here
can anyone please tell me what could be wrong here, thanks in advance
You'll need to tweak the css to reveal the content that is hidden.
To push you in the direction, see the improvement with:
#landing_products1 {
height: 330px;
margin-top: -65px;
}
I don't know how responsive you need to be with your UI, so let's call this a temporary fix. The first carousel's dimensions don't perfectly match the others, so I'll leave the fine tuning to you.
It also appears that you have some js and css issues to mop up.

fetching data in while loop in list tag

while($recor1=mysql_fetch_assoc($res1))
{
?>
<ul>
<li class="col-md-3 col-sm-3"><div class="dest-list"><?php echo $recor1['sub_destination']; ?></div> </li>
</ul>
<div class="clearfix"></div>
<?php
}
it displays the result horizontally i want it vertically please give me soluation
there are a number of things wrong with your code, why are you adding a new list for every item with only one list item, that makes no sense. Also do not add block elements inside inline elements (div inside a). Also if you what the list items under each other then why add the col-... class?
<ul>
<?php while($recor1=mysql_fetch_assoc($res1)) {?>
<li class="">
<a href="#">
<?php echo $recor1['sub_destination']; ?>
</a>
</li>
<?php } ?>
</ul>
this gives you the right html structure, and you can then style it as you see fit
if you dont want to display a list horizontally remove col-sm-3 class of your li, which changes your code like below
while($recor1=mysql_fetch_assoc($res1)) { ?>
<div class="col-md-3 col-sm-3">
<ul>
<li >
<a href="#">
<div class="dest-list">
<?php echo $recor1['sub_destination']; ?>
</div>
</a>
</li>
</ul>
</div>
<div class="clearfix"></div>
<?php
}
take a look at this example

Assign SQL rows unique pages

sorry if this is a bit vague although I really don't know how to explain this one.
Basically I already have a listing page that lists all of the rows in my database into a html template that lists each row into an eCommerce style category page using PHP.
I am using this code for the listing page using PDO:
<?php while($row = $results->fetch(PDO::FETCH_ASSOC))
{
echo '
<div class="listing-container">
<h3 class="model-listing-title clearfix">'.$row["Make"].' '.$row["Model"].' '.$row["Variant"].'</h3>
<h3 class="price-listing">£'.number_format($row['Price']).'</h3>
</div>
<div class="listing-container-spec">
<img src="'.(explode(',', $row["PictureRefs"])[0]).'" class="stock-img-finder"/>
<div class="ul-listing-container">
<ul class="overwrite-btstrp-ul">
<li class="diesel-svg list-svg">'.$row["FuelType"].'</li>
<li class="saloon-svg list-svg">'.$row["Bodytype"].'</li>
<li class="gear-svg list-svg">'.$row["Transmission"].'</li>
<li class="color-svg list-svg">'.$row["Colour"].'</li>
</ul>
</div>
<ul class="overwrite-btstrp-ul other-specs-ul h4-style">
<li>Mileage: '.number_format($row["Mileage"]).'</li>
<li>Engine size: '.$row["EngineSize"].'cc</li>
</ul>
<button href="#" class="btn h4-style checked-btn hover-listing-btn"><span class="glyphicon glyphicon-ok"></span> History checked
</button>
<button href="#" class="btn h4-style more-details-btn hover-listing-btn tst-mre-btn"><span class="glyphicon glyphicon-list"></span> More details
</button>
<button href="#" class="btn h4-style test-drive-btn hover-listing-btn tst-mre-btn"><span class="test-drive-glyph"></span> Test drive
</button>
<h4 class="h4-style listing-photos-count"><span class="glyphicon glyphicon-camera"></span> 5 More photos</h4>
</div>
';
} ?>
</div>
Now what I want to do is create a page for each of the SQL rows however I am unsure how I can do this, just like an eBay product page really.
My main question is what method could I do to create individual pages that are dedicated to each SQL row?
If anyone could shed a bit of light on this for me it would be much appreciated.
Knowing you can extract data from a page to another using $_POST['name-of-your-element'], I would say to do something like this :
Creating a php page dedicated to display information of one specific row
Putting some $_POST['...'] call to display the exact data
To do this, instead of just displaying your row in your actual page, you should create form for each row, and then adding a submit button for each row which will launch the "display row page" with the correct information. I would see something like this for each row :
<form method = "post" action = "displayData_Make.php">
<div id = "Make" name = "Make">
Make : <?php echo $row['Make'] ?>
</div>
<input type = "submit" value = "more information..." />
</form>
Then in you "displayData_Make.php" receive your information and display them like you want :
<?php
$info = $_POST['Make'];
// Do what you want with this data
// Display, etc...
?>
<!--
Some html code
-->

Categories