jason360 Posted January 16, 2015 Share Posted January 16, 2015 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 More sharing options...
QuickOldCar Posted January 16, 2015 Share Posted January 16, 2015 You need to echo it as well echo '</ul> </section>'; Link to comment https://forums.phpfreaks.com/topic/293974-query-within-an-echo/#findComment-1503116 Share on other sites More sharing options...
jason360 Posted January 16, 2015 Author Share Posted January 16, 2015 Thanks QuickOldCar...that was simple. Link to comment https://forums.phpfreaks.com/topic/293974-query-within-an-echo/#findComment-1503190 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.