Wrox Programmer Forums
|
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2006, 09:40 AM
Registered User
 
Join Date: Oct 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to mekanaren
Default CH 6 (edit the table)

The code is as follow--from the text book but when i click edit from index i cant see any thing..not even the html part..appriciate if some one help me.....


<?php
   $link = mysql_connect("localhost", "root", "naren")
      or die("Could not connect: " . mysql_error());
   mysql_select_db('wiley', $link) or die ( mysql_error());
   $peoplesql = "SELECT
               *
             FROM
               `people`
            ";
   $result = mysql_query($peoplesql)
      or die("Invalid query: " . mysql_error());
   while( $row = mysql_fetch_array( $result , MYSQL_ASSOC )){
      $people[ $row['people_id'] ] = $row['people_fullname'];
   }

   switch( $_GET['action'] ){
      case "edit":
         $moviesql = "SELECT
                     *
                   FROM
                     `movie`
                   WHERE
                      `movie`.`movie_id` = '".$_GET['id']."'
                  ";
         $result = mysql_query($moviesql)
            or die("Invalid query: " . mysql_error());
         $row = mysql_fetch_array( $result , MYSQL_ASSOC );
         $movie_name = $row[ 'movie_name' ];
         $movie_type = $row[ 'movie_type' ];
         $movie_year = $row[ 'movie_year' ];
         $movie_leadactor = $row[ 'movie_leadactor' ];
         $movie_director = $row[ 'movie_director' ];
         break;
      default:
         $movie_name = "";
         $movie_type = "";
         $movie_year = "";
         $movie_leadactor = "";
         $movie_director = "";
         break;
   }
?>
<html>
<head>
   <TITLE><?php echo $_GET['action']?> movie</TITLE>
</head>
<body>
<FORM action="commit.php?action=<?php echo $_GET['action']?>&type=movie&id=<?php
echo $_GET['id']?>" method="post">
   <table border=0 width="750" cellspacing=1 cellpadding=3 bgcolor="#353535"
align="center">
      <tr>
         <td bgcolor="#ffffff" width="30%">
            Movie Name
         </td>
         <td bgcolor="#ffffff" width="70%">
            <input type="text" name="movie_name" value="<?php echo $movie_name?>">
         </td>
      </tr>
      <tr>
         <td bgcolor="#ffffff">
            Movie Type
         </td>
         <td bgcolor="#ffffff">
         <SELECT id="game" name="movie_type" style="width:150px">
<?php
         $sql = "SELECT
                  `movietype_id`,
                  `movietype_label`
               FROM
                  `movietype`
               ORDER BY
                  `movietype_label`
               ";
         $result = mysql_query($sql)
            or die("Query Error".mysql_error());
         while ( $row = mysql_fetch_array($result) ){
            if ( $row['movietype_id'] == $movie_type){
               $selected = " SELECTED";
            } else {
               $selected = "";
            }
            echo '<OPTION value="'.$row['movietype_id'].'"'.$selected.'>'.$row['movietype_label'].
'</OPTION>'."\r\n";
         }
?>
         </SELECT>

         </td>
      </tr>
      <tr>
         <td bgcolor="#ffffff">
            Movie Year
         </td>
         <td bgcolor="#ffffff">
            <SELECT name="movie_year">
               <option value="" SELECTED>Select a year...</option>
<?php
for ($year=date("Y"); $year >= 1970 ;$year--){
            if ( $year == $movie_year){
               $selected = " SELECTED";
            } else {
               $selected = "";
            }
?>
               <option value="<?php echo $year?>"<?php echo $selected?>><?php echo
$year?></option>
<?
}
?>
            </SELECT>
         </td>
      </tr>
      <tr>
         <td bgcolor="#ffffff">
            Lead Actor
         </td>
         <td bgcolor="#ffffff">
            <SELECT name="movie_leadactor">
               <option value="" SELECTED>Select an actor...</option>
<?php
foreach( $people as $people_id => $people_fullname ){
            if ( $people_id == $movie_leadactor){
               $selected = " SELECTED";
            } else {
               $selected = "";
            }
?>
               <option value="<?php echo $people_id?>"<?php echo $selected?>><?php
echo $people_fullname?></option>
<?php
}
?>
            </SELECT>
         </td>
      </tr>
      <tr>
         <td bgcolor="#ffffff">
            Director
         </td>
         <td bgcolor="#ffffff">
            <SELECT name="movie_director">
               <option value="" SELECTED>Select a director...</option>
<?php
foreach( $people as $people_id => $people_fullname ){
            if ( $people_id == $movie_director){
               $selected = " SELECTED";
            } else {
               $selected = "";
            }
?>
               <option value="<?php echo $people_id?>"<?php echo $selected?>><?php
echo $people_fullname?></option>
<?php
}
?>
            </SELECT>
         </td>
      </tr>
      <tr>
         <td bgcolor="#ffffff" colspan=2 align="center">
            <INPUT type="SUBMIT" name="SUBMIT" value="<?php echo $_GET['action']?>">
         </td>
      </tr>
   </table>
</FORM>
</body>
</html>








Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit Access Table in Excel (2003) kewldude_3001 Access 0 April 10th, 2008 02:26 PM
Edit Table through a Form Coby Access VBA 3 August 17th, 2007 07:10 AM
Edit-add new entry to an acces table from word matpen Access 4 January 5th, 2006 06:30 PM
Edit value from Table acdsky Classic ASP Databases 1 June 28th, 2004 10:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.