Jump to content

Lets populate a forum Shall we? question


Adrienk

Recommended Posts

I have two scripts. One uses a drop down list to populate a forum while the other makes you enter in a value and populates the forum below with all the data in that table where the input matches the requested number.

 

So lets get down to it shall we?

 

1st up we have a movies list.

 

<?php
include('CheckLogin.php');
include ('databaseconfig.php');

$query = mysql_query("select title from movies");

if (isset($_POST['submitSearch']))
{
$query2 = mysql_query("select * from movies where title = ". $_POST['list']);
}
?>

<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Home
    </title>
<script type="text/javascript" src="javaScript/jquery-min.js"></script>
<script type="text/javascript" src="javaScript/corners.js"></script>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <link href="style.css" rel="stylesheet" type="text/css">

  </head>

  <body>
    <div id="wrapper">
      <header>
        <div id="header">
          <h1 id="logo">RAY AND CARLS
          </h1>
          <p class="description"><?php echo check();?><br/>
        </p>
        </div>
      </header>
      <nav>
        <ul id="nav">
          <li>
            <a href="index.php">Home
            </a>
          </li>
          <li>
            <a href="#">Customer Registration
            </a>
          </li>
          <li>
            <a href="#">View Movies
            </a>
          </li>
          <li>
            <a href="#">View Games
            </a>
          </li>
          <li>
            <a href="#">Rent
            </a>
          </li>
          <li>
            <a href="#">Login
            </a>
          </li>
                    <li>
            <a href="#">Admin
            </a>
          </li>
        </ul>
      </nav>
      <article>

        <section>


          <div class="cornerBox cBox3">
            <div class="cornerBox-content">
		<div class="List">
            <form class="cmxform" id="commentForm" action="action" method="post">
             <p>
               <select name="list">
                  <?php while ($row = mysql_fetch_array($query)) {
echo "<option>$row[title]</option>\n";
} ?>
               </select>
             </p>
             <p><input name="submitSearch" type="button" value="submit"></p>
             </form>
             <p>  </p>
             <form class="cmxform" id="commentForm" action="action" method="post">
             <h2>The Movie Selected
                </h2>
                  <p>
                  <?php while ($row2 = mysql_fetch_array($query2)){?>
                    <label for="cname">Movie ID:
                    </label>
                    <em>*
                    </em>
                    <input id="cname" name="movieid" size="4" class="required" minlength="2" value="<?php echo $row2[0];?>">
                  </p>
                  <p>
                    <label for="cemail">Rented <em> 0 for n, 1 for y</em>
                    </label>
                    <em>*
                    </em>
                    <input id="cemail" name="rented" size="2" class="required email" value="<?php echo $row2[1];?>">
                  </p>
                  <p>
                    <label for="curl">Title
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="title" size="30" class="url" value="<?php echo $row2[2];?>">
                  </p>
                  <p>
                    <label for="curl">Category
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="category" size="15" class="url" value="<?php echo $row2[3];?>">
                  </p>
                  <p>
                    <label for="curl">Director
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="director" size="15" class="url" value="<?php echo $row2[4];?>">
                  </p>
                  <p>
                    <label for="curl">Leading Actors
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="leadingactors" size="50" class="url" value="<?php echo $row2[5];?>">
                  </p>
                                    <p>
                    <label for="curl">Supporting Actors
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="supportingactors" size="50" class="url" value="<?php echo $row2[6];?>">
                  </p>
                                    <p>
                    <label for="curl">Run Time <em>in minutes</em>
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="runtime" size="4" class="url" value=""><?php echo $row2[7];?></input>
                  </p>
                                    <p>
                    <label for="curl">Rating
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="rating" size="6" class="url" value="<?php echo $row2[8];?>">
                  </p>
                                    <p>
                    <label for="curl">Release Date
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="releasedate" size="10" class="url" value="<?php echo $row2[9];?>">
                  <?php } ?>
              </form>
            </div>

            </div>
          </div>
        </section>
      </article>
      <footer>
        <div id="footer">


          <div class="footer1">
            <h2> About
            </h2>
            <p>
              Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, 
              feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi 
              vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, 
              condimentum sed, commodo vitae, ornare sit amet, wisi.
            </p>

          </div>

          <div class="footer2">
            <h2>Other places
            </h2>
            <p>
              <ul>
                <li>
                  <a href="#">Link 1
                  </a>
                </li>
                <li>
                  <a href="#">Link 2
                  </a>
                </li>
                <li>
                  <a href="#">Link 3
                  </a>
                </li>
                <li>
                  <a href="#">Link 4
                  </a>
                </li>
              </ul>
            </p>
          </div>

          <div class="footer3">
            <h2> Other information
            </h2>
            <p>
              Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, 
              feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi 
              vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, 
              condimentum sed, commodo vitae, ornare sit amet, wisi.
            </p>
          </div>

          <p class="credits">© 
            <a href="http://bwshome.byethost5.com/blogs">Adam Balan - BLACKANDWHITE
            </a> 
            <span>•
            </span> Powered by 
            <a href="http://bwshome.byethost5.com/blogs">BLACKANDWHITE
            </a> 
            <span>•
            </span> 

          </div>

        </footer>
      </div>
    </body>
  </html>]

 

This script populates a list with movie names with the select statement of select * from movies;

 

What I want to do is select a movie from this list and have the page refresh with a forum full of the details based on the movie title, hence the select * from movies where title = title statement.

 

What it currently does is populates a drop down list with titles of movies in the data base but not the forum....

 

2nd up we have the customer details

 

 

The second script is similar but now we want to populate a forum based on user input of a customer id.

 

So lets say we have an ID of 10, we enter 10 hit enter and the forum bellow should populate with all the customer info based on that id allowing me to edit and update (I haven't got to the update part yet, still trying to populate a forum)

 

<?php 
session_start(); 
include('CheckLogin.php'); 
include('databaseconfig.php');

if (isset($_POST['searchSubmit']))
{ 
$query = mysql_query("select * from customer where customer_id =".$_POST['cust_id']);
}
?>

  <!DOCTYPE HTML>
  <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>Home
      </title>


<script type="text/javascript" src="javaScript/jquery-min.js"></script>
<script type="text/javascript" src="javaScript/corners.js"></script>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>

</script>

    <link href="style.css" rel="stylesheet" type="text/css">
  </head>

  <body>
    <div id="wrapper">
      <header>
        <div id="header">
          <h1 id="logo">RAY AND CARLS
          </h1>
          <p class="description">
            <?php echo checkAdmin();?>
              <br/>
          </p>
        </div>
      </header>
      <nav>
        <ul id="nav">
          <li>
            <a href="index.php">Home
            </a>
          </li>
          <li>
            <a href="#">Customer Registration
            </a>
          </li>
          <li>
            <a href="#">View Movies
            </a>
          </li>
          <li>
            <a href="#">View Games
            </a>
          </li>
          <li>
            <a href="#">Rent
            </a>
          </li>
          <li>
            <a href="#">Login
            </a>
          </li>
          <li>
            <a href="#">Admin
            </a>
          </li>
        </ul>
      </nav>
      <article>

        <section>


          <div class="cornerBox cBox3">
            <div class="cornerBox-content">
              <p>All updates to the Data base can be done here. Keeping in mind specific relationships with
                The back end data bases.
              </p>

              <p>Some common tasks are below. This page allows you to add, edit and delete customers/movies and games.
              </p>
              <div class="cornerBox2 cBox3">
                <div class="cornerBox-content">
                  <h1>Menu
                  </h1>
                  <ul>
                    <h2>Customers
                    </h2>
                    <li>
                      <a href="#">edit
                      </a>
                    </li>
                    <li>
                      <a href="#">Add New
                      </a>
                    </li>
                    <h2>Movies
                    </h2>
                    <li>
                      <a href="#">edit
                      </a>
                    </li>
                    <li>
                      <a href="#">Add New
                      </a>
                    </li>
                    <h2>Games
                    </h2>
                    <li>
                      <a href="#">edit
                      </a>
                    </li>
                    <li>
                      <a href="#">Add New
                      </a>
                    </li>
                  </ul>
                </div>
              </div>
              <div class="Forum"> 
              <h2>Search</h2>

              <form class="cmxform" id="commentForm" method="post" action="">
                                <p>
                    <label for="cname">Customer ID:
                    </label>
                    <em>* id's must be > 0
                    </em>
                    <input id="cname" name="cust_id" size="25" class="required" minlength="2" />
                  </p>
                                    <p>
                    <input class="submit" type="submit" value="Submit" name="searchSubmit"/>
                  </p>
                  </form>
                <h2>Edit Customer
                </h2>
                              <?php 
		  
		  $resualt = mysql_query($query);
		  
		  while($row = mysql_fetch_array($resualt))
		  {
		  
		  ?>
                <form class="cmxform" id="commentForm" method="post" action="">

                  <p>
                    <label for="cname">Customer ID:
                    </label>
                    <em>*
                    </em>
                    <input id="cname" name="cust_id" size="25" class="required" minlength="2" value="<?php $row[0]?>"/>
                  </p>
                  <p>
                    <label for="cemail">First Name
                    </label>
                    <em>*
                    </em>
                    <input id="cemail" name="fname" size="25" class="required email" value="<?php $row[1]?>"/>
                  </p>
                  <p>
                    <label for="curl">Last Name
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="lastname" size="25" class="url" value="<?php $row[2]?>"/>
                  </p>
                  <p>
                    <label for="curl">Address
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="address" size="25" class="url" value="<?php $row[3]?>"/>
                  </p>
                  <p>
                    <label for="curl">Postal Code
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="postalcode" size="7" class="url" value="<?php $row[4]?>"/>
                  </p>
                  <p>
                    <label for="curl">Phone Number
                    </label>
                    <em>*
                    </em>
                    <input id="curl" name="phonenumber" size="11" class="url" value="<?php $row[5]?>""/>
                  </p>

                  <p>
                    <input class="submit" type="submit" value="Submit" name="submit"/>
                  </p>
                </form>
                <?php } ?>

                <?php 
			if (!mysql_query($query)) 
			{ 
			echo("<h1>Possible Errors
                </h1>");
                //Echo errors
                echo mysql_error();	
                echo ("<p>");
                }
                else
                {
                 echo("<h2>Customer was added</h1>");
			}

                  ?>
                </div>


              </div>
            </div>
          </section>
        </article>
        <footer>
          <div id="footer">


            <div class="footer1">
              <h2> About
              </h2>
                <p>
                  Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, 
                  feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi 
                  vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, 
                  condimentum sed, commodo vitae, ornare sit amet, wisi.
                </p>

              </div>

              <div class="footer2">
                <h2>Other places
                </h2>
                <p>
                  <ul>
                    <li>
                      <a href="#">Link 1
                      </a>
                    </li>
                    <li>
                      <a href="#">Link 2
                      </a>
                    </li>
                    <li>
                      <a href="#">Link 3
                      </a>
                    </li>
                    <li>
                      <a href="#">Link 4
                      </a>
                    </li>
                  </ul>
                </p>
              </div>

              <div class="footer3">
                <h2> Other information
                </h2>
                <p>
                  Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, 
                  feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi 
                  vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, 
                  condimentum sed, commodo vitae, ornare sit amet, wisi.
                </p>
              </div>

              <p class="credits">© 
                <a href="http://bwshome.byethost5.com/blogs">Adam Balan - BLACKANDWHITE
                </a> 
                <span>•

                </span> Powered by 
                <a href="http://bwshome.byethost5.com/blogs">BLACKANDWHITE
                </a> 
                <span>•

                </span> 
              </div>

            </footer>
          </div>
        </body>
      </html>

 

Now when I enter 10 into the search I get an error of:

 

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #5' at line 1"

 

I was told to make another thread for my question(s) and since these are in relation to each other (populating a forum and all) I thought it best to combine two into one.

 

 

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.