Jump to content

Loop inside loop problem.


Mortenjan

Recommended Posts

Hello people.

 

I got a problem with loops.

The code make a new field or table to the right with each record in the database. I understand why it does that, but not how to make it work another way.

 

 

I want the records to be showed like this:

 

Field 1(hidden)          Field 2(hidden)

Date 1          time x connected to date 1

                    time y connected to date 1

                    time a connected to date 1

 

field 3 (hidden)          field 4(hidden)

date 2          time o connected to date 2

etc     

 

Currently  code: http://www.vinstrakino.co.cc/test/test.html

 

I know it is possible, but how?

 

Regards Morten

 

<!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>
<title>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
background-color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {
color: #FFFFFF;
font-size: 19px;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: none;
color: #B10202;
}
a:active {
text-decoration: none;
color: #AE0202;
}
-->
</style>

<meta Name="generator" content="PHPEd Version 3.1.2 (Build 3165)">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="1017" border="0" align="left" cellpadding="0" cellspacing="0"  background="bilder/bakgrunn_oversikt.png" style="background-repeat:no-repeat">
  <tr >
    <td width="1017" height="705" align="left" valign="top"><table width="943" height="101" border="0">
      <tr>
        <td width="937" height="83"> </td>
      </tr>
<tr></tr>
    </table>
      <table width="1002" height="444" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="170" height="440" align="left" valign="top"><p class="style1"> </p>
            <p class="style2"><a href="index.html">Hjemmeside</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="oversikt.html">Billettbestilling/<br />
              Kinoprogram</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
          <hr size="1" color="#000000" />            <p class="style1"> </p></td>
          <td width="832" align="left" valign="top"><table width="819" height="438" border="0" align="left" cellpadding="0" cellspacing="0">
              <tr>
                <td width="819" height="438" valign="top">
                
                <table width="782" height="242" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="782" height="27" align="center" valign="bottom"></td>
                  </tr>
                  <tr>
                    <td height="206" align="left" valign="top" background="bilder/bakgrunn_liten.png" style="background-repeat:repeat-y"><?php
                                
require 'php/tilkobling.php';
$query="

SELECT 
id,
name, 
age_limit, 
length_time, 
filmweb, 
picture

FROM 
movies

";
$result=mysql_query($query);

$num=mysql_numrows($result);

$i=0;

while ($i < $num) {

$film_id=mysql_result($result,$i,"id");
$film_navn=mysql_result($result,$i,"name");
$film_aldersgrense=mysql_result($result,$i,"age_limit");
$film_spilletid=mysql_result($result,$i,"length_time");
$film_filmweb=mysql_result($result,$i,"filmweb");
$film_bilde=mysql_result($result,$i,"picture");

echo"

        <table background='bilder/Vindu_oversikt.png' width='756' height='219' border='0' align='center'>
                      <tr>
                          <td width='750' height='290' align='left' valign='top'>
              <table width='727' height='243' align='center'  cellpadding='0' cellspacing='0'>
                    <tr>
                      <td height='7' colspan='7'  valign='top'> </td>
                    </tr>
                    <tr>
                      <td height='7' colspan='7'  valign='buttom'> $film_navn
                          </td>
                    </tr>
                    <tr>
                      <td width='190' rowspan='3'  valign='top'><strong></strong><img border='2px' src='$film_bilde' alt='$film_navn' width='190' height='235' /></td>
                      <td width='116' align='center'  valign='top' bordercolor='#F0F0F0'><span class='style12'>Aldersgrense:</td>
                      <td width='82' height='6'  valign='top'><span class='style12'>Spilltid:</td>
                      <td width='66' height='6'  valign='top'><span class='style12'>Filmweb:</td>
                      <td width='76' height='6'  valign='top'><span class='style12'>Dato:</td>
                      <td width='87' height='6' align='center'  valign='top'><span class='style12'>Klokkeslett:</td>
                      <td width='108' align='center'  valign='top'>Ledige billetter:</td>
                    </tr></strong>
                    <tr>
                      <td height='160' align='center'  valign='top'>$film_aldersgrense år</td>
                      <td rowspan='2'  valign='top'>$film_spilletid</td>
                      <td rowspan='2'  valign='top'><a href='$film_filmweb'>Link</a>   </td>
                      <td rowspan='2'  valign='top'>
                      
";


$query_dato="

select id, movie_id,
date

FROM 
date

where
movie_id = ".$film_id;

$result_dato=mysql_query($query_dato);
$num_dato=mysql_numrows($result_dato);

$d=0;


while ($d < $num_dato) {

$film_dato=mysql_result($result_dato,$d,"date");
$dato_id=mysql_result($result_dato,$d,"id");


echo $film_dato;
echo '<br>';


    

echo  "</td>
<td rowspan='2' align='center'  valign='top'>";
                  
                   
$query_tid="

select id, date_id,
time

FROM 
time

where
date_id = ".$dato_id;

$result_tid=mysql_query($query_tid);
$num_tid=mysql_numrows($result_tid);

$t=0;

while ($t < $num_tid) {

$film_tid=mysql_result($result_tid,$t,"time");

echo $film_tid;
echo '<br>';

$t++;   
}   
echo "
                      
                      
              
";
$d++;   
}    
             
echo " 
                      
                      
                      
                      
                      
                      
                      
                      
                      
                      
                      
                      </td>
                      <td rowspan='2' align='center'  valign='top'></td>
                    </tr>
                    <tr>
                      <td height='21' align='center'  valign='bottom'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>
                    </tr>
                    
                    
                </table>  
                
                </td>
                        </tr>
                      </table>      
                
                
";

$i++;


}
?>


























</td>
                  </tr>
                </table></td>
              </tr>
          </table></td>
        </tr>
    </table>
      <table width="980" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="156" height="63" align="right" valign="top"> </td>
          <td width="814" valign="top"><img src="bilder/bonn.png" width="799" height="63" alt="bånn" /></td>
        </tr>
      </table>
      <p> </p>
      <hr size="1" color="#000000" /></td>
  </tr>

</table>
</body>
</html>


 

 

 

 

Link to comment
Share on other sites

Your code is very difficult to follow. You have a LOT of nested tables that are unnecessary which complicates this even more. I would highly suggest you rethink the layout of the page to make the programatical creation more elegant.

 

Also, you have multiple queries that you are running within loops. That is very inefficient. You only need ONE query to get all of the data you need.

 

I attempted to rewrite the code as you requested, but because of the complexity with the nested tables I can't ensure it will work 100%

<!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>
<title>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
background-color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {
color: #FFFFFF;
font-size: 19px;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: none;
color: #B10202;
}
a:active {
text-decoration: none;
color: #AE0202;
}
-->
</style>

<meta Name="generator" content="PHPEd Version 3.1.2 (Build 3165)">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="1017" border="0" align="left" cellpadding="0" cellspacing="0"  background="bilder/bakgrunn_oversikt.png" style="background-repeat:no-repeat">
  <tr>
    <td width="1017" height="705" align="left" valign="top"><table width="943" height="101" border="0">
  </tr>
  <tr>
    <td width="937" height="83"> </td>
  </tr>
</table>

<table width="1002" height="444" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="170" height="440" align="left" valign="top"><p class="style1"> </p>
      <p class="style2"><a href="index.html">Hjemmeside</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="oversikt.html">Billettbestilling/<br />Kinoprogram</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
      <hr size="1" color="#000000" />
      <p class="style1"> </p>
    </td>
    <td width="832" align="left" valign="top">
      <table width="819" height="438" border="0" align="left" cellpadding="0" cellspacing="0">
        <tr>
          <td width="819" height="438" valign="top">
            <table width="782" height="242" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="782" height="27" align="center" valign="bottom"></td>
              </tr>
              <tr>
                <td height="206" align="left" valign="top" background="bilder/bakgrunn_liten.png" style="background-repeat:repeat-y">
<?php
                                
require 'php/tilkobling.php';
$query="SELECT movies.id, movies.name, movies.age_limit, movies.length_time, movies.filmweb, movies.picture,
               date.id as date_id, date,
               time.id as time_id, time
        FROM movies
        JOIN date ON movies.id = date.movie_id
        JOIN time ON date.id = time.date_id";

$result=mysql_query($query);

while ($movie = mysql_fetch_assoc($result))
{
    if ($current_movie_id != $movie['id'])
    {
        $current_movie_id = $movie['id'];
        echo"<table background='bilder/Vindu_oversikt.png' width='756' height='219' border='0' align='center'>\n";
        echo"  <tr>\n";
        echo"    <td width='750' height='290' align='left' valign='top'>\n";
        echo"      <table width='727' height='243' align='center'  cellpadding='0' cellspacing='0'>\n";
        echo"        <tr>\n";
        echo"          <td height='7' colspan='7'  valign='top'> </td>\n";
        echo"        </tr>\n";
        echo"        <tr>\n";
        echo"          <td height='7' colspan='7'  valign='buttom'> {$movie['name']}</td>\n";
        echo"        </tr>\n";
        echo"        <tr>\n";
        echo"          <td width='190' rowspan='3'  valign='top'>";
        echo"            <img border='2px' src='{$movie['picture']}' alt='{$movie['name']}' width='190' height='235' />";
        echo"          </td>\n";
        echo"          <td rowspan='3'>\n";
        echo"            <table>\n";
        echo"            <tr>\n";
        echo"              <td width='116' align='center' valign='top' bordercolor='#F0F0F0'><span class='style12'>Aldersgrense:</td>\n";
        echo"              <td width='82' height='6' valign='top'><span class='style12'>Spilltid:</td>\n";
        echo"              <td width='66' height='6' valign='top'><span class='style12'>Filmweb:</td>\n";
        echo"              <td width='76' height='6' valign='top'><span class='style12'>Dato:</td>\n";
        echo"              <td width='87' height='6' valign='top' align='center'><span class='style12'>Klokkeslett:</td>\n";
        echo"              <td width='108' align='center'  valign='top'>Ledige billetter:</td>\n";
        echo"            </tr>\n";
        echo"            <tr>\n";
        echo"              <td height='160' align='center'  valign='top'>{$movie['age_limit']} år</td>\n";
        echo"              <td rowspan='' valign='top'>{$movie['length_time']}</td>\n";
        echo"              <td rowspan='' valign='top'><a href='{$movie['filmweb']}'>Link</a></td>\n";
    }
    else
    {
        echo "           <tr>\n";
        echo "             <td colspan='3'> </td>\n";
    }

    if ($current_date_id != $movie['date_id'])
    {
        $current_date_id != $movie['date_id'];
        echo"              <td rowspan='' valign='top'>{$movie['date']}</td>\n";
    }
    else
    {
        echo"              <td rowspan='' valign='top'> </td>\n";
    }

    echo "                 <td rowspan='' align='center'  valign='top'>{$movie['time']}</td>\n";


    echo "                <td rowspan='' align='center'  valign='top'></td>\n";
    echo "              </tr>\n";
    echo "            </table>\n";
    echo "          </td>\n";
    echo "        </tr>\n";
    echo "        <tr>\n";
    echo "          <td height='21' align='center' valign='bottom'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>\n";
    echo "        </tr>\n";
    echo "      </table>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "</table>\n";
}   

?>

                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

<table width="980" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="156" height="63" align="right" valign="top"> </td>
    <td width="814" valign="top"><img src="bilder/bonn.png" width="799" height="63" alt="bånn" /></td>
  </tr>
</table>

<p> </p>
<hr size="1" color="#000000" />

</body>
</html>


Link to comment
Share on other sites

Hi, and thanks for your help:)

 

This was the output: www.vinstrakino.co.cc/test/guru.html

 

As you said, its many nested tables. I'ill try to make a whole new page, with fewer tables.

 

But your query, it seems like it gets one "time" for each "date". And i need several times for ech date, and several dates for each movie, to be listed systemathecly.

But i dont know how to achieve that. It seems like i was very close with my three queries, and i dont understand why i cant use those.

 

But thanks again.

Would be great with some more help.

Much appreciated.

 

Regards Morten.

Link to comment
Share on other sites

You *can* you the three queries, but the whole point of using a relatinal database is to be able to be able to work with "related" data. As I stated, using looping queries is very inefficient. If this is for your personal site, then go ahead. But, if this is for a site that many users would access, the method you were using can put a severe performance drag on the server.

 

I wrote all of that code off-the-cuff, I wasn't able to test any of it because I don't have your database to test against. I tool a look at the query again and I still think it should work to get ALL the data you are asking for. And, the code I posted should handle the proper displaying of that data, but again I was not able to test it properly. Trying to code within all those nested tables was difficult without having output to test against.

 

The output from the query should look something like this

 

Movie1, Date1-1, Time1-1-1
Movie1, Date1-1, Time1-1-2
Movie1, Date1-1, Time1-1-3
Movie1, Date1-2, Time1-2-1
Movie1, Date1-2, Time1-2-1
Movie2, Date2-1, Time2-1-1

Link to comment
Share on other sites

I am fully able to get that result. I started with a query like yours, but then i got one movie, one date, and one time listed like this:

 

<table>

Movie one, date one , time one

</table>

<table>

Movie one, date one , time two

</table>

<table>

Movie one, date two , time one

</table>

 

etc.

 

I want it this way,but i didnt know how to achieve that with my old query:

 

<table>

Movie one, date one , time one

time two

date two, time one

</table>

<table>

Movie two, date one , time one

                date two, time one

</table>

 

What is the best way to achieve this?

 

Regards Morten.

 

Link to comment
Share on other sites

Just use the methodology I incorporated in the code I posted above: Use a "flag" to track the current movie or the current date so you know when to display the movie,date from the currently processed record. Here's an example. Let's say this is the output for two movies:

 

Movie | Date     | Time
Crash | 02-06-09 | 12:30
Crash | 02-06-09 | 03:15
Crash | 02-06-09 | 05:45
Crash | 02-10-09 | 02:20
Crash | 02-10-09 | 04:15
Shrek | 02-12-09 | 08:20

 

You want the output to look like this

Crash | 02-06-09 | 12:30
                   03:15
                   05:45
        02-10-09 | 02:20
                   04:15
Shrek | 02-12-09 | 08:20

 

The code to generate that could look something like this

//Variables to track current move/date
$current_movie = "";
$current_date = "";

echo "<table>\n";
while($movie=mysql_fetch_assoc($result))
{
    //Start the row
    echo "<tr>\n";

    //See if this movie title is the same as the last record(s)
    //If no, display the new title, otherwise use blank
    if ($current_movie != $move['title'])
    {
        $new_movie = true;
        $current_movie = $move['title'];
        echo "<td>{$current_movie}</td>\n";
    }
    else
    {
        $new_movie = false;
        echo "<td> </td>\n";
    }

    //See if this movie date is the same as the last record(s)
    //If no, display the new date, otherwise use blank
    //Note: also utilize "$new_movie" in case it is a different
    //      movie but same date as last record of last movie
    if ($current_date != $move['date'] || $new_movie)
    {
        $current_date = $move['date']
        echo "<td>{$current_date}</td>\n";
    }
    else
    {
        echo "<td> </td>\n";
    }

    //Display the time
    echo  "<td>{$movie['time']}</td>\n";

    //Cloe the row
    echo "<tr>\n";
}
echo "</table>\n";

Link to comment
Share on other sites

Hi, and thanks for all your help.

Its much appreciated.

 

Ive tried to rewrite the code you gave me, but im not getting the wanted result.

 

page:www.vinstrakino.co.cc/test/morten.html

 

code:

<!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>
<title>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
background-color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {
color: #FFFFFF;
font-size: 19px;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: none;
color: #B10202;
}
a:active {
text-decoration: none;
color: #AE0202;
}
-->
</style>

<meta Name="generator" content="PHPEd Version 3.1.2 (Build 3165)">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="1017" border="0" align="left" cellpadding="0" cellspacing="0"  background="bilder/bakgrunn_oversikt.png" style="background-repeat:no-repeat">
  <tr >
    <td width="1017" height="705" align="left" valign="top"><table width="943" height="101" border="0">
      <tr>
        <td width="937" height="83"> </td>
      </tr>
<tr></tr>
    </table>
      <table width="1002" height="444" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="170" height="440" align="left" valign="top"><p class="style1"> </p>
            <p class="style2"><a href="index.html">Hjemmeside</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="oversikt.html">Billettbestilling/<br />
              Kinoprogram</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
          <hr size="1" color="#000000" />            <p class="style1"> </p></td>
          <td width="832" align="left" valign="top"><table width="819" height="438" border="0" align="left" cellpadding="0" cellspacing="0">
              <tr>
                <td width="819" height="438" valign="top">
                
                <table width="782" height="242" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="782" height="27" align="center" valign="bottom"></td>
                  </tr>
                  <tr>
                    <td height="206" align="left" valign="top" background="bilder/bakgrunn_liten.png" style="background-repeat:repeat-y"><?php
                                
require 'php/tilkobling.php';
$query=" 

SELECT 
movies.id, 
movies.name, 
movies.age_limit, 
movies.length_time, 
movies.filmweb, 
movies.picture, 
date.id AS date_id, date, 
time.id AS time_id, time

FROM movies

JOIN date ON movies.id = date.movie_id
JOIN time ON date.id = time.date_id

";
$result=mysql_query($query);

$film_id=mysql_result($result,$i,"id");

$film_aldersgrense=mysql_result($result,$i,"age_limit");
$film_spilletid=mysql_result($result,$i,"length_time");
$film_filmweb=mysql_result($result,$i,"filmweb");
$film_bilde=mysql_result($result,$i,"picture");
$current_movie=mysql_result($result,$i,"name");
$current_date=mysql_result($result,$i,"date");
$current_time=mysql_result($result,$i,"time");


while($movie=mysql_fetch_assoc($result))
{

echo"

        <table background='bilder/Vindu_oversikt.png' width='756' height='219' border='0' align='center'>
                      <tr>
                          <td width='750' height='290' align='left' valign='top'>
              <table width='727' height='243' align='center'  cellpadding='0' cellspacing='0'>
                    <tr>
                      <td height='7' colspan='7'  valign='top'> </td>
                    </tr>
                    <tr>
                      <td height='7' colspan='7'  valign='buttom'> ";
                      
   if ($current_movie != $movie['name'])
    {
        $new_movie = true;
        $current_movie = $movie['name'];
        echo "{$current_movie}";
    }
    else
    {
        $new_movie = false;
        echo " ";
    }
                      
                      
                      
                      
                      
                    echo"
                          </td>
                    </tr>
                    <tr>
                      <td width='190' rowspan='3'  valign='top'><strong></strong><img border='2px' src='$film_bilde' alt='$film_navn' width='190' height='235' /></td>
                      <td width='116' align='center'  valign='top' bordercolor='#F0F0F0'><span class='style12'>Aldersgrense:</td>
                      <td width='82' height='6'  valign='top'><span class='style12'>Spilltid:</td>
                      <td width='66' height='6'  valign='top'><span class='style12'>Filmweb:</td>
                      <td width='76' height='6'  valign='top'><span class='style12'>Dato:</td>
                      <td width='87' height='6' align='center'  valign='top'><span class='style12'>Klokkeslett:</td>
                      <td width='108' align='center'  valign='top'>Ledige billetter:</td>
                    </tr></strong>
                    <tr>
                      <td height='160' align='center'  valign='top'>$film_aldersgrense År</td>
                      <td rowspan='2'  valign='top'>$film_spilletid</td>
                      <td rowspan='2'  valign='top'><a href='$film_filmweb'>Link</a>   </td>
                      <td rowspan='2'  valign='top'>
                      
                      ";
  if ($current_date != $movie['date'] || $new_movie)
    {
        $current_date = $movie['date'];
        echo "{$current_date}";
    }
    else
    {
        echo " ";
    }

    
                      
                      echo "
                      
</td>

<td rowspan='2' align='center'  valign='top'>
                     ";
                      
                     echo  "{$movie['time']}";
                      
                      
                      
                      
                      
                      
                      
                      echo "
                      </td>
                      <td rowspan='2' align='center'  valign='top'></td>
                    </tr>
                    <tr>
                      <td height='21' align='center'  valign='bottom'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>
                    </tr>
                    
                    
                </table>  
                
                </td>
                        </tr>
                      </table>      
                
                
";

$i++;


}
?>


























</td>
                  </tr>
                </table></td>
              </tr>
          </table></td>
        </tr>
    </table>
      <table width="980" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="156" height="63" align="right" valign="top"> </td>
          <td width="814" valign="top"><img src="bilder/bonn.png" width="799" height="63" alt="bånn" /></td>
        </tr>
      </table>
      <p> </p>
      <hr size="1" color="#000000" /></td>
  </tr>

</table>
</body>
</html>

 

What im i doing wrong?

Thanks again for your help.

 

Regards Morten

Link to comment
Share on other sites

I have fixed the movies, but the dates wont repeat itself.

It only shows one date connected to one movie.

 

How do i fix this?

 

page: Vinstra Kino

 

<!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>
<title>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
background-color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {
color: #FFFFFF;
font-size: 19px;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: none;
color: #B10202;
}
a:active {
text-decoration: none;
color: #AE0202;
}
-->
</style>

<meta Name="generator" content="PHPEd Version 3.1.2 (Build 3165)">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="1017" border="0" align="left" cellpadding="0" cellspacing="0"  background="bilder/bakgrunn_oversikt.png" style="background-repeat:no-repeat">
  <tr >
    <td width="1017" height="705" align="left" valign="top"><table width="943" height="101" border="0">
      <tr>
        <td width="937" height="83"> </td>
      </tr>
<tr></tr>
    </table>
      <table width="1002" height="444" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="170" height="440" align="left" valign="top"><p class="style1"> </p>
            <p class="style2"><a href="index.html">Hjemmeside</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="oversikt.html">Billettbestilling/<br />
              Kinoprogram</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
          <hr size="1" color="#000000" />            <p class="style1"> </p></td>
          <td width="832" align="left" valign="top"><table width="819" height="438" border="0" align="left" cellpadding="0" cellspacing="0">
              <tr>
                <td width="819" height="438" valign="top">
                
                <table width="782" height="242" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="782" height="27" align="center" valign="bottom"></td>
                  </tr>
                  <tr>
                    <td height="206" align="left" valign="top" background="bilder/bakgrunn_liten.png" style="background-repeat:repeat-y"><?php
                                
require 'php/tilkobling.php';
$query=" 

SELECT 
movies.id, 
movies.name, 
movies.age_limit, 
movies.length_time, 
movies.filmweb, 
movies.picture, 
date.id AS date_id, date, 
time.id AS time_id, time

FROM movies

JOIN date ON movies.id = date.movie_id
JOIN time ON date.id = time.date_id

";
$result=mysql_query($query);

$film_id=mysql_result($result,$i,"id");
$film_aldersgrense=mysql_result($result,$i,"age_limit");
$film_spilletid=mysql_result($result,$i,"length_time");
$film_filmweb=mysql_result($result,$i,"filmweb");
$film_bilde=mysql_result($result,$i,"picture");
$film_navn=mysql_result($result,$i,"name");
$film_dato=mysql_result($result,$i,"date");
$film_tid=mysql_result($result,$i,"time");


while($movie=mysql_fetch_assoc($result))
{



   if ($film_navn != $movie['name'])
    {
        $new_movie = true;
        $film_n = $movie['name'];
        
echo"<table background='bilder/Vindu_oversikt.png' width='756' height='219' border='0' align='center'>";
echo"<tr>";
echo"<td width='750' height='290' align='left' valign='top'>";
echo"<table width='727' height='243' align='center'  cellpadding='0' cellspacing='0'>";
echo"<tr>";
echo"<td height='7' colspan='7'  valign='top'> </td>";
echo"</tr>";
echo"<tr>";
echo"<td height='7' colspan='7'  valign='buttom'>";

echo "{$film_n}";
                      
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td width='190' rowspan='3'  valign='top'>";
echo"<img border='2px' src='$film_bilde' alt='$film_navn' width='190' height='235' />";
echo"</td>";
echo"<td width='116' align='center'  valign='top' bordercolor='#F0F0F0'>";
echo"<span class='style12'>Aldersgrense:</td>";

echo"<td width='82' height='6'  valign='top'><span class='style12'>Spilltid:</td>";
echo"<td width='66' height='6'  valign='top'><span class='style12'>Filmweb:</td>";
echo"<td width='76' height='6'  valign='top'><span class='style12'>Dato:</td>";
echo"<td width='87' height='6' align='center'  valign='top'><span class='style12'>Klokkeslett:</td>";
echo"<td width='108' align='center'  valign='top'>Ledige billetter:</td>";
echo"</tr></strong>";
echo"<tr>";
echo"<td height='160' align='center'  valign='top'>$film_aldersgrense år</td>";
echo"<td rowspan='2'  valign='top'>$film_spilletid</td>";
echo"<td rowspan='2'  valign='top'><a href='$film_filmweb'>Link</a>   </td>";
echo"<td rowspan='2'  valign='top'>";

    if ($film_dato != $movie['date'] || $new_movie)
    {
    	$new_date = $true;
        $film_d = $movie['date'];
    	echo "{$film_d}<br>";
    }
    else
    {
        $new_date = false;
        echo "";
    }      
                      
echo"</td>";
echo"<td rowspan='2' align='center'  valign='top'>";            
                      

echo"</td>";
echo"<td rowspan='2' align='center'  valign='top'></td>";
echo"</tr>";
echo"<tr>";
echo"<td height='21' align='center'  valign='bottom'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>";
echo"</tr>";
echo"</table>"; 
echo"</td>";
echo"</tr>";
echo"</table>";
                
    }
    else
    {
        $new_movie = false;
        echo "";
    }



}
?>


























</td>
                  </tr>
                </table></td>
              </tr>
          </table></td>
        </tr>
    </table>
      <table width="980" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="156" height="63" align="right" valign="top"> </td>
          <td width="814" valign="top"><img src="bilder/bonn.png" width="799" height="63" alt="bånn" /></td>
        </tr>
      </table>
      <p> </p>
      <hr size="1" color="#000000" /></td>
  </tr>

</table>
</body>
</html>

 

Thanks in advance

 

Regards Morten

Link to comment
Share on other sites

No offense, but your code is very disorganized which makes fixing it much harder than it should be - especially for someone who didn't write it (i.e. me).

 

Ok, here is another attempt with plenty of comments. It is difficult trying to code this with all the nested tables and not being able to test it properly - but I think this should work (may be some minor typos)

<!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>
<title>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
background-color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {
color: #FFFFFF;
font-size: 19px;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: none;
color: #B10202;
}
a:active {
text-decoration: none;
color: #AE0202;
}
-->
</style>

<meta Name="generator" content="PHPEd Version 3.1.2 (Build 3165)">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="1017" border="0" align="left" cellpadding="0" cellspacing="0"  background="bilder/bakgrunn_oversikt.png" style="background-repeat:no-repeat">
  <tr >
    <td width="1017" height="705" align="left" valign="top"><table width="943" height="101" border="0">
      <tr>
        <td width="937" height="83"> </td>
      </tr>
<tr></tr>
    </table>
      <table width="1002" height="444" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="170" height="440" align="left" valign="top"><p class="style1"> </p>
            <p class="style2"><a href="index.html">Hjemmeside</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="oversikt.html">Billettbestilling/<br />
              Kinoprogram</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
            <hr size="1" color="#000000" />            <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
          <hr size="1" color="#000000" />            <p class="style1"> </p></td>
          <td width="832" align="left" valign="top"><table width="819" height="438" border="0" align="left" cellpadding="0" cellspacing="0">
              <tr>
                <td width="819" height="438" valign="top">
                
                <table width="782" height="242" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="782" height="27" align="center" valign="bottom"></td>
                  </tr>
                  <tr>
                    <td height="206" align="left" valign="top" background="bilder/bakgrunn_liten.png" style="background-repeat:repeat-y">
<?php
                                
require 'php/tilkobling.php';

$query="SELECT 
            movies.id, movies.name, movies.age_limit, movies.length_time, movies.filmweb, movies.picture, 
            date.id AS date_id, date, 
            time.id AS time_id, time
        FROM movies
        JOIN date ON movies.id = date.movie_id
        JOIN time ON date.id = time.date_id";

$result=mysql_query($query);

$current_film_name = "";
$current_film_date = "";

while($movie = mysql_fetch_assoc($result))
{
   //Check for new movie
   if ($current_film_name != $movie['name'])
    {
        $new_movie = true;
        $current_film_name = $movie['name'];

        //Movie Background
        echo "<table background='bilder/Vindu_oversikt.png' width='756' height='219' border='0' align='center'>\n";
        echo "  <tr>\n";
        echo "    <td width='750' height='290' align='left' valign='top'>\n";
        //Movie Main Table
        echo "        <table width='727' height='243' align='center'  cellpadding='0' cellspacing='0'>\n";
        echo "            <tr><td height='7' colspan='2' valign='buttom' style='padding-top:15px;'>{$movie['name']}</td></tr>\n";
        echo "            <tr>\n";
        echo "                <td width='190' rowspan='2'  valign='top'><img border='2px' src='{$movie['picture']}' alt='{$movie['name']}' width='190' height='235' /></td>\n";
        echo "                <td width='116' align='center'  valign='top' bordercolor='#F0F0F0'>\n\n";

        //Movie Data Header
        echo "<table border="1">\n"; //Remove border after debugging
        echo "    <tr>\n";
        echo "        <th class='style12'>Aldersgrense:</td>\n";
        echo "        <th width='82' height='6'  valign='top'><span class='style12'>Spilltid:</th>\n";
        echo "        <th width='66' height='6'  valign='top'><span class='style12'>Filmweb:</th>\n";
        echo "        <th width='76' height='6'  valign='top'><span class='style12'>Dato:</th>\n";
        echo "        <th width='87' height='6' align='center'  valign='top'><span class='style12'>Klokkeslett:</th>\n";
        echo "        <th width='108' align='center'  valign='top'>Ledige billetter:</th>\n";
        echo "    </tr>\n";
    }
    else
    {
        $new_movie = false;
        //If not first movie close previous movie tables
        if ($current_film_name != "")
        {
            //Close movie data table
            echo "</table>\n";
            //BESTILL Link
            echo"            <tr>";
            echo"                <td height='21' align='center'  valign='bottom'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>";
            echo"            </tr>\n";
            //Close Movie Main Table
            echo"        </table>\n";
            //close Background Table 
            echo"    </td>\n";
            echo"  </tr>\n";
            echo"</table>\n";
        }
    }

    //Movie data
    echo "    <tr>";
    //Check for new movie
    if ($new_movie)
    {
        //Display basic movie info (first three columns)
        echo "        <td align='center' valign='top'>{$movie['age_limit']} år</td>\n";
        echo "        <td valign='top'>{$movie['length_time']}</td>\n";
        echo "        <td valign='top'><a href='{$movie['filmweb']}'>Link</a></td>\n";
    }
    else
    {
        //Same movie as last, Display blank cells for first three columns
        echo "        <td colspan='3' valign='top'> </td>\n";
    }

    //Movie date (only display if new date)
    if ($current_film_date != $movie['date'] || $new_movie)
    {
        $current_film_date = $movie['date'];
        echo "        <td valign='top'>{$movie['date']}</td>\n";
    }
    else
    {
        //Same date as last, display blank cell
        echo "        <td valign='top'> </td>\n";
    }

    //Display time
    echo"        <td>{$movie['date']}</td>\n";

    //Close movie data row
    echo"    </tr>\n";       

}

//CLOSE FINAL MOVIE TABLES
//Close movie data table
echo "</table>\n";
//BESTILL Link
echo"            <tr>";
echo"                <td height='21' align='center'  valign='bottom'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>";
echo"            </tr>\n";
//Close Movie Main Table
echo"        </table>\n";
//close Background Table 
echo"    </td>\n";
echo"  </tr>\n";
echo"</table>\n";

?>

                    </td>
                  </tr>
                </table></td>
              </tr>
          </table></td>
        </tr>
    </table>
      <table width="980" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="156" height="63" align="right" valign="top"> </td>
          <td width="814" valign="top"><img src="bilder/bonn.png" width="799" height="63" alt="bånn" /></td>
        </tr>
      </table>
      <p> </p>
      <hr size="1" color="#000000" /></td>
  </tr>

</table>
</body>
</html>

Link to comment
Share on other sites

thanks you very much for spending so much efford on making this code!.

 

Ill try to debug it. Its not easy, thats for sure.

 

But thanks again.

Ill come back to you when i hopefully have been able to get some results.

 

Just ask if you want a database copy.

 

Regards Morten

Link to comment
Share on other sites

Go ahead and attach a database output and I'll see what I can do.

 

Your first code will probably work without any noticable effect as long as you are dealing with a small number of users AND the database is small. The problems will arise as the database grows. I worked on a project once where we were creating reports from hundreds (thousands?) of records and the developer writing it did what you did in your first code. When running those reports the page would time out before the process could finish when processing lots of records.

 

Even if it does work, it is inifinitely better, in my opinion, to learn to do things the right way. I would still suggest a complete restructuring of that page. Would make things a whole lot easier.

Link to comment
Share on other sites

Here is your html file. I dont think i can make it more simple.

 

 

Is it good enough?

 

Regards Morten

<!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>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
background-color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {
color: #FFFFFF;
font-size: 19px;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: none;
color: #B10202;
}
a:active {
text-decoration: none;
color: #AE0202;
}
-->
</style>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<!--Start of the whole page table-->

<table background="bilder/bakgrunn_oversikt.png" width="963" border="0" cellpadding="0" cellspacing="0">


 	<!--Logo and menu-->
 <tr>
   <td width="170" rowspan="2"" valign="bottom"left="left"><p class="style1"> </p>
     <p class="style2"><a href="index.html">Hjemmeside</a></p>
     <hr size="1" color="#000000" />
     <p class="style2"><a href="oversikt.html">Billettbestilling/<br />
       Kinoprogram</a></p>
     <hr size="1" color="#000000" />
     <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
     <hr size="1" color="#000000" />
     <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
     <hr size="1" color="#000000" />
     <p class="style1"> </p></td>
   <td width="793" height="128" align="left" valign="top"> </td>
 </tr>

   <!--End logo and menu-->





    <!--Picture following the movies y-axis.-->

   <tr>
   <td background='bilder/bakgrunn_liten.png' style='background-repeat:repeat-y'  align="left" valign="top">

   <!--The movie table-->

   <table background='bilder/Vindu_oversikt.png' width='764' height='300' align='center'  cellpadding='0' cellspacing='0'>
     <tr>
       <td height='29' colspan='7'  valign='bottom'> $film_navn </td>
     </tr>
     <tr>
       <td width='204' rowspan='3' align="right"  valign='top'><strong></strong><img border='2px' src='$film_bilde' alt='$film_navn' width='190' height='235' /></td>
       <td width='116' align='center'  valign='top' bordercolor='#F0F0F0'><span class='style12'>Aldersgrense:</span></td>
       <td width='82' height='6'  valign='top'><span class='style12'>Spilltid:</span></td>
       <td width='64' height='6'  valign='top'><span class='style12'>Filmweb:</span></td>
       <td width='74' height='6'  valign='top'><span class='style12'>Dato:</span></td>
       <td width='84' height='6' align='center'  valign='top'><span class='style12'>Klokkeslett:</span></td>
       <td width='138' align='center'  valign='top'>Ledige billetter:</td>
     </tr>
     <tr>
       <td height='160' align='center'  valign='top'>$film_aldersgrense år</td>
       <td rowspan='2'  valign='top'>$film_spilletid</td>
       <td rowspan='2'  valign='top'><a href='$film_filmweb'>Link</a></td>
       <td rowspan='2'  valign='top'>$film_dato </td>
       <td rowspan='2' align='center'  valign='top'>$film_tid</td>
       <td rowspan='2' align='center'  valign='top'></td>
     </tr>
     <tr>
       <td height='90' align='center'  valign='middle'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>
     </tr>
   </table>

    <!--End movie table-->

    </td>
 </tr>
      
    <!--End picture following the movies y-axis.-->
    




   <!--Buttom picture-->

 <tr>
   <td height="63" align="right" valign="top"> </td>
   <td valign="top"><img src="bilder/bonn.png" width="782" height="63" alt="bånn" /></td>   
 </tr>

     <!--End buttom picture-->


</table>


<!--End on whole page.-->

</body>
</html>




 

Build with dreamweaver, so you can take a look at it there, or in your browser.

Link to comment
Share on other sites

Here is a code almost identic with yours, and its working.

 

page:http://www.vinstrakino.co.cc/test/morten.html

 

But its not working like it should.

I am only getting one date and time record for each movie.

It wont loop like its supposed to.

 

 

Got a clue?

 

Regards Morten

 

 

<!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>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
background-color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {
color: #FFFFFF;
font-size: 19px;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: none;
color: #B10202;
}
a:active {
text-decoration: none;
color: #AE0202;
}
-->
</style>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<!--Start of the whole page table-->

<table background="bilder/bakgrunn_oversikt.png" style="background-repeat:no-repeat" width="963" border="0" cellpadding="0" cellspacing="0">
    
  	<!--Logo and menu-->
  <tr>
    <td width="170" rowspan="2"" valign="bottom"left="left"><p class="style1"> </p>
      <p class="style2"><a href="index.html">Hjemmeside</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="oversikt.html">Billettbestilling/<br />
        Kinoprogram</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
      <hr size="1" color="#000000" />
      <p class="style1"> </p></td>
    <td width="793" height="128" align="left" valign="top"> </td>
  </tr>
  
    <!--End logo and menu-->

     <!--Picture following the movies y-axis.-->
  
    <tr>
    <td background='bilder/bakgrunn_liten.png' style='background-repeat:repeat-y'  align="left" valign="top">
    
    
    
    
<?php
                              
require 'php/tilkobling.php';

$query="SELECT 
            movies.id, movies.name, movies.age_limit, movies.length_time, movies.filmweb, movies.picture, 
            date.id AS date_id, date, 
            time.id AS time_id, time
        FROM movies
        JOIN date ON movies.id = date.movie_id
        JOIN time ON date.id = time.date_id";

$result=mysql_query($query);

$current_film_name = "";
$current_film_date = "";

while($movie = mysql_fetch_assoc($result))
{
   //Check for new movie
   if ($current_film_name != $movie['name'])
    {
        $new_movie = true;
        $current_film_name = $movie['name'];
     
                 
                   
                                   
    
    //The movie table
    
echo "<table background='bilder/Vindu_oversikt.png' width='764' height='300' align='center'  cellpadding='0' cellspacing='0'>";
echo " <tr>";
echo "     <td height='29' colspan='7'  valign='bottom'> {$movie['name']} </td>";
echo "  </tr>";
echo "   <tr>";
echo "   <td width='204' rowspan='3' align='right'  valign='top'><strong></strong><img border='2px' src='{$movie['picture']}' alt='{$movie['name']}' width='190' height='235' /></td>";

        //Movie Data Header
echo "        <td width='116' align='center'  valign='top' bordercolor='#F0F0F0'><span class='style12'>Aldersgrense:</span></td>";
echo "        <td width='82' height='6'  valign='top'><span class='style12'>Spilltid:</span></td>";
echo "        <td width='64' height='6'  valign='top'><span class='style12'>Filmweb:</span></td>";
echo "        <td width='74' height='6'  valign='top'><span class='style12'>Dato:</span></td>";
echo "        <td width='84' height='6' align='center'  valign='top'><span class='style12'>Klokkeslett:</span></td>";
echo "        <td width='138' align='center'  valign='top'>Ledige billetter:</td>";
        //End - Movie Data Header

echo "      </tr>";
echo "      <tr>";

	//Check for new movie
if ($new_movie)
    {
    			//Display basic movie info (first three columns)
	echo "<td height='160' align='center'  valign='top'>{$movie['age_limit']} år</td>";
	echo "<td rowspan='2'  valign='top'>{$movie['length_time']}</td>";
	echo "<td rowspan='2'  valign='top'><a href='$film_filmweb'>Link</a></td>";
    }
    else
    {
        //Same movie as last, Display blank cells for first three columns
        echo "        <td colspan='3' valign='top'> </td>\n";
    }
    
    
    
    //Movie date (only display if new date)
    if ($current_film_date != $movie['date'] || $new_movie)
    {
        $current_film_date = $movie['date'];
        echo "        <td rowspan='2'  valign='top'>$current_film_date </td>";
    }
    else
    {
        //Same date as last, display blank cell
        echo "        <td rowspan='2'  valign='top'> </td>\n";
    }
echo "        <td rowspan='2' align='center'  valign='top'>{$movie['time']}</td>";
echo "        <td rowspan='2' align='center'  valign='top'></td>";
echo "      </tr>";
echo "      <tr>";
echo "        <td height='90' align='center'  valign='middle'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>";
echo "      </tr>";
echo "    </table>";
    
     //End movie table
         }
    else
    {
       $new_movie = false;
       //If not first movie close previous movie tables
    }
     
}     

     
     
?>     
     
     
     
     
     
     
     
     
     
    
     </td>
  </tr>
       
     <!--End picture following the movies y-axis.-->
     


    <!--Buttom picture-->
    
  <tr>
    <td height="63" align="right" valign="top"> </td>
    <td valign="top"><img src="bilder/bonn.png" width="782" height="63" alt="bånn" /></td>   
  </tr>
  
      <!--End buttom picture-->
      
      
</table>


<!--End on whole page.-->

</body>
</html>





Link to comment
Share on other sites

I think that's a lot better. Although there are some errors. Here's a tip: whenever working with tables - especially nested ones, it's a good idea to create them with different color borders. you can then easily see if there are any problems with the table structure. Then just remove the borders when development is done.

 

<!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>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
background-color: #000000;
}
td { color: white; }
.style1 {color: #FFFFFF}
.style2 {
color: #FFFFFF;
font-size: 19px;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: none;
color: #B10202;
}
a:active {
text-decoration: none;
color: #AE0202;
}
-->
</style>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<!--Start of the whole page table-->

<table background="bilder/bakgrunn_oversikt.png" width="963" border="1" borderColor="white" cellpadding="0" cellspacing="0">
  
  
  	<!--Logo and menu-->
  <tr>
    <td width="170" rowspan="2"" valign="bottom"left="left"><p class="style1"> </p>
      <p class="style2"><a href="index.html">Hjemmeside</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="oversikt.html">Billettbestilling/<br />
        Kinoprogram</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
      <hr size="1" color="#000000" />
      <p class="style1"> </p></td>
    <td width="793" height="128" align="left" valign="top"> </td>
  </tr>
  
    <!--End logo and menu-->

    <!--Picture following the movies y-axis.-->
  
    <tr>
    <td background='bilder/bakgrunn_liten.png' style='background-repeat:repeat-y'  align="left" valign="top">
    
    <!--The movie table-->
    
    <table background='bilder/Vindu_oversikt.png' width='764' height='300' border="1" borderColor="blue" align='center'  cellpadding='0' cellspacing='0'>
      <tr>
        <td height='29' colspan='7' valign='bottom'> $film_navn </td>
      </tr>
      <tr>
        <td width='204' rowspan='3' align="right"  valign='top'><img border='2px' src='$film_bilde' alt='$film_navn' width='190' height='235' /></td>
        <td width='116' align='center'  valign='top' bordercolor='#F0F0F0'><span class='style12'>Aldersgrense:</span></td>
        <td width='82' height='6'  valign='top'><span class='style12'>Spilltid:</span></td>
        <td width='64' height='6'  valign='top'><span class='style12'>Filmweb:</span></td>
        <td width='74' height='6'  valign='top'><span class='style12'>Dato:</span></td>
        <td width='84' height='6' align='center'  valign='top'><span class='style12'>Klokkeslett:</span></td>
        <td width='138' align='center'  valign='top'>Ledige billetter:</td>
      </tr>
      <tr>
        <td height='160' align='center'  valign='top'>$film_aldersgrense år</td>
        <td valign='top'>$film_spilletid</td>
        <td valign='top'><a href='$film_filmweb'>Link</a></td>
        <td valign='top'>$film_dato</td>
        <td align='center'  valign='top'>$film_tid</td>
        <td align='center'  valign='top'></td>
      </tr>
      <tr>
        <td height='90' align='center' colspan='6' valign='middle'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>
      </tr>
    </table>
    
     <!--End movie table-->
    
     </td>
  </tr>
       
     <!--End picture following the movies y-axis.-->
     
    <!--Buttom picture-->
    
  <tr>
    <td height="63" align="right" valign="top"> </td>
    <td valign="top"><img src="bilder/bonn.png" width="782" height="63" alt="bånn" /></td>   
  </tr>
  
      <!--End buttom picture-->
      
</table>

<!--End on whole page.-->

</body>
</html>

Link to comment
Share on other sites

Here is a code almost identic with yours, and its working.

 

page:http://www.vinstrakino.co.cc/test/morten.html

 

But its not working like it should.

I am only getting one date and time record for each movie.

It wont loop like its supposed to.

 

You switch around the logic from what I provided. For example this is what I gave you

   //Check for new movie
   if ($current_film_name != $movie['name'])
   {
        $new_movie = true;
        //Logic to open the new movie table and display basic movie info
    }
    else
    {
        $new_movie = false;
    }

    //Logic to display the date/times for the individual records

 

here is what you did

   //Check for new movie
   if ($current_film_name != $movie['name'])
   {
        $new_movie = true;
        //Logic to open the new movie table and display basic movie info
        //Logic to display the date/times for the individual records
    }
    else
    {
        $new_movie = false;
    }

 

See the problem? Since all of the code for presenting the data (basic and date/time) has been moved into the true branch, that code is only run when a "new movie" is detected in the results (i.e. the first record for each movie)! The other records for each move are not processed at all.

 

There is a problem with trying to use the current code with your new design in that the current code would create a new table row for each date/time record, but the image is set to be only three rows high. But, you won't know how many rows there will be. Your new design is better, so you will have to take a different approach - one which I think is better and more cleaner anyway.

 

Try this:

<!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>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
background-color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {
color: #FFFFFF;
font-size: 19px;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: none;
color: #B10202;
}
a:active {
text-decoration: none;
color: #AE0202;
}
-->
</style>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<!--Start of the whole page table-->

<table background="bilder/bakgrunn_oversikt.png" style="background-repeat:no-repeat" width="963" border="0" cellpadding="0" cellspacing="0">
    
  	<!--Logo and menu-->
  <tr>
    <td width="170" rowspan="2"" valign="bottom"left="left"><p class="style1"> </p>
      <p class="style2"><a href="index.html">Hjemmeside</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="oversikt.html">Billettbestilling/<br />
        Kinoprogram</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
      <hr size="1" color="#000000" />
      <p class="style1"> </p></td>
    <td width="793" height="128" align="left" valign="top"> </td>
  </tr>
  
    <!--End logo and menu-->

     <!--Picture following the movies y-axis.-->
  
    <tr>
    <td background='bilder/bakgrunn_liten.png' style='background-repeat:repeat-y'  align="left" valign="top">
    
    
    
    
<?php

function displayMovie($name, $image, $age, $length, $web, $dates, $times)
{
echo "
    <table background='bilder/Vindu_oversikt.png' width='764' height='300' border="1" borderColor="blue" align='center'  cellpadding='0' cellspacing='0'>
      <tr>
        <td height='29' colspan='7' valign='bottom'> $name </td>
      </tr>
      <tr>
        <td width='204' rowspan='3' align="right"  valign='top'><img border='2px' src='$image' alt='$name' width='190' height='235' /></td>
        <td width='116' align='center'  valign='top' bordercolor='#F0F0F0'><span class='style12'>Aldersgrense:</span></td>
        <td width='82' height='6'  valign='top'><span class='style12'>Spilltid:</span></td>
        <td width='64' height='6'  valign='top'><span class='style12'>Filmweb:</span></td>
        <td width='74' height='6'  valign='top'><span class='style12'>Dato:</span></td>
        <td width='84' height='6' align='center'  valign='top'><span class='style12'>Klokkeslett:</span></td>
        <td width='138' align='center'  valign='top'>Ledige billetter:</td>
      </tr>
      <tr>
        <td height='160' align='center'  valign='top'>$age år</td>
        <td valign='top'>$length</td>
        <td valign='top'><a href='$web'>Link</a></td>
        <td valign='top'>$dates</td>
        <td align='center' valign='top'>$times</td>
        <td align='center' valign='top'></td>
      </tr>
      <tr>
        <td height='90' align='center' colspan='6' valign='middle'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>
      </tr>
    </table>";
}

require 'php/tilkobling.php';

$query="SELECT 
            movies.id, movies.name, movies.age_limit, movies.length_time, movies.filmweb, movies.picture, 
            date.id AS date_id, date, 
            time.id AS time_id, time
        FROM movies
        JOIN date ON movies.id = date.movie_id
        JOIN time ON date.id = time.date_id";

$result=mysql_query($query);

$current_film_name = "";
$current_film_date = "";

while($movie = mysql_fetch_assoc($result))
{
   //Check for new movie
   if ($current_film_name != $movie['name'])
   {
        //New movie

        if($current_film_name != "")
        {
            //If not the first record, display the last movie
            displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times);
        }

        $current_film_name = $movie['name'];

        $m_name      = $movie['name'];
        $m_image     = $movie['picture'];
        $m_age_limit = $movie['age_limit'];
        $m_length    = $movie['length_time'];
        $m_web       = $movie['filmweb'];
        $m_dates     = $movie['date'];
        $m_times     = $movie['time'];
    }
    else
    {
        if ($current_film_date != $movie['date'])
        {
            //Different date from last record, show it
            $movie_dates .= "<br>{$movie['date']}";
        }
        else
        {
            //Same date as last, line break
            $movie_dates .= "<br>";
        }

        $movie_times .= "<br>{$movie['time']}";
    }
}

//Display the last movie
displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times);
     
?>     
    
     </td>
  </tr>
       
     <!--End picture following the movies y-axis.-->
     


    <!--Buttom picture-->
    
  <tr>
    <td height="63" align="right" valign="top"> </td>
    <td valign="top"><img src="bilder/bonn.png" width="782" height="63" alt="bånn" /></td>   
  </tr>
  
      <!--End buttom picture-->
      
      
</table>


<!--End on whole page.-->

</body>
</html>





Link to comment
Share on other sites

Im not sure why, but it doesnt work. Get a blank screen in firefox.

 

Ill try to debug it, but are you 100% sure that this code works with the functions and all?

 

Thanks again for your effort!

 

Much appreciated!

I wouldnt be able to write this myself, thats for sure.

 

Regards Morten

Link to comment
Share on other sites

Your code works now. Was some " inside echo that i changed to '.

 

But the dates and times still wont loop.

 

page:http://www.vinstrakino.co.cc/test/morten.html

 

<!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>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
   background-color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {
   color: #FFFFFF;
   font-size: 19px;
}
a:link {
   color: #FFFFFF;
   text-decoration: none;
}
a:visited {
   text-decoration: none;
   color: #FFFFFF;
}
a:hover {
   text-decoration: none;
   color: #B10202;
}
a:active {
   text-decoration: none;
   color: #AE0202;
}
-->
</style>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<!--Start of the whole page table-->

<table background="bilder/bakgrunn_oversikt.png" style="background-repeat:no-repeat" width="963" border="0" cellpadding="0" cellspacing="0">
   
     <!--Logo and menu-->
  <tr>
    <td width="170" rowspan="2"" valign="bottom"left="left"><p class="style1"> </p>
      <p class="style2"><a href="index.html">Hjemmeside</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="oversikt.html">Billettbestilling/<br />
        Kinoprogram</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
      <hr size="1" color="#000000" />
      <p class="style1"> </p></td>
    <td width="793" height="128" align="left" valign="top"> </td>
  </tr>

    <!--End logo and menu-->

     <!--Picture following the movies y-axis.-->

    <tr>
    <td background='bilder/bakgrunn_liten.png' style='background-repeat:repeat-y'  align="left" valign="top">
   
   
   
   
<?php

function displayMovie($name, $image, $age, $length, $web, $dates, $times)
{
echo "
    <table background='bilder/Vindu_oversikt.png' width='764' height='300' border='1' borderColor='blue' align='center'  cellpadding='0' cellspacing='0'>
      <tr>
        <td height='29' colspan='7' valign='bottom'> $name </td>
      </tr>
      <tr>
        <td width='204' rowspan='3' align='right'  valign='top'><img border='2px' src='$image' alt='$name' width='190' height='235' /></td>
        <td width='116' align='center'  valign='top' bordercolor='#F0F0F0'><span class='style12'>Aldersgrense:</span></td>
        <td width='82' height='6'  valign='top'><span class='style12'>Spilltid:</span></td>
        <td width='64' height='6'  valign='top'><span class='style12'>Filmweb:</span></td>
        <td width='74' height='6'  valign='top'><span class='style12'>Dato:</span></td>
        <td width='84' height='6' align='center'  valign='top'><span class='style12'>Klokkeslett:</span></td>
        <td width='138' align='center'  valign='top'>Ledige billetter:</td>
      </tr>
      <tr>
        <td height='160' align='center'  valign='top'>$age år</td>
        <td valign='top'>$length</td>
        <td valign='top'><a href='$web'>Link</a></td>
        <td valign='top'>$dates</td>
        <td align='center' valign='top'>$times</td>
        <td align='center' valign='top'></td>
      </tr>
      <tr>
        <td height='90' align='center' colspan='6' valign='middle'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>
      </tr>
    </table>";
}

require 'php/tilkobling.php';

$query="SELECT 
            movies.id, movies.name, movies.age_limit, movies.length_time, movies.filmweb, movies.picture, 
            date.id AS date_id, date, 
            time.id AS time_id, time
        FROM movies
        JOIN date ON movies.id = date.movie_id
        JOIN time ON date.id = time.date_id";

$result=mysql_query($query);

$current_film_name = "";
$current_film_date = "";

while($movie = mysql_fetch_assoc($result))
{
   //Check for new movie
   if ($current_film_name != $movie['name'])
   {
        //New movie

        if($current_film_name != "")
        {
            //If not the first record, display the last movie
            displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times);
        }

        $current_film_name = $movie['name'];

        $m_name      = $movie['name'];
        $m_image     = $movie['picture'];
        $m_age_limit = $movie['age_limit'];
        $m_length    = $movie['length_time'];
        $m_web       = $movie['filmweb'];
        $m_dates     = $movie['date'];
        $m_times     = $movie['time'];
    }
    else
    {
        if ($current_film_date != $movie['date'])
        {
            //Different date from last record, show it
            $movie_dates .= "<br>{$movie['date']}";
        }
        else
        {
            //Same date as last, line break
            $movie_dates .= "<br>";
        }

        $movie_times .= "<br>{$movie['time']}";
    }
}

//Display the last movie
displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times);
     
?>     
   
     </td>
  </tr>
       
     <!--End picture following the movies y-axis.-->
     


    <!--Buttom picture-->
   
  <tr>
    <td height="63" align="right" valign="top"> </td>
    <td valign="top"><img src="bilder/bonn.png" width="782" height="63" alt="bånn" /></td>   
  </tr>

      <!--End buttom picture-->
     
     
</table>


<!--End on whole page.-->

</body>
</html>





Link to comment
Share on other sites

O, I have it working, but you are going to need to clean up the "look" of the page. I had to make some adjustments.

 

Note: I hard coded the path to the images so they would show up in my environment.

 

<!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>
<title>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
    color:white;
background-color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {
color: #FFFFFF;
font-size: 19px;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: none;
color: #B10202;
}
a:active {
text-decoration: none;
color: #AE0202;
}
-->
</style>

<meta Name="generator" content="PHPEd Version 3.1.2 (Build 3165)">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="965" border="0" align="" cellpadding="0" cellspacing="10"  background="http://www.vinstrakino.co.cc/test/bilder/bakgrudnn_oversikt.png" style="background-repeat:no-repeat">
  <tr>
    <td colspan="2" height="100" align="left" valign="top">Header</td>
  </tr>
  <tr>
    <td width="160" valign="top">
      <br><br>
      <p class="style2"><a href="index.html">Hjemmeside</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="oversikt.html">Billettbestilling/<br />Kinoprogram</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
      <hr size="1" color="#000000" />
      <p class="style1"> </p>
    </td>
    <td width="400" background="http://www.vinstrakino.co.cc/test/bilder/Vindu_oversikt.png" style="background-repeat:repeat-y;">

<?php

function displayMovie($name, $image, $age, $length, $web, $dates, $times)
{
echo "
    <table width=\"764\" height=\"300\" border=\"0\" borderColor=\"\" align=\"center\"  cellpadding=\"0\" cellspacing=\"0\">
      <tr>
        <td height=\"29\" colspan=\"7\" valign=\"bottom\"> $name </td>
      </tr>
      <tr>
        <td width=\"204\" rowspan=\"3\" align=\"right\"  valign=\"top\"><img border=\"2px\" src=\"$image\" alt=\"$name\" width=\"190\" height=\"235\" /></td>
        <td width=\"116\" align=\"center\"  valign=\"top\" bordercolor=\"#F0F0F0\"><span class=\"style12\">Aldersgrense:</span></td>
        <td width=\"82\" height=\"6\" valign=\"top\"><span class=\"style12\">Spilltid:</span></td>
        <td width=\"64\" height=\"6\" valign=\"top\"><span class=\"style12\">Filmweb:</span></td>
        <td width=\"74\" height=\"6\" valign=\"top\"><span class=\"style12\" nowrap>Dato:</span></td>
        <td width=\"84\" height=\"6\" align=\"center\"  valign=\"top\"><span class=\"style12\">Klokkeslett:</span></td>
        <td width=\"138\" align=\"center\"  valign=\"top\">Ledige billetter:</td>
      </tr>
      <tr>
        <td height=\"160\" align=\"center\" valign=\"top\">$age år</td>
        <td valign=\"top\" nowrap>$length</td>
        <td valign=\"top\" nowrap><a href=\"$web\">Link</a></td>
        <td valign=\"top\" nowrap>$dates</td>
        <td align=\"center\" valign=\"top\" nowrap>$times</td>
        <td align=\"center\" valign=\"top\" nowrap></td>
      </tr>
      <tr>
        <td height=\"90\" align=\"center\" colspan=\"6\" valign=\"middle\"><a href=\"bestill.html\"><img src=\"http://www.vinstrakino.co.cc/bestill.png\" alt=\"bestill\" width=\"70\" height=\"21\" border=\"0\" /></a></td>
      </tr>
    </table>";
}

require 'php/tilkobling.php';

$query="SELECT 
            movies.id, movies.name, movies.age_limit, movies.length_time, movies.filmweb, movies.picture, 
            date.id AS date_id, date, 
            time.id AS time_id, time
        FROM movies
        JOIN date ON movies.id = date.movie_id
        JOIN time ON date.id = time.date_id
        ORDER BY movies.name";

$result=mysql_query($query);

$current_film_name = "";
$current_film_date = "";

while($movie = mysql_fetch_assoc($result))
{
   //Check for new movie
   if ($current_film_name != $movie['name'])
   {
        //New movie

        if($current_film_name != "")
        {
            //If not the first record, display the last movie
            displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times);
        }

        $current_film_name = $movie['name'];

        $m_name      = $movie['name'];
        $m_image     = $movie['picture'];
        $m_age_limit = $movie['age_limit'];
        $m_length    = $movie['length_time'];
        $m_web       = $movie['filmweb'];
        $m_dates     = $movie['date'];
        $m_times     = $movie['time'];
    }
    else
    {
        if ($current_film_date != $movie['date'])
        {
            //Different date from last record, show it
            $m_dates .= "<br>{$movie['date']}";
        }
        else
        {
            //Same date as last, line break
            $m_dates .= "<br>";
        }

        $m_times .= "<br>{$movie['time']}";
    }
}

//Display the last movie
displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times);
     
?> 
    </td>
  </tr>
</table>

<table width="1017" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="" height="63" align="right" valign="top"> </td>
    <td width="" valign="top"><img src="http://www.vinstrakino.co.cc/test/bilder/bonn.png" width="799" height="63" alt="bånn" /></td>
  </tr>
</table>

<p> </p>
<hr size="1" color="#000000" />

</body>
</html>

Link to comment
Share on other sites

Here is your updated code(with just new design values), use that.

 

Just change the picture links again :)

Thanks for the help so far!

 

Would be great if the dates did not repeat.

 

Page: http://www.vinstrakino.co.cc/test/morten.html

 

Regards Morten

 

<!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>
<title>Vinstra Kino - Oversikt</title>
<style type="text/css">
<!--
body {
    
   background-color: #000000;
}
.style1 {color: #FFFFFF}
.style2 {
   color: #FFFFFF;
   font-size: 19px;
}
a:link {
   color: #FFFFFF;
   text-decoration: none;
}
a:visited {
   text-decoration: none;
   color: #FFFFFF;
}
a:hover {
   text-decoration: none;
   color: #B10202;
}
a:active {
   text-decoration: none;
   color: #AE0202;
}
-->
</style>

<meta Name="generator" content="PHPEd Version 3.1.2 (Build 3165)">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="958" border="0" align="" cellpadding="0" cellspacing="0"  background="bilder/bakgrunn_oversikt.png" style="background-repeat:no-repeat">
  <tr>
    <td colspan="2" height="128" align="left" valign="top"></td>
  </tr>
  <tr>
    <td width="170" height="318" valign="top">
      <br><br>
      <p class="style2"><a href="index.html">Hjemmeside</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="oversikt.html">Billettbestilling/<br />Kinoprogram</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="om.html">Om Vinstra Kino</a></p>
      <hr size="1" color="#000000" />
      <p class="style2"><a href="kontakt.html">Kontakt oss</a></p>
      <hr size="1" color="#000000" />
      <p class="style1"> </p>
    </td>
    <td width="788" background="bilder/bakgrunn_liten.png"  style="background-repeat:repeat-y;">

<?php

function displayMovie($name, $image, $age, $length, $web, $dates, $times)
{
echo "
    <table background=\"bilder/Vindu_oversikt.png\" width=\"760\" height=\"250\" border=\"0\" borderColor=\"\" align=\"center\"  cellpadding=\"0\" cellspacing=\"0\">
      <tr>
        <td width=\"2\" height=\"29\" colspan=\"7\" align=\"center\" valign=\"bottom\">$name </td>
      </tr>
      
      <tr>
        <td width=\"204\" rowspan=\"3\" align=\"right\"  valign=\"top\"><img border=\"2px\" src=\"$image\" alt=\"$name\" width=\"190\" height=\"235\" /></td>
        <td width=\"116\" align=\"center\"  valign=\"top\" bordercolor=\"#F0F0F0\"><span class=\"style12\">Aldersgrense:</span></td>
        <td width=\"82\" height=\"6\" valign=\"top\"><span class=\"style12\">Spilltid:</span></td>
        <td width=\"64\" height=\"6\" valign=\"top\"><span class=\"style12\">Filmweb:</span></td>
        <td width=\"74\" height=\"6\" valign=\"top\"><span class=\"style12\" nowrap>Dato:</span></td>
        <td width=\"84\" height=\"6\" align=\"center\"  valign=\"top\"><span class=\"style12\">Klokkeslett:</span></td>
        <td width=\"138\" align=\"center\"  valign=\"top\">Ledige billetter:</td>
      </tr>
      <tr>
        <td height=\"140\" align=\"center\" valign=\"top\">$age år</td>
        <td valign=\"top\" nowrap>$length</td>
        <td valign=\"top\" nowrap><a href=\"$web\">Link</a></td>
        <td valign=\"top\" nowrap>$dates</td>
        <td align=\"center\" valign=\"top\" nowrap>$times</td>
        <td align=\"center\" valign=\"top\" nowrap></td>
      </tr>
      <tr>
        <td height=\"90\" align=\"left\" colspan=\"6\" valign=\"buttom\"><a href=\"bestill.html\"><img src=\"http://www.vinstrakino.co.cc/bestill.png\" alt=\"bestill\" width=\"70\" height=\"21\" border=\"0\" /></a></td>
      </tr>
    </table>";
}

require 'php/tilkobling.php';

$query="SELECT 
            movies.id, movies.name, movies.age_limit, movies.length_time, movies.filmweb, movies.picture, 
            date.id AS date_id, date, 
            time.id AS time_id, time
        FROM movies
        JOIN date ON movies.id = date.movie_id
        JOIN time ON date.id = time.date_id
        ORDER BY date.date";

$result=mysql_query($query);

$current_film_name = "";
$current_film_date = "";

while($movie = mysql_fetch_assoc($result))
{
   //Check for new movie
   if ($current_film_name != $movie['name'])
   {
        //New movie

        if($current_film_name != "")
        {
            //If not the first record, display the last movie
            displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times);
        }

        $current_film_name = $movie['name'];

        $m_name      = $movie['name'];
        $m_image     = $movie['picture'];
        $m_age_limit = $movie['age_limit'];
        $m_length    = $movie['length_time'];
        $m_web       = $movie['filmweb'];
        $m_dates     = $movie['date'];
        $m_times     = $movie['time'];
    }
    else
    {
        if ($current_film_date != $movie['date'])
        {
            //Different date from last record, show it
            $m_dates .= "<br>{$movie['date']}";
        }
        else
        {
            //Same date as last, line break
            $m_dates .= "<br>";
        }

        $m_times .= "<br>{$movie['time']}";
    }
}

//Display the last movie
displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times);
     
?></td>
  </tr>
</table>
<table width="1017" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="150" height="63" align="right" valign="top"> </td>
    <td width="150" valign="top"><img src="bilder/bonn.png" width="799" height="63" alt="bånn" /></td>
  </tr>
</table>
<hr size="1" color="#000000" />
</body>
</html>

Link to comment
Share on other sites

To get the results to populate the date/times in the proper order add the date to the ORDER clause in the query:

$query="SELECT 
            movies.id, movies.name, movies.age_limit, movies.length_time, movies.filmweb, movies.picture, 
            date.id AS date_id, date, 
            time.id AS time_id, time
        FROM movies
        JOIN date ON movies.id = date.movie_id
        JOIN time ON date.id = time.date_id
        ORDER BY movies.name, date";

 

For the date issue, I left off a couple lines. Replace the WHILE loop with this code

while($movie = mysql_fetch_assoc($result))
{
   //Check for new movie
   if ($current_film_name != $movie['name'])
   {
        //New movie

        if($current_film_name != "")
        {
            //If not the first record, display the last movie
            displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times);
        }

        $current_film_name = $movie['name'];

        $m_name      = $movie['name'];
        $m_image     = $movie['picture'];
        $m_age_limit = $movie['age_limit'];
        $m_length    = $movie['length_time'];
        $m_web       = $movie['filmweb'];
        $m_dates     = "";
        $m_times     = "";
        $current_film_date = "";
}

    //Date/time data
    if ($current_film_date != $movie['date'])
    {
        //Different date from last record, show it
        $current_film_date = $movie['date'];
        $m_dates .= "{$movie['date']}<br>";
    }
    else
    {
        //Same date as last, line break
        $m_dates .= "<br>";
    }

//Time date
$m_times .= "{$movie['time']}<br>";
}

 

That should take care of it

Link to comment
Share on other sites

try

<?php
require 'php/tilkobling.php';
$query="SELECT
            movies.id, movies.name, movies.age_limit, movies.length_time, movies.filmweb, movies.picture, 
            date.id AS date_id, date, 
            time.id AS time_id, time
        FROM movies
        JOIN date ON movies.id = date.movie_id
        JOIN time ON date.id = time.date_id
        ORDER BY movies.name, date, time";
$result=mysql_query($query);
$current_film_name = "";
$current_film_date = "";
$end_table = "";
$bestll = "      <tr>
        <td height='90' align='center'  valign='middle'><a href='bestill.html'><img src='../bestill.png' alt='bestill' width='70' height='21' border='0' /></a></td>
      </tr>";
while($movie = mysql_fetch_assoc($result))
{
if ($current_film_name != $movie['name']) {
	$current_film_name = $movie['name'];
	$current_film_date = "";
	if ($end_table) {
		echo "        <td rowspan='2'  valign='top'>$dates </td>";
		echo "        <td rowspan='2' align='center'  valign='top'>$times</td>";
		echo "        <td rowspan='2' align='center'  valign='top'></td>";
		echo "      </tr>";
		echo $bestll;
	}
	$br = "";
	echo $end_table;
	$end_table = "</table>";
	echo "<table background='bilder/Vindu_oversikt.png' width='764' height='300' align='center'  cellpadding='0' cellspacing='0'>";
	echo " <tr>";
	echo "     <td height='29' colspan='7'  valign='bottom'> {$movie['name']} </td>";
	echo "</tr>";
	echo "<tr>";
	echo "   <td width='204' rowspan='3' align='right'  valign='top'><strong></strong><img border='2px' src='{$movie['picture']}' alt='{$movie['name']}' width='190' height='235' /></td>";
	echo "        <td width='116' align='center'  valign='top' bordercolor='#F0F0F0'><span class='style12'>Aldersgrense:</span></td>";
	echo "        <td width='82' height='6'  valign='top'><span class='style12'>Spilltid:</span></td>";
	echo "        <td width='64' height='6'  valign='top'><span class='style12'>Filmweb:</span></td>";
	echo "        <td width='74' height='6'  valign='top'><span class='style12'>Dato:</span></td>";
	echo "        <td width='84' height='6' align='center'  valign='top'><span class='style12'>Klokkeslett:</span></td>";
	echo "        <td width='138' align='center'  valign='top'>Ledige billetter:</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td height='160' align='center'  valign='top'>{$movie['age_limit']} år</td>";
	echo "<td rowspan='2'  valign='top'>{$movie['length_time']}</td>";
	echo "<td rowspan='2'  valign='top'><a href='$film_filmweb'>Link</a></td>";
}
if ($current_film_date != $movie['date']) {
	$current_film_date = $movie['date'];
	$dates = $dates.$br.$current_film_date;
} else {
	$dates .= $br;
}
$times = $times. $br.$movie['time'];
$br = "<br />";
}
if ($end_table) {
echo "        <td rowspan='2'  valign='top'>$dates </td>";
echo "        <td rowspan='2' align='center'  valign='top'>$times</td>";
echo "        <td rowspan='2' align='center'  valign='top'></td>";
echo "      </tr>";
echo $bestll, $end_table;
}
?>     

not tested

Link to comment
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.