Hello there,

I am having trouble with a form/database. I have 3 age groups that needs to be sorted into 3 separate tables. Users fill in a form (dropdown list with the separate age groups) and when they click submit, the data gets sorted in tables on another page. With the help of dreamweaver I could get the list linked to 1 table, but can't get it to sort into the 3 different tables.

The DB's name is: "hotel"
The table's name is: "besprekings"
I would like to organize the data based on their choice in "Graad" (sorry for different language) (bolded area) so if they chose "10" their data would be sorted into the "graad 10" table and so on.

I hope I'm making sense..

Here's the code:

<?php require_once('Connections/hotel.php'); ?>
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  return $theValue;

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO besprekings (`Naam en Van`, Epos, `Telefoon Nommer`, `Aantal Sitplekke`, Graad, Datum) VALUES (%s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Naam_en_Van'], "text"),
                       GetSQLValueString($_POST['Epos'], "text"),
                       GetSQLValueString($_POST['Telefoon_Nommer'], "text"),
                       GetSQLValueString($_POST['Aantal_Sitplekke'], "text"),
                       GetSQLValueString($_POST['Graad'], "text"),
                       GetSQLValueString($_POST['Datum'], "text"));

  mysql_select_db($database_hotel, $hotel);
  $Result1 = mysql_query($insertSQL, $hotel) or die(mysql_error());

  $insertGoTo = "dankie.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  header(sprintf("Location: %s", $insertGoTo));
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>La Doraigne</title>
<link rel="stylesheet" type="text/css" href="css.css" media="screen" />
<script src="request.js"></script>
function handleOnChange(dd1)
  var idx = dd1.selectedIndex;
  var val = dd1[idx].text;
  var par = document.forms["form1"];
  var parelmts = par.elements;
  var prezsel = parelmts["Datum"];
  var Graad = val;
  if (Graad != "Kies graad")
		url: "./" +  Graad + ".txt",
		callback: fillPrez,
		cache: Http.Cache.Get
	}, [prezsel]);

function fillPrez(xmlreply, prezelmt)
  if (xmlreply.status == Http.Status.OK)
    var prezresponse = xmlreply.responseText;
    var prezar = prezresponse.split("|");
    prezelmt.length = 1;
    prezelmt.length = prezar.length;
    for (o=1; o < prezar.length; o++)
      prezelmt[o].text = prezar[o];
    alert("Cannot handle the AJAX call.");

<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
    <table align="left">
      <tr valign="baseline">
        <td width="114" align="left" nowrap="nowrap">Naam en Van:</td>
        <td width="212"><input type="text" name="Naam_en_Van" value="" size="32" /></td>
      <tr valign="baseline">
        <td nowrap="nowrap" align="left">Epos:</td>
        <td><input type="text" name="Epos" value="" size="32" /></td>
      <tr valign="baseline">
        <td nowrap="nowrap" align="left">Telefoon Nommer:</td>
        <td><input type="text" name="Telefoon_Nommer" value="" size="32" /></td>
      <tr valign="baseline">
        <td nowrap="nowrap" align="left">Aantal Sitplekke:</td>
        <td><select name="Sitplekke">
			<option value="1" <?php if (!(strcmp(1, ""))) {echo "SELECTED";} ?>>1</option>
            <option value="2" <?php if (!(strcmp(2, ""))) {echo "SELECTED";} ?>>2</option>
            <option value="3" <?php if (!(strcmp(3, ""))) {echo "SELECTED";} ?>>3</option>
            <option value="4" <?php if (!(strcmp(4, ""))) {echo "SELECTED";} ?>>4</option>
            <option value="5" <?php if (!(strcmp(5, ""))) {echo "SELECTED";} ?>>5</option>
            <option value="6" <?php if (!(strcmp(6, ""))) {echo "SELECTED";} ?>>6</option>
            <option value="7" <?php if (!(strcmp(7, ""))) {echo "SELECTED";} ?>>7</option>
            <option value="8" <?php if (!(strcmp(8, ""))) {echo "SELECTED";} ?>>8</option>
      <tr valign="baseline">
        [B]<td nowrap="nowrap" align="left">Graad:</td>
        <td><select name="Graad" onChange="handleOnChange(this);">
<option>Kies graad</option>
<option value="10" <?php if (!(strcmp(10, ""))) {echo "SELECTED";} ?>>10</option>
<option value="11" <?php if (!(strcmp(11, ""))) {echo "SELECTED";} ?>>11</option>
<option value="12" <?php if (!(strcmp(12, ""))) {echo "SELECTED";} ?>>12</option>

        </td>[/B]      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="left">Datum:</td>
		<select name="Datum">
		<option>Kies Datum</option>
      <tr valign="baseline">
        <td nowrap="nowrap" align="left">&nbsp;</td>
        <td><input type="submit" value="Gaan Voort" /></td>
    <input type="hidden" name="MM_insert" value="form1" />
9 Years
Discussion Span
Last Post by litchi

Hi again,

I got it working :)

Simple if statement on receiving page. Sorry.


This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.