Jump to content

problem assigning a block of html/css with a foreach function to a variable?


glennpb

Recommended Posts

hey guys,

I'm quite new to PHP and i was wondering if someone would be able to help me out with this.

The code i have checks the database to see if a user has provided a Vimeo ID. If they haven't, $video_check will equal a line of html that says the user hasn't added any videos to their portfolio. If the a vimeo ID is present, i want $video_check to equal a bunch of html and css with a foreach function inside that is used to display the users videos from vimeo.

The foreach function works fine when its not assigned to the $video_check variable. How do i structure it so that it displays correctly?

 

If you click on videos on this page you might get a better idea of what i'm talking about.

http://www.myfilmportfolio.ie/profile.php?id=33

 

and here is the code i'm having the problem with:

 

///////  check if user has provided vimeo id  //////////////////////////

$vimeoID = $row["vimeoID"];

$video_check='';

if (empty($vimeoID)){

    $video_check = '<h3>'.$firstname .' has not added any videos to their portfolio</h3>';

    }

    else{

    $video_check = '<div id="stats">

          <div style="clear: both;"></div>

      </div>

      <div id="wrapper">

  <div id="embed"></div>

                <div id="thumbs">

<ul>

<?php foreach ($videos->video as $video): ?>

    <li>

                                    <h4><?=$video->title?></h4>

    <a href="<?php echo $video->url ?>">

    <img src="<?php echo $video->thumbnail_medium ?>" class="thumb" /></a>

    <p><?=$video->description?></p>

                                            <br />

    </li>

    <?php endforeach ?>

</ul>

</div>

</div>';

}

 

 

if anyone could help me out id really appreciate it.

Cheers,

G

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.