By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

looping problem..

P: 93
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("select * from Movie" . $where . $ordered);
if(!$movies)
{
echo '<td valign="top" class="movielistTablemargin">';
echo '<h3 style="color:red;font-align:center;">There are no movies matching your selection.</h3>';
} else
{
echo '<td align="right" valign="top" class="movielistTablemargin">';
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="#f5e9dc" onMouseOver="this.bgColor='#e9d7c4';" onMouseOut="this.bgColor='f5e9dc';" onClick="document.location='/moviebrowser/MB2searchNon.php?movieID=<?php echo $movie->movieID?>'" style="cursor:pointer;">

<td width="50" valign="top"><img src="<?php echo $movie->filmPoster; ?>" width="50" height="65" border="1" vspace="2"/></td>
<td width="350" align="left" class="movielistText"><b>
<?php echo $movie->movieTitle;?></b> (<?php echo $movie->year;?>) <font size="1" color="white" style="background-color:red"><?php echo $movie->features;?></font><br />Directed by:
<?php
$directs = $db->get_results("select 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("select 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="#f5e9dc" onMouseOver="this.bgColor='#e9d7c4';" onMouseOut="this.bgColor='f5e9dc';" onClick="document.location='/moviebrowser/MB2search.php?movieID=<?php echo $movie->movieID?>'" style="cursor:pointer;">

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

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

<?php
$directs = $db->get_results("select 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("select 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("INSERT INTO LogsTableMainscreen (page, action, userID, type, date) VALUES ('movie features', 'click', " . $_SESSION['user']->userID . ", '$type', getDate())");


}

?>

[/PHP]
Feb 14 '08 #1
Share this Question
Share on Google+
2 Replies


harshmaul
Expert 100+
P: 490
Hi mate, Whats being inserted at the moment?
Feb 15 '08 #2

P: 93
nma
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
Feb 15 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.