looping problem..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nma
    New Member
    • Aug 2007
    • 93

    looping problem..

    Hi
    Could someone help me in identifying the location of the bold code to be insert. i want to insert into database the user log either php var $type='no features' or 'full features' depending on the user choice. Currently when I run, it stores $type='full features' eventhought I click on no features.

    Please help
    thansk
    nma

    [PHP]

    $movies = $db->get_results("s elect * from Movie" . $where . $ordered);
    if(!$movies)
    {
    echo '<td valign="top" class="movielis tTablemargin">' ;
    echo '<h3 style="color:re d;font-align:center;"> There are no movies matching your selection.</h3>';
    } else
    {
    echo '<td align="right" valign="top" class="movielis tTablemargin">' ;
    foreach($movies as $movie) {
    ?>
    <table width="400" border="0" cellspacing="2" cellpadding="1" >
    <tr>
    </tr>
    <?php
    if($movie->feature == 0)
    {
    $type = 'no features';
    ?>
    <tr bgcolor="#f5e9d c" onMouseOver="th is.bgColor='#e9 d7c4';" onMouseOut="thi s.bgColor='f5e9 dc';" onClick="docume nt.location='/moviebrowser/MB2searchNon.ph p?movieID=<?php echo $movie->movieID?>'" style="cursor:p ointer;">

    <td width="50" valign="top"><i mg src="<?php echo $movie->filmPoster; ?>" width="50" height="65" border="1" vspace="2"/></td>
    <td width="350" align="left" class="movielis tText"><b>
    <?php echo $movie->movieTitle;? ></b> (<?php echo $movie->year;?>) <font size="1" color="white" style="backgrou nd-color:red"><?ph p echo $movie->features;?></font><br />Directed by:
    <?php
    $directs = $db->get_results("s elect directorName from Director where directorID in (select directorID from MovieDirector where movieID = '" . $movie->movieID . "')");
    foreach ($directs as $direct) {
    echo " - ";
    echo $direct->directorName ;

    }
    ?>
    <br/>Genre:
    <?php
    $genres = $db->get_results("s elect genreName from Genre where genreID in (select genreID from MovieGenre where movieID = '" . $movie->movieID . "')");
    foreach ($genres as $genre) {

    echo " - " . $genre->genreName;
    }

    ?>

    </td>
    </tr>
    <tr>
    <td colspan="3" height="5"><img src="movielist-separator.jpg" width="386" height="1"/></td>
    </tr>
    <?php
    }
    else {
    $type = 'full features';
    ?>
    <tr bgcolor="#f5e9d c" onMouseOver="th is.bgColor='#e9 d7c4';" onMouseOut="thi s.bgColor='f5e9 dc';" onClick="docume nt.location='/moviebrowser/MB2search.php?m ovieID=<?php echo $movie->movieID?>'" style="cursor:p ointer;">

    <td width="50" valign="top"><i mg src="<?php echo $movie->filmPoster; ?>" width="50" height="65" border="1" vspace="2"/></td>

    <td width="350" align="left" class="movielis tText"><b>
    <?php echo $movie->movieTitle;? ></b> (<?php echo $movie->year;?>) <font size="1" color="white" style="backgrou nd-color:red"><?ph p echo $movie->features;?></font><br />Directed by:

    <?php
    $directs = $db->get_results("s elect directorName from Director where directorID in (select directorID from MovieDirector where movieID = '" . $movie->movieID . "')");
    foreach ($directs as $direct) {
    echo " - ";
    echo $direct->directorName ;
    }
    ?>
    <br/>Genre:
    <?php
    $genres = $db->get_results("s elect genreName from Genre where genreID in (select genreID from MovieGenre where movieID = '" . $movie->movieID . "')");
    foreach ($genres as $genre) {

    echo " - " . $genre->genreName;
    }
    ?>

    </td>
    </tr>
    <tr>
    <td colspan="3" height="5"><img src="movielist-separator.jpg" width="386" height="1"/></td>
    </tr>
    <?php
    }
    ?>
    </table>
    <?php
    }
    //to insert user log into database
    $db->query("INSER T INTO LogsTableMainsc reen (page, action, userID, type, date) VALUES ('movie features', 'click', " . $_SESSION['user']->userID . ", '$type', getDate())");


    }

    ?>

    [/PHP]
  • harshmaul
    Recognized Expert Contributor
    • Jul 2007
    • 490

    #2
    Hi mate, Whats being inserted at the moment?

    Comment

    • nma
      New Member
      • Aug 2007
      • 93

      #3
      Originally posted by harshmaul
      Hi mate, Whats being inserted at the moment?
      Hi
      currently it insert the second loop (after else) and store in the database type as 'full features'
      Suppose I choose (during the program running) as 'no features' but it still read as 'full features'

      I'm confius now

      Please help

      Thanks

      nma

      Comment

      Working...