Jump to content

Query within an echo.


jason360

Recommended Posts

Hey guys,

 

I am stuck on this piece of code. Within the function I am using I need to include an mysql query.  I am not sure how to insert it within the echo.  Currently the query works but the code stops once close the '' and </ul> and </section> are cut out.

 

Please note that there is alot more code within the echo, not just the section and ul.  Just simplified it for my question.

 

Any help would be appreciated.

 

Thanks


 
<?php
  $query = mysql_query('SELECT id FROM videos WHERE user="'.$id.'"');
list ($video_id) = mysql_fetch_array($query);


if ($video_id != '') {


 echo '<section>
       <ul >';


       $query = mysql_query('SELECT video FROM videos WHERE id="'.$id.'" ORDER BY RAND()');
                        
       $i = 0;
                        
        class myCounter implements Countable {
        public function count() {
        static $count = 0;
        return ++$count;
        }
        }
                                                
        $counter = new myCounter;
                        
        while ($row = mysql_fetch_array($query))
                        
        {
                        
        if($i % 5 === 0)
                        
        {
                        
                        
        }


echo "<li data-path='feeds/api/videos/".$row['video']."' ></li>";
                                               
        $i++; 
        }
                                            
'</ul>
</section>';


?>
Link to comment
https://forums.phpfreaks.com/topic/293974-query-within-an-echo/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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