ydeonia Posted April 7, 2013 Share Posted April 7, 2013 (edited) Hi Can anybody plese help me in groping the movies under same cinema in this code <?php if(count($showtimes)==0): echo '<div class="invalid_city">'.$textnost.'</div>'; else: $i = 0; $ciName = ''; $count = count($showtimes); foreach ($showtimes as $st): ?> <div class="showtime <?php echo $i+1; ?>" id="accordion"> <h4 class="stime_heading <?php echo $i; ?>"><a href="javascript:void(0);"><span><?php echo $st['cinema_name']; ?></span> </a></h4> <div class="listmovies_cont"> <?php if($address_show): ?> <div class="address_movies"><?php echo $st['address']; ?></div> <?php endif; ?> <ul class="list_movies"> <li> <span class="tit_movie"> <a class="modal" id="popup" rel="{handler: 'iframe', size: {x: 970, y: 600}}" href="http://www.imdb.com/find?s=tt&q=<?php echo $st['movie_name']; ?>"> <?php echo $st['movie_name']; ?></a> </span></br> <?php echo $st['cast']; ?> <?php if($show_times): ?> <span class="time_movie"><?php echo$st['show_time']; ?> <?php $results = $dispatcher->trigger('onBeforeDisplayContent', array (& $st, & $params)); echo $results[3]; ?> </span> <?php endif; ?> </li> </ul> </div> </div> <?php $i++; $ciName = $st['cinema_name']; endforeach; ?> Now this code displays cinema name with single movie . But there are multiple movie running in same cinema. I want to show them in same cinema with movie name ,cast and showtime. here in below table I want to group movies with cinema Id Here is the table structure Thanks Edited April 7, 2013 by ydeonia Quote Link to comment https://forums.phpfreaks.com/topic/276631-little-help-please/ Share on other sites More sharing options...
Jessica Posted April 7, 2013 Share Posted April 7, 2013 I wrote a tutorial that addresses this: http://thewebmason.com/tutorial-parent-child-lists/ You'll want to store the cinema in a variable and compare the previous one to the current one. Quote Link to comment https://forums.phpfreaks.com/topic/276631-little-help-please/#findComment-1423380 Share on other sites More sharing options...
Barand Posted April 7, 2013 Share Posted April 7, 2013 (edited) If ever a table was in need of normalization it's that one ( as I have mentioned before ). If you are going to use MySql, use it as a relational database, with the advantages that brings, and not a collection of spreadsheets. Just my 0.02 worth Edited April 7, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/276631-little-help-please/#findComment-1423466 Share on other sites More sharing options...
ydeonia Posted April 8, 2013 Author Share Posted April 8, 2013 If ever a table was in need of normalization it's that one ( as I have mentioned before ). If you are going to use MySql, use it as a relational database, with the advantages that brings, and not a collection of spreadsheets. Just my 0.02 worth I didn't understand your point. Sorry . Yes this is mysql . I want to display the parents as cinemas and child as movies. Quote Link to comment https://forums.phpfreaks.com/topic/276631-little-help-please/#findComment-1423469 Share on other sites More sharing options...
Barand Posted April 8, 2013 Share Posted April 8, 2013 (edited) I didn't understand your point. My reply to previous post - view the videos in the link http://forums.phpfreaks.com/topic/276568-condition-help/?do=findComment&comment=1423062 Edited April 8, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/276631-little-help-please/#findComment-1423472 Share on other sites More sharing options...
ydeonia Posted April 8, 2013 Author Share Posted April 8, 2013 I wrote a tutorial that addresses this: http://thewebmason.com/tutorial-parent-child-lists/ You'll want to store the cinema in a variable and compare the previous one to the current one. Hi Jessica , After reading your blog , I created the page and it worked ! Loads of Love for you . Thank you <?php mysql_connect("localhost","test","test"); mysql_select_db("test_db"); //select the table $result = mysql_query("select cinema_name ,cast,show_time, cinemaId, movie_name , m.id from jos_cinema as c INNER JOIN #__movie as m ON m.id=c.movie_id ORDER BY c.cinemaId ASC,m.id ASC") or die ('Error: '.mysql_error ()); while ($row = mysql_fetch_array($result)){ if($last_cinema != $row['cinema_name']){ echo "<h3>{$row['cinema_name']}</h3>"; $last_cinema = $row['cinema_name']; } echo "<br /><b>{$row['movie_name']}</b><br />"; echo" {$row['cast']}<br />"; echo "{$row['show_time']}"; } ?> My reply to previous post - view the videos in the link http://forums.phpfreaks.com/topic/276568-condition-help/?do=findComment&comment=1423062 Hi Barand , I read your topic and I learned many new things . Thanks alot. Quote Link to comment https://forums.phpfreaks.com/topic/276631-little-help-please/#findComment-1423487 Share on other sites More sharing options...
Jessica Posted April 8, 2013 Share Posted April 8, 2013 (edited) You're missing the part where you define $last_cinema before you ever try to use it, if you turn on strict error reporting you'll see a warning or notice. Otherwise good. Definitely normalize the tables though, I didn't see the original screenshot before, and Barand is 100% right, you need to fix your structure. Also a line like this: echo "{$row['show_time']}"; just adds extra processing. No need to put a variable in strings to echo it. Edited April 8, 2013 by Jessica Quote Link to comment https://forums.phpfreaks.com/topic/276631-little-help-please/#findComment-1423509 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.