Submit information into text box

Discussion in 'PHP' started by dannbkk, Jun 21, 2007.

  1. #1
    This code I have put together is meant to pull information from categories when the dropdown titles are selected and when add button is clicked it submits the information into the textarea field box,

    The problem is when add is clicked it is not?

    Where in my code is it wrong?

    <?php echo $_SERVER['PHP_SELF']; ?>">
    <table width="65%" border="0">
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
      <tr>
        <td width="7%">Day</td>
        <td width="47%"><select name="1" id="1">
          <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '1' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
            </select>
        <input type="hidden" name="Date" value="<%=dteDate%>">
    	<input name="showDate" type="text" style="width:200; position:absolute;" value="<%=dteShowDate%>" onClick="if(self.gfPop)gfPop.fPopRLCalendar(document.frm.Date,null,null,document.frm.showDate,null);return false;" readonly="true">
    	<a href="#" onClick="if(self.gfPop)gfPop.fPopRLCalendar(document.frm.Date,null,null,document.frm.showDate,null);return false;"  title="Click to open calendar">&nbsp;</td>
        </tr>
      
      <tr>
        <td>Golf</td>
        <td><select name="2" id="2">
          <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '2' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
        </tr>
      <tr>
        <td>Sight</td>
        <td><select name="3" id="3">
          <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '3' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
        </tr>
      <tr>
        <td>Flight</td>
        <td><select name="4" id="4">
          <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '4' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
        </tr>
      <tr>
        <td>Hotel</td>
        <td><select name="5" id="5">
          <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '5' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
            </select></td>
        </tr>
      
      
      <tr>
        <td valign="top">Info</td>
        <td><textarea name="6" cols="100" rows="8" id="6"><?=$_POST['19'];?></textarea></td>
        </tr>
      <tr>
        <td><table width="48" border="0" cellpadding="3">
          <tr>
            <td width="38"><input name="submit" type="submit" id="submit" value="Add" /></td>
            </tr>
        </table>
          <label></label>
          <?php
    if (isset($_POST['submit'])) {
    $a = $_POST['1'];
    $b = $_POST['2'];
    $c = $_POST['3'];
    $d = $_POST['4'];
    $e = $_POST['5'];
    $f = nl2br($_POST['6']);
    #if ($a == '' || $b == '' || $c == '' || $d == '' || $e == '') {
    #   echo '<center><font color="#FF0000">Please fill up all the blanks!</font></center>';
    #} 
    #else{
        mysql_query("INSERT INTO information (category, golf, sight, flight, hotel, info)
                                      VALUES ('$a', '$b', '$c', '$d', '$e', '$f')") or die("MySQL Error: ".mysql_error());
        echo '<center><font color="#008000">Business successfully added into the list!</font></center>';
    #}
    }
    ?>
    PHP:
     
    dannbkk, Jun 21, 2007 IP
  2. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Why are you using font tags?
     
    dp-user-1, Jun 21, 2007 IP
  3. dannbkk

    dannbkk Well-Known Member

    Messages:
    1,403
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    120
    #3
    I have submitted all my php code with some html tags around it, whats the problem by doing that?
     
    dannbkk, Jun 22, 2007 IP
  4. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #4
    He'd prefer you to use CSS, here is the simplest approach (for the notice at the end):
    <span style="color: #008000;">
    Code (markup):
    Instead of <font color...
     
    krt, Jun 22, 2007 IP
  5. PenSniffer

    PenSniffer Guest

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    why arn't you using a associative $_POST, and have you done a print_r($_POST) to see what it is storing?
     
    PenSniffer, Jun 22, 2007 IP
  6. dannbkk

    dannbkk Well-Known Member

    Messages:
    1,403
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    120
    #6
    Actually I am re-designing the layout of this now slightly becuase I want a different system.

    I am putting this form together that will call 5 different rows from the database in dropdown format.
    http://www.seo2webdesign.com/add_golf_tour.php

    Can anyone tell me a better way to call Days etc. I am trying to work out a system like this but have a dropdown to select Day1 , Day2 etc, all the way to Day 30 but it seems a little unfriendly this way.

    And I also want a certain output which i need help with that you can see down the bottom.

    Does anyone have any suggestions of what they would do?

    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <table width="65%" border="0">
      <tr>
    <td>Heading</td>
        <td><textarea name="6" cols="70" rows="1" id="6"><?=$_POST['6'];?>
        </textarea></td>
        </tr>
      <tr>
        <td width="7%">Day 1 </td>
        <td width="47%"><select name="1" id="1">
          <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '1' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
            </select>
        <input type="hidden" name="Date" value="<%=dteDate%>">
    	<input name="showDate" type="text" style="width:200; position:absolute;" value="<%=dteShowDate%>" onClick="if(self.gfPop)gfPop.fPopRLCalendar(document.frm.Date,null,null,document.frm.showDate,null);return false;" readonly="true">
    	<a href="#" onClick="if(self.gfPop)gfPop.fPopRLCalendar(document.frm.Date,null,null,document.frm.showDate,null);return false;"  title="Click to open calendar">&nbsp;</td>
        </tr>
      
      <tr>
        <td>Golf</td>
        <td><select name="2" id="2">
          <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '2' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
        </tr>
      <tr>
        <td>Sight</td>
        <td><select name="3" id="3">
          <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '3' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
        </tr>
      <tr>
        <td>Flight</td>
        <td><select name="4" id="4">
          <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '4' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
        </tr>
      <tr>
        <td>Hotel</td>
        <td><select name="5" id="5">
          <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '5' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
            </select></td>
        </tr>
      <tr>
        <td>Day 2 </td>
        <td><select name="1" id="1">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '1' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
          </select>
            <input type="hidden" name="Date" value="<%=dteDate%>" />
            <input name="showDate" type="text" style="width:200; position:absolute;" value="<%=dteShowDate%>" onclick="if(self.gfPop)gfPop.fPopRLCalendar(document.frm.Date,null,null,document.frm.showDate,null);return false;" readonly="true" />
            <a href="#" onClick="if(self.gfPop)gfPop.fPopRLCalendar(document.frm.Date,null,null,document.frm.showDate,null);return false;"  title="Click to open calendar">&nbsp;</td>
      </tr>
      <tr>
        <td>Golf</td>
        <td><select name="2" id="2">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '2' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td>Sight</td>
        <td><select name="3" id="3">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '3' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td>Flight</td>
        <td><select name="4" id="4">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '4' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td>Hotel</td>
        <td><select name="5" id="5">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '5' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td>Day 3 </td>
        <td><select name="1" id="1">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '1' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
          </select>
            <input type="hidden" name="Date" value="<%=dteDate%>" />
            <input name="showDate" type="text" style="width:200; position:absolute;" value="<%=dteShowDate%>" onclick="if(self.gfPop)gfPop.fPopRLCalendar(document.frm.Date,null,null,document.frm.showDate,null);return false;" readonly="true" />
            <a href="#" onClick="if(self.gfPop)gfPop.fPopRLCalendar(document.frm.Date,null,null,document.frm.showDate,null);return false;"  title="Click to open calendar">&nbsp;</td>
      </tr>
      <tr>
        <td>Golf</td>
        <td><select name="2" id="2">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '2' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td>Sight</td>
        <td><select name="3" id="3">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '3' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td>Flight</td>
        <td><select name="4" id="4">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '4' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td>Hotel</td>
        <td><select name="5" id="5">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '5' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td>Day 4 </td>
        <td><select name="1" id="1">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '1' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
          </select>
            <input type="hidden" name="Date" value="<%=dteDate%>" />
            <input name="showDate" type="text" style="width:200; position:absolute;" value="<%=dteShowDate%>" onclick="if(self.gfPop)gfPop.fPopRLCalendar(document.frm.Date,null,null,document.frm.showDate,null);return false;" readonly="true" />
            <a href="#" onClick="if(self.gfPop)gfPop.fPopRLCalendar(document.frm.Date,null,null,document.frm.showDate,null);return false;"  title="Click to open calendar">&nbsp;</td>
      </tr>
      <tr>
        <td>Golf</td>
        <td><select name="2" id="2">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '2' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td>Sight</td>
        <td><select name="3" id="3">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '3' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td>Flight</td>
        <td><select name="4" id="4">
            <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '4' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td>Hotel</td>
        <td><select name="5" id="5">
    <?php
            $r = mysql_query("SELECT * FROM category WHERE cat_group = '5' ORDER BY id ASC") or die("MySQL Error: ".mysql_error());
            while ($row = mysql_fetch_assoc($r)) {
                echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
            }
            ?>
        </select></td>
      </tr>
      <tr>
        <td colspan="2"><table width="200" border="0" cellpadding="0">
          <tr>
            <td>Cost</td>
            <td><textarea name="7" cols="70" rows="1" id="7"><?=$_POST['7'];?>
            </textarea></td>
          </tr>
        </table></td>
        </tr>
      
      <tr>
        <td><table width="48" border="0" cellpadding="3">
          <tr>
            <td width="38"><input name="submit" type="submit" id="submit" value="Add" /></td>
            </tr>
        </table>
          <label></label>
          <?php
    if (isset($_POST['submit'])) {
    $a = $_POST['1'];
    $b = $_POST['2'];
    $c = $_POST['3'];
    $d = $_POST['4'];
    $e = $_POST['5'];
    $f = nl2br($_POST['6']);
    $g = nl2br($_POST['7']);
    #if ($a == '' || $b == '' || $c == '' || $d == '' || $e == '') {
    #   echo '<center><font color="#FF0000">Please fill up all the blanks!</font></center>';
    #} 
    #else{
        mysql_query("INSERT INTO information (category, golf, sight, flight, hotel, info, cost)
                                      VALUES ('$a', '$b', '$c', '$d', '$e', '$f', $g')") or die("MySQL Error: ".mysql_error());
        echo '<center><font color="#008000">Business successfully added into the list!</font></center>';
    #}
    }
    ?>
    PHP:
    Output I want is simply like this;
    This is corresponding with the following tables
    ;

    info (table)
    5 days/ 4 nights Bangkok – Hua Hin – Chiang Mai – Phuket Golf Holiday Package for Mr. and Mrs. Lewis

    category, golf, sight, flight (tables)
    Day 1, Sunday October 21: arrive Bangkok (QR 612, 07:20), transfer to your hotel
    Day 2, Monday October 22: half day city tour including visit to Grand Palace
    Day 3, Tuesday October 23: golf at Thai Country Club (site of Tiger Woods PGA Victory in 1997, best clubhouse in Asia)
    Day 4, Wednesday October 24: free day, at your own leisure shopping and at relaxing at pool
    Day 5, Thursday October 25: golf at Mission Hills Kanchanaburi (Jack Nicklaus design), transfer to River Kwai, check in your hotel


    This is corresponding with the following tables;
    hotel
    (table)
    Inclusive of following:
    -- 4 Nights accommodation in Bangkok at 5-star Shangri La Hotel, superior room, excluding daily breakfast
    -- 3 Nights accommodation in Kanchanaburi at 4-star Felix Resort, superior room, including daily breakfast
    -- 6 Nights accommodation in Hua Hin at 4-star Holiday Inn Beach Resort, standard room, including daily breakfast
    -- 6 nights accommodation in Chiang Mai at 4-star Imperial Mae Ping Hotel, superior room, including daily breakfast
    -- 8 nights accommodation in Phuket at 5-star Le Royal Meriden Yacht Club, ocean front deluxe room, including daily breakfast

    cost (table)
    All green fee, accommodation & transport costs based on 2 golfers:
    Special offer, per person, double occupancy = 188,440 Thai Baht
     
    dannbkk, Jun 22, 2007 IP