Jump to content
Sign in to follow this  
KalashaLv

php loop

Recommended Posts

Heey! Cik es skatos mātē googlē, jau otro dienu nevaru atrast pareizo risinājumu, kā dabūt manu skriptu darboties.
Cik es saprotu, tam ir jābūt loopam, vai kam līdzīgam.

Man ir news skripts, kurš izvelk 2 news no foruma. Pēc dizaina, man ir vēlme dabūt vienu news ar vieniem divs, bet otru ar savādākiem.
Teiksim tā, kad man ir viens news uz float:left, bet otrs uz float:right;
Lai ko es mēģinātu, viņš duplicēs man divus/trīs/četrus/simts vienādus news , katru ar savu float.

Teiksim tā, ka man ir viens posts ar nosaukumu "Čau" un otrs ar "Hello", viņš atkārtos 2 reiz "Čau" ar float: left un float: right. un ar Hello būs tas pats. Bet ja es uzlikšu, lai neatkārto postus, abi divi būs float:left;

Šeit ir viens ko es mēģināju.

 

<?php
for ($counter = 1; $counter < 2; $counter++ ) {
     if ($counter % 2 == 0) {
            echo '
			<section class="mbr-section content7 cid-rtdgTjs5VO" id="content7-6">
<div class="container">
        <div class="media-container-row">
            <div class="col-12 col-md-8">
                <div class="media-container-row">
                    <div class="media-content">
                        <div class="mbr-section-text">
                            <p class="mbr-text align-right mb-0 mbr-fonts-style display-7">
							<strong data-toggle="tooltip" data-placement="top" title="'.$post_title.'">'.smaller($post_title,20).'</strong> '.strip_tags(smaller($post_text,300)).'</p>
                        </div>
                    </div>
                    <div class="mbr-figure" style="width: 60%;">
                     <img src="assets/images/background1.jpg" alt="News">  
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
			';
     } else {
echo '
			  <section class="mbr-section content6 cid-rtdgSE8ViC" id="content6-5">
<div class="container">
        <div class="media-container-row">
            <div class="col-12 col-md-8">
                <div class="media-container-row">
                    <div class="mbr-figure" style="width: 60%;">
                      <img src="assets/images/background1.jpg" alt="News">  
                    </div>
                    <div class="media-content">
                        <div class="mbr-section-text">
                            <p class="mbr-text mb-0 mbr-fonts-style display-7">
                               <strong data-toggle="tooltip" data-placement="top" title="'.$post_title.'">'.smaller($post_title,20).'</strong> '.strip_tags(smaller($post_text,300)).'</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
';
	 }		 
   }
?>

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.