Are you using mysql_fetch_assoc() ? Yep....
You got thru chapter 5 pretty quick....seems like it is going very slowly.
Anyway, here is the code.....see what you can see.....THANKS
This is the admin txt file (also have it saved as .php) After that is movie.php
[CODE<?php
$db = mysql_connect('localhost', 'bp6am', 'bp6ampass') or
die ('Unable to connect. Check your connection parameters.');
mysql_select_db('moviesite', $db) or die(mysql_error($db));
?>
<html>
<head>
<title>Movie database</title>
<style type="text/css">
th { background-color: #999;}
.odd_row { background_color: #EEE; }
.even_row { background_color: #FFF; }
</style>
</head>
<body>
<table style="width:100%;">
<tr>
<th colspan="2">Movies <a href="movie.php?action=add">[ADD]</a></th>
</tr>
<?php
$query = 'SELECT * FROM movie';
$result = mysql_query($query, $db) or die (mysql_error($db));
$odd = true;
while ($row = mysql_fetch_assoc($result)) {
echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">';
$odd = !$odd;
echo '<td style="width:75%;">';
echo $row['movie_name'];
echo '</td><td>';
echo ' <a href="movie.php?action=edit&id=' . $row['movie_id'] . '"> [EDIT]</a>';
echo ' <a href="delete.php?type=movie&id=' . $row['movie_id'] . '"> [DELETE]</a>';
echo '</td></tr>';
}
?>
<tr>
<th colspan="2">People <a href="people.php?action=add"> [ADD]</a></th>
</tr>
<?php
$query = 'SELECT * FROM people';
$result = mysql_query($query, $db) or die (mysql_error($db));
$odd = true;
while ($row = mysql_fetch_assoc($result)) {
echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">';
$odd = !$odd;
echo '<td style="width: 25%;">';
echo $row['people_fullname'];
echo '</td><td>';
echo ' <a href="people.php?action=edit&id=' . $row['people_id'] . '"> [EDIT]</a>';
echo ' <a href="delete.php?type=people&id=' . $row['people_id'] . '"> [DELETE]</a>';
echo '</td></tr>';
}
?>
</table>
</body>
</html>
[/code]
Code:
<?php
$db = mysql_connect('localhost', 'bp6am', 'bp6ampass') or
die ('Unable to connect. Check your connection parameters.');
mysql_select_db('moviesite', $db) or die(mysql_error($db));
?>
<html>
<head>
<title>Add Movie</title>
</head>
<body>
<form action="commit.php?action=add&type=movie" method="post">
<table>
<tr>
<td>Movie Name</td>
<td><input type="text" name="movie_name"/></td>
</tr><tr>
<td>Movie Type</td>
<td><select name="movie_type">
<?php
//select movie type information
$query = 'SELECT
movietype_id, movietype_label
FROM
movietype
ORDER BY
movietype_label';
$result = mysql_query($query, $db) or die(mysql_error($db));
//populate the select options with the results
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $value) {
echo '<option value="' . $row['movietype_id'] . '">';
echo $row['movietype_label'] . '</option>';
}
}
?>
</select></td>
</tr><tr>
<td>Movie Year</td>
<td><select name="movie_year">
<?php
// populate the select options with years
for ($yr = date("Y"); $yr >= 1970; $yr--) {
echo '<option value="' . $yr . '">' . $yr . '</option>';
}
?>
</select></td>
</tr><tr>
<td>Lead Actor</td>
<td><select name="movie_leadactor">
<?php
//select actor records
$query = 'SELECT
people_id, people_fullname
FROM
people
WHERE
people_isactor = 1
ORDER BY
people_fullname';
$result = mysql_query($query, $db) or die(mysql_error($db));
//populate the select options with the results
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $value) {
echo '<option value="' . $row['people_id'] . '">';
echo $row['people_fullname'] . '</option>';
}
}
?>
</select></td>
</tr><tr>
<td>Director></td>
<td><select name="movie_director">
<?php
//select director records
$query = 'SELECT
people_id, people_fullname
FROM
people
WHERE
people_isdirector = 1
ORDER BY
people_fullname';
$result = mysql_query($query, $db) or die(mysql_error($db));
//populate the select options with the results
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $value) {
echo '<option value="' . $row['people_id'] . '">';
echo $row['people_fullname'] . '</option>';
}
}
?>
</select></td>
</tr><tr>
<td colspan="2" style="text-align: center;">
<input type="submit" name="submit" value="Add" />
</td>
</tr>
</table>
</form>
</body>
</html>