Bug of getElementsByTagName in php DomDocument - php

There is this code on php. With the DOMDocument I search for all the img tags then I go through a cycle above them and make a change.
In html there are 5 tags img. And the cycle passes 3 times.
How to solve this problem?
$dom = new DOMDocument();
$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$imgs_t = $dom->getElementsByTagName('img');
$amp_img_src = '/images/front/what_is_dt_video.jpg';
$count_foreach = 0;
foreach( $imgs_t as $img_t ){
$count_foreach++;
$img_alt = '';
$tmp_img_src = $img_t->getAttribute('src');
$img_alt = $img_t->getAttribute('alt');
if($tmp_img_src != $amp_img_src){
$tmp_amp_img = $dom->createElement('amp-img');
$tmp_amp_img->setAttribute('width', 200);
$tmp_amp_img->setAttribute('height', 200);
$tmp_amp_img->setAttribute('src', $tmp_img_src);
$tmp_amp_img->setAttribute('alt', $img_alt);
$img_t->parentNode->replaceChild($tmp_amp_img, $img_t);
}
}
var_dump($count_foreach);
And this is exactly the html that enters the $html variable at the beginning of the php code.
<div class="what_is_dt drop_down_pg">
<div class="drop_down_video drop_down_cont">
<div class="col-sm-7 col-xs-12">
<div class="video_wrap">
<div id="ntx_dt_info_video_link" class="no-padding">
<img src="/images/front/what_is_dt_video.jpg" height="315px" width="481px" alt="Lorem ipsum">
</div>
<div class="what_fx_video_head">
<span>Lorem ipsum</span>
</div>
</div>
</div>
<div class="col-sm-5 col-xs-12 no-padding">
<span class="background_green">
<h2>Lorem ipsum</h2>
<p><em>Lorem ipsum</em></p>
<p><em>Lorem ipsum</em></p>
</span>
[T]CONFIRM_THEORY[/T]
</div>
[T]CONFIRM_THEORY_MOBILE[/T]
<hr />
</div>
<h2 style="margin-top: 40px;"><strong>Lorem ipsum</strong></h2>
<div style="padding-top: 30px;">
<div class="signature-left col-lg-6 col-md-6 col-sm-6 col-xs-12">
<img src="/uploads/docs/th%20Failure%20Swing.png" alt="Lorem ipsum" title="Lorem ipsum" width="200" height="200" />
<span style="font-size: small;"> <strong>Lorem ipsum.</strong></span>
<span style="font-size: small;">Lorem ipsum. </span>
</div>
<div class="signature-left col-lg-6 col-md-6 col-sm-6 col-xs-12">
<img src="/uploads/docs/th%20Nonfailure%20Swing.png" alt="Lorem ipsum" width="200" height="200"/>
<span style="font-size: small;"><strong>Lorem ipsum.</strong> </span>
<span style="font-size: small;">Lorem ipsum.</span>
</div>
</div>
<p style="clear: both; padding-top: 30px;" >Lorem ipsum.</p>
<div style="padding-top: 30px;">
<div class="signature-left col-lg-6 col-md-6 col-sm-6 col-xs-12">
<img src="/uploads/docs/th Failure Swing Bottom.png" alt="" />
<p><span style="font-size: small;"><strong>Failure Swing </strong>Lorem ipsum.</span></p>
</div>
<div class="signature-left col-lg-6 col-md-6 col-sm-6 col-xs-12">
<img src="/uploads/docs/th Nonfailure Swing Bottom.png" alt="Lorem ipsum" width="200" height="200" />
<p><span style="font-size: small;"><strong>Nonfailure Swing</strong>Lorem ipsum.</span></p>
</div>
</div>
<p style="clear: both;"><br /></p>
[T]OUR_LEARNING[/T]
</div>

Related

my amazon cart ATC not response to my css

This is my coding line. the
<?php include '../includes/amazon-cart.php' ?>
is not responsive.
<section class="bg-secondary py-4">
<div class="container">
<div class="row no-gutters">
<div class="col-lg-5">
<img src="https://cdn.truegcloud.com/cholibrium/oto1/cholibrium-up3ds-3-bottles.png" alt="" class="img-fluid d-block mx-auto pb-4 pb-md-0" type="image">
</div>
<div class="col-lg-7">
<h2 class="text-blue text-center">
<b>New Customers Only
<br class="d-none d-md-block">- Price Per Bottle:
<span style="opacity:25%; font-weight: 600;">
<br class="d-none d-lg-block">
<s>$99</s>
</span> $27
</b>
</h2>
<h3 class="text-success text-center" style="font-size:35px;">
<b><u>Savings: $216</u></b>
</h3>
<?php include '../includes/amazon-cart.php' ?>
<form id="buy-form" action="/go/order.php" method="get">
<input type="hidden" name="pid" value="<?php echo ${$funnel.'_SKU'}; ?>">
<button type="submit"
name="submit-test"
value="1"
class="submit-order-btn btn-lg btn-yellow1 p-4 p-relative"
alt="Submit Form"
>
<h3 class="submit-texts m-0"><b>ADD TO ORDER</b></h3>
<div class="loader-wrap">
<span class="loader" style="top: 20%; left: 40%;"></span>
</div>
</button>
<?php if(!isset($_COOKIE['pp_preference']) && isset($_COOKIE['vault'])){ ?>
<p class="text-pink text-center" style="margin-top: 15px !important;text-transform: none;font-weight: 300;font-size: 15px !important;">By clicking "Add To Order" button, your card will automatically be charged.</p>
<?php } ?>
</form>
<div class="row align-items-center justify-content-around">
<div class="col-6">
<img src="https://cdn.truegcloud.com/epishieldplus/up1dssl-4b.png" alt="" class="img-fluid align-self-center d-block mx-auto" type="image">
</div>
<div class="col-6">
<img src="https://cdn.truegcloud.com/epishieldplus/up1dssl-2b.png" alt="" class="img-fluid align-self-center d-block mx-auto" type="image">
</div>
</div>
</div>
</div>
</div>
</section>
but now it became like this
It supposed to be like this

Divs below another with bootstrap 5 and not going to side

I'm trying to align a div like a gallery through a loop,
is there a way to do this efficiently with bootstrap? they just stay one above another. I tried to make more divs, but they repeat the results of first too. I'm using Laravel 9.0 and Bootstrap 5.0
#extends('master')
<body class="bg-light"></body>
<div class="container-fluid">
<div class="px-lg-5">
<?php
if (!empty($sql)) {
foreach ($sql as $value) {
?>
<div class="row">
<!-- Gallery item -->
<div class="col-xl-3 col-lg-4 col-md-6 mb-4 float-left">
<div class="bg-white rounded shadow-sm"><img src="https://bootstrapious.com/i/snippets/sn-gallery/img-1.jpg" alt="" class="img-fluid card-img-top">
<div class="p-4">
<h5> <?php echo $value->name; ?></h5>
<p class="small text-muted mb-0">Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
<p class="small text-muted mb-0">Avaliable: <?php echo $value->quantity ?></p>
<div class="d-flex align-items-center justify-content-between rounded-pill bg-light px-3 py-2 mt-4">
<p class="small mb-0"><span class="font-weight-bold">R$<?php echo $value->price ?></span></p>
<div class="badge badge-danger px-3 rounded-pill font-weight-normal">
<span class="text-dark"><?php echo substr($value->category, 0, 7); ?></span>
</div>
<div>
GET
</div>
<div>
GET
</div>
</div>
</div>
</div>
</div>
<!-- End -->
<?php } ?>
<!-- End -->
<?php } ?>
</div>
<div class="py-5 text-right">Show me more</div>
</div>
</div>
</body>
seeing the code shows you are creating more rows with the foreach. try this code that i provided whether it will solve your issues
<div class="container-fluid"><div class="px-lg-5">
<div class="row">
<?php if (!empty($sql)) {
foreach ($sql as $value) { ?>
<!-- Gallery item -->
<div class="col-xl-3 col-lg-4 col-md-6 mb-4 float-left">
<div class="bg-white rounded shadow-sm"><img src="https://bootstrapious.com/i/snippets/sn-gallery/img-1.jpg" alt="" class="img-fluid card-img-top">
<div class="p-4">
<h5> <?php echo $value->name; ?></h5>
<p class="small text-muted mb-0">Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
<p class="small text-muted mb-0">Avaliable: <?php echo $value->quantity; ?></p>
<div class="d-flex align-items-center justify-content-between rounded-pill bg-light px-3 py-2 mt-4">
<p class="small mb-0"><span class="font-weight-bold">R$<?php echo $value->price; ?></span></p>
<div class="badge badge-danger px-3 rounded-pill font-weight-normal">
<span class="text-dark"><?php echo substr(
$value->category,
0,
7
); ?></span>
</div>
<div>
GET
</div>
<div>
GET
</div>
</div>
</div>
</div>
</div>
<!-- End -->
<?php } ?>
<!-- End -->
<?php
} ?>
</div>
<div class="py-5 text-right">Show me more</div>
<div class="row"> shouldn't be in the foreach loop. Each item has a single row if you use it in the foreach loop.
Find:
<?php
if (!empty($sql)) {
foreach ($sql as $value) {
?>
<div class="row">
...
</div>
<?php
}
}
?>
Replace with:
<div class="row">
<?php
if (!empty($sql)) {
foreach ($sql as $value) {
?>
...
<?php
}
}
?>
</div>
In bootstap, row is a master container. col means grids inside the container.
egg:
<div class="row">
<div class="col-md-3">
item 1
</div>
<div class="col-md-3">
item 2
</div>
<div class="col-md-3">
item 3
</div>
<div class="col-md-3">
item 4
</div>
</div>
Please check here
link
Your mistake is to loop the main container.
#extends('master')
<body class="bg-light"></body>
<div class="container-fluid">
<div class="px-lg-5">
<div class="row">
<?php
if (!empty($sql)) {
foreach ($sql as $value) {
?>
<!-- Gallery item -->
<div class="col-xl-3 col-lg-4 col-md-6 mb-4 float-left">
<div class="bg-white rounded shadow-sm"><img src="https://bootstrapious.com/i/snippets/sn-gallery/img-1.jpg" alt="" class="img-fluid card-img-top">
<div class="p-4">
<h5> <?php echo $value->name; ?></h5>
<p class="small text-muted mb-0">Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
<p class="small text-muted mb-0">Avaliable: <?php echo $value->quantity ?></p>
<div class="d-flex align-items-center justify-content-between rounded-pill bg-light px-3 py-2 mt-4">
<p class="small mb-0"><span class="font-weight-bold">R$<?php echo $value->price ?></span></p>
<div class="badge badge-danger px-3 rounded-pill font-weight-normal">
<span class="text-dark"><?php echo substr($value->category, 0, 7); ?></span>
</div>
<div>
GET
</div>
<div>
GET
</div>
</div>
</div>
</div>
</div>
<!-- End -->
<?php } ?>
<!-- End -->
<?php } ?>
</div>
<div class="py-5 text-right">Show me more</div>
</div>
</div>
</body>
You had closed your body tag at 2nd line.
Try this:
#extends('master')
<body class="bg-light">
<div class="container-fluid">
<div class="px-lg-5">
<?php
if (!empty($sql)) {
foreach ($sql as $value) {
?>
<div class="d-flex">
<!-- Gallery item -->
<div class="col-xl-3 col-lg-4 col-md-6 mb-4 float-left">
<div class="bg-white rounded shadow-sm"><img src="https://bootstrapious.com/i/snippets/sn-gallery/img-1.jpg" alt="" class="img-fluid card-img-top">
<div class="p-4">
<h5> <?php echo $value->name; ?></h5>
<p class="small text-muted mb-0">Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
<p class="small text-muted mb-0">Avaliable: <?php echo $value->quantity ?></p>
<div class="d-flex align-items-center justify-content-between rounded-pill bg-light px-3 py-2 mt-4">
<p class="small mb-0"><span class="font-weight-bold">R$<?php echo $value->price ?></span></p>
<div class="badge badge-danger px-3 rounded-pill font-weight-normal">
<span class="text-dark"><?php echo substr($value->category, 0, 7); ?></span>
</div>
<div>
GET
</div>
<div>
GET
</div>
</div>
</div>
</div>
</div>
<!-- End -->
<?php } ?>
<!-- End -->
<?php } ?>
</div>
<div class="py-5 text-right">Show me more</div>
</div>
</div>
</body>

style not working when element created using PHP's "echo' '"

I use PHP code to insert some elements in another PHP file, when the elements were originally created inside the calling PHP file style worked just fine, but when i replaced the code with an 'include(somephpfile.php)', elements were added the way i wanted them to but style didnt apply.
style doesn't apply to elements created this way:
echo '<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
<div class="wow fadeInLeft animated portfolio-item" data-wow-duration="500ms" data-wow-delay="0ms" style="box-shadow: 0px 10px 12px grey; width:80%">
<div class="img-wrapper">
<img src="booksCovers/';
$queryImage = "SELECT cover from books where bookno = '$temp';";
$resultsImage = mysqli_query($db, $queryImage);
$imagesrc = mysqli_fetch_array($resultsImage);
echo $imagesrc[0];
echo '" class="img-responsive" alt="this is a title" style="width : 450px ; height :320px; " />
<div class="mybooks-overlay">
<div class="desc">
<div class="description">';
$query2 = "SELECT description FROM books WHERE bookno = '$temp';";
$results = mysqli_query($db, $query2);
$book = mysqli_fetch_array($results);
echo $book[0];
echo '
</div>
<a class="details" target="_blank " href=" #">Learn More</a>
</div>
</div>
</div>
<figcaption>
<button class="myButtone">
<div class="insider"> </div>
20. 00$
</button>
<div class="heart"></div>
</figcaption>
</div>
</div>';
but it applied when it was done this way:
<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
<div class="wow fadeInLeft animated portfolio-item" data-wow-duration="500ms" data-wow-delay="0ms" style="box-shadow: 0px 10px 12px grey; width:80%">
<div class="img-wrapper">
<img src="booksCovers/" class="img-responsive" alt="this is a title" style="width : 450px ; height :320px; " />
<div class="mybooks-overlay">
<div class="desc">
<div class="description">
</div>
</div>
</div>
</div>
<figcaption>
<button class="myButtone">
<div class="insider"> </div>
20. 00$
</button>
<div class="heart"></div>
</figcaption>
</div>
</div>

Align items in 3's in PHP using HTML

Good Day All,
I am trying to align items in a row of 3. At the top of each row there is a div called "". The purpose of this div is to open a new and after every 3 items the div must be close and another one opened. I have tried the below code to my suprise it is not working. This is very weird as the MOD operand should work. Cna any of you see what I could be doing wrong?
The write picture should look like this
It is out of alignment and the blue colour fills the whole page. I do not know what I am doing wrong:
$currentRow = 1;
echo '<div class="top-box">';
while($Data=mysqli_fetch_array($Result))
{
echo '<div class="col_1_of_3 span_1_of_3">
<a href="Single.php?Query='.$Data[5].'">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/'.$Data[14].'" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">'.$Data[11].'</p>
<div class="price1">
<span class="actual">R'.$Data[13].'</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>';
$currentRow++;
if($currentRow % 3 == 0)
{
echo '</div> ';
echo '<div class="top-box">';
}
}
When I manually repeat the items every 3 items like below, it works perfectly:
<div class="top-box">
<div class="col_1_of_3 span_1_of_3">
<a href="Single.php">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/1st_Party_Boy.jpg" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">His First Party</p>
<div class="price1">
<span class="actual">R350.00</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>
<div class="col_1_of_3 span_1_of_3">
<a href="Single.php">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/Her_First_Party.jpg" height="300" width="320" alt=""/>
</div>
<div class="sale-box"><span class="on_sale title_shop">New</span></div>
<div class="price">
<div class="cart-left">
<p class="title">Her First of Many </p>
<div class="price1">
<span class="actual">R350.00</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>
<div class="col_1_of_3 span_1_of_3">
<a href="Single.php">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/First_one_for_boys_and_girls.jpg" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">Their First Birthday</p>
<div class="price1">
<span class="actual">R350.00</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>
<div class="clear"></div>
</div>
Hey change $currentRow to zero
$currentRow = 0;
echo '<div class="top-box">';
while($Data=mysqli_fetch_array($Result))
{
echo '<div class="col_1_of_3 span_1_of_3">
<a href="Single.php?Query='.$Data[5].'">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/'.$Data[14].'" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">'.$Data[11].'</p>
<div class="price1">
<span class="actual">R'.$Data[13].'</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>';
$currentRow++;
if($currentRow % 3 == 0)
{
echo '</div> ';
echo '<div class="top-box">';
}
}

Why PHP include Not Hidden inside the div with bootstrap 4

I Used Php include to include the info inside of the modals for the albums and for some reason its including the correct file but its not hidden as i specified in the div class where I have included it. you can visit the music page on https://www.trillumonopoly.com but here is the code for the music page where i included the musicmodals.php info page. Funny thing is it doesnt display all of the content. just the very last div. why is this even visible? How can I fix? I cant include the code of the music modal page ... too much for the text area... but
<html>
<head>
<style>
.general {
background : url("img/parallaxmain1.jpg") repeat fixed 100% !Important;
background-size: cover;
}
.album {
width: 90%;
height: 650px;
margin:0 auto;
overflow-x: auto;
overflow-y: hidden;
background : url("img/featured.jpg") repeat fixed 80% !Important;
background-size: cover;
}
.songlist {
width: 85%;
margin: 0 auto;
font-size: 90% !important;
height: 200px:
overflow-x: auto;
overflow-y: hidden;
}
.albumback {
background : url("img/featured.jpg") repeat fixed 80% !Important;
background-size: cover;
}
</style>
</head>
<body><center><font size="2em">
<div class="general">
<div class="header">
<div class="col-6 ">
<img src="img/mediahead.png" class="img-fluid">
</div>
<div class="col-6 ">
</div>
</div>
<div class="discography row container">
<div class="col-lg-3 col-md-4 col-sm-6 box2"><br>
<a href="#BlueLines" data-lity>
<img src="music/011BlueLines/bluelines.jpg" class="img-fluid">
</a>
<hr style="background-color:#ffffff"><br>
<div class="video description">
Artist: T. Cartel <br>
Title: BLUE LINES & BIG FACES<br>
Release: 2015<br>
</div><br>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 box2"><br>
<a href="#YungNGettinIt" data-lity>
<img src="music/010YungNGettinIt/yung.jpg" class="img-fluid">
</a>
<hr style="background-color:#ffffff"><br>
<div class="video description">
Artist: T. Cartel <br>
Title: Yung N Gettin It<br>
Release: 2014<br>
</div><br>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 box2"><br>
<a href="#RNL" data-lity>
<img src="music/009RNL/rnl.jpg" class="img-fluid">
</a>
<hr style="background-color:#ffffff"><br>
<div class="video description">
Artist: T. Cartel <br>
Title: RNL<br>
Release: 2014<br>
</div><br>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 box2"><br>
<a href="#GodsHand" data-lity>
<img src="music/008GodsHand/godshand.jpg" class="img-fluid">
</a>
<hr style="background-color:#ffffff"><br>
<div class="video description">
Artist: T. Cartel <br>
Title: GodsHand<br>
Release: 2013<br>
</div><br>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 box2"><br>
<a href="#AG" data-lity>
<img src="music/007IAmAG/IamAGFront.jpg" class="img-fluid">
</a>
<hr style="background-color:#ffffff"><br>
<div class="video description">
Artist: ZAREYAH <br>
Title: I AM A G<br>
Release: 2011<br>
</div><br>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 box2"><br>
<a href="#KeepItG" data-lity>
<img src="music/006KeepItG/keepItGFront.jpg" class="img-fluid">
</a>
<hr style="background-color:#ffffff"><br>
<div class="video description">
Artist: T. Cartel <br>
Title: Keep It G<br>
Release: 2012<br>
</div><br>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 box2"><br>
<a href="#Gunsmoke" data-lity>
<img src="music/005GunsmokeNResin/gunsmoke.jpg" class="img-fluid">
</a>
<hr style="background-color:#ffffff"><br>
<div class="video description">
Artist: T. Cartel <br>
Title: GunsSMoke & Resin<br>
Release: 2011<br>
</div><br>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 box2"><br>
<a href="#Divine1" data-lity>
<img src="music/004DGvol1/DGvol1front.jpg" class="img-fluid">
</a>
<hr style="background-color:#ffffff"><br>
<div class="video description">
Artist: Divine Grind <br>
Title: Vol. 1<br>
Release: 2010<br>
</div><br>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 box2"><br>
<a href="#PotentAlbum" data-lity>
<img src="music/003PotentAlbum/potentalbumfront.jpg" class="img-fluid">
</a>
<hr style="background-color:#ffffff"><br>
<div class="video description">
Artist: T. Cartel <br>
Title: The Potent Album<br>
Release: 2006<br>
</div><br>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 box2"><br>
<a href="#2Potent" data-lity>
<img src="music/002The2PotentAlbum/toopotentalbumfront.jpg" class="img-fluid">
</a>
<hr style="background-color:#ffffff"><br>
<div class="video description">
Artist: T. Cartel <br>
Title: 2 Potent Album<br>
Release: 2005<br>
</div><br>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 box2"><br>
<a href="#DoinNumbers" data-lity>
<img src="music/001DoinNumbers/DoinNumbersFront.jpg" class="img-fluid">
</a>
<hr style="background-color:#ffffff"><br>
<div class="video description">
Artist: T. Cartel <br>
Title: Doin Numbers<br>
Release: 2005<br>
</div><br>
</div>
</div>
</div>
<center>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7512006871298343"
data-ad-slot="7265345115"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<!--footer-->
© ILLUMONOPOLY LLC. ALL RIGHTS RESERVED. </center>
<div class="d-none invisible">
<?php include("/customers/b/b/3/trillumonopoly.com/httpd.www/pages/musicmodals.php");?>
</div>
</body>
</html>
An extra closing was before the last modal allowing it to close the last div that contained all the modals. Simply removed the closing and all the content became hidden.

Categories