Jump to content

Recommended Posts

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

PEWP21g.png

 

 

Thanks 

Edited by ydeonia
Link to comment
https://forums.phpfreaks.com/topic/276631-little-help-please/
Share on other sites

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 by Barand
Link to comment
https://forums.phpfreaks.com/topic/276631-little-help-please/#findComment-1423466
Share on other sites

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. 

Link to comment
https://forums.phpfreaks.com/topic/276631-little-help-please/#findComment-1423469
Share on other sites

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 by Barand
Link to comment
https://forums.phpfreaks.com/topic/276631-little-help-please/#findComment-1423472
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/276631-little-help-please/#findComment-1423487
Share on other sites

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 by Jessica
Link to comment
https://forums.phpfreaks.com/topic/276631-little-help-please/#findComment-1423509
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.