jeffreyxtc Posted November 28, 2010 Share Posted November 28, 2010 Hi I am currently building a movie timeline and need some help with a repeat region issue. The idea is that when someone submits a movie event - it gets positioned in the timeline accordingly. Obviously for events with the same year, I dont want repeat year headings. I have added some if statements to remove duplicate year headings but its still not quite the result I am looking. Currently, I have 2001------------------------------------------------2002-------------------------- movie event--movie event--movie event | movie event--movie event What I need is 2001-------------2002 movie event movie event movie event movie event movie event movie event hope that makes sense I am a newbie so appreciate any advice my code looks like this: <?php require_once('Connections/timeline.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_timeline, $timeline); $query_Recordset1 = "SELECT * FROM film2 ORDER BY `year` ASC"; $Recordset1 = mysql_query($query_Recordset1, $timeline) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>My Movie Timeline</title> <link rel="stylesheet" type="text/css" media="screen, projection" href="includes/screen.css" /> <script src="includes/jquery-1.2.6.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript" charset="utf-8"> $(function(){ $("#page-wrap").wrapInner("<table><tr>"); $(".event").wrap("<td>"); $(".intro").wrap("<td>"); }); function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } </script> <script type="text/javascript" src="includes/smoothscroll.js"></script> <script language="javascript"><!--//window.close();//--></script> </head> <body> <a name="home"></a> <div id="page-wrap"> <div class="intro"> <img src="images/logo.png" alt="My Movie Timeline" width="311" height="151" /> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lobortis dignissim turpis. Pellentesque ultricies rhoncus laoreet. Cras tellus risus, sollicitudin sit amet pulvinar molestie, vulputate ac neque.</p> <ul class="times"> <li><a href="#a-long-time-ago">A long time ago...</a></li> <li><a href="#">0 - 100</a></li> <li><a href="#">101 - 200</a></li> <li><a href="#">201 - 300</a></li> <li><a href="#">301 - 400</a></li> <li><a href="#">401 - 500</a></li> </ul> <br /> <a href="index.php" onclick="MM_openBrWindow('submit.php','submit','width=500,height=500')">Submit</a> a film event entry | <a href="admin.php">Admin</a> </div> <?php // initialize variable to hold previous value $previous = ''; ?> <?php do { ?> <div class="event"> <a name="a-long-time-ago"></a> <h1> <?php // display field if it doesn't match previous value if ($row_Recordset1['year'] != $previous) { echo $row_Recordset1['year']; } else { // otherwise, insert a non-breaking space echo ' '; } // set $previous to current value for next time $previous = $row_Recordset1['year']; ?> </h1> <div class="triangle-isosceles top"> <h2><?php echo $row_Recordset1['movie']; ?></h2> <h3><a href="*"><?php echo $row_Recordset1['name']; ?></a></h3> </div> </div> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </div> <?php mysql_free_result($Recordset1); ?> ------------------ Regards Jeff Mod edit: . . . tags added. Quote Link to comment 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.