Jump to content

Seapep

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Seapep's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the help guys. I got it to work, in the above code I was missing a set of { } brackets. Cheers,
  2. So something lilke this <?php require_once 'dblogin.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); if (!$db_server) die("Unable to connect to MySQL: " . mysql_error()); mysql_select_db($db_database) or die("Unable to select database: " . mysql_error()); $sql = "SELECT\n" . "levels.LevelID,\n" . "levels.LevelName\n" . "FROM\n" . "levels\n"; $result = mysql_query($sql) or die(mysql_error()); $options=""; while($row = mysql_fetch_array($result)){ $LevelID=$row["LevelID"]; $LevelName=$row["LevelName"]; $options.="<OPTION VALUE=\"$LevelID\">".$LevelName.'</option>'; $sql2 = "SELECT\n" . "events.EventID,\n" . "events.EventName\n" . "FROM\n" . "events\n"; $result2 = mysql_query($sql2) or die(mysql_error()); $options2=""; while($row2 = mysql_fetch_array($result2)) $EventID=$row2["EventID"]; $EventName=$row2["EventName"]; $options2.="<OPTION VALUE=\"$EventID\">".$EventName.'</option>'; } ?> <table width="500" border="1" align="center" cellpadding="0" cellspacing="1" > <tr> <td> <form name="form1" method="post" action="scheduleinsert_ac.php"> <table width="100%" border="1" cellspacing="1" cellpadding="3"> <tr> <td colspan="3"><div align="center"> <p><strong>Schedule Form</strong></p> </div></td> </tr> <tr> <td>Event Name</td> <td><div align="center">:</div></td> <td><select name="EventID"> <OPTION VALUE="0">Choose <?php echo $options2;?> </select></td> </tr> <tr> <td>Level</td> <td><div align="center">:</div></td> <td><select name="LevelID"> <OPTION VALUE="0">Choose <?php echo $options;?> </select></td> </tr>
  3. I guess the issue is where would I put the 2nd query which would populate the 2nd drop down list? I have seen a lot of examples but they all are linking back to each other via a relationship. Whereas what I have is 2 drop down lists querying 2 different tables. I tried to copy what I have with the corresponding fields and all I get is a blank field.
  4. Hi Folks, I am learning php and mysql so please bear with me and again if this is not in the right place please let me know. Anyways, I have a form setup that will be used to add events for a local sports team. I have 3 tables. Table1(Level) is working fine and populating the drop down form as I need it to. Table 2 is the Events. This is used to track all the event names that are used through the organization. Table 3 is the Schedule. This show all the events that are scheduled. What I need the form to do is allow the client to choose the event type and the level type for the registration process. Can I do this with mutliple dropdown lists with mysql/php? Here is what I have that is working. mysql_select_db($db_database) or die("Unable to select database: " . mysql_error()); $sql = "SELECT\n" . "levels.LevelID,\n" . "levels.LevelName\n" . "FROM\n" . "levels\n"; $result = mysql_query($sql) or die(mysql_error()); $options=""; while($row = mysql_fetch_array($result)){ $LevelID=$row["LevelID"]; $LevelName=$row["LevelName"]; $options.="<OPTION VALUE=\"$LevelID\">".$LevelName.'</option>'; } ?> <style type="text/css"> <!-- body p { color: #F00; } --> </style> <table width="500" border="1" align="center" cellpadding="0" cellspacing="1" > <tr> <td> <form name="form1" method="post" action="scheduleinsert_ac.php"> <table width="100%" border="1" cellspacing="1" cellpadding="3"> <tr> <td colspan="3"><div align="center"> <p><strong>Myers Schedule Form</strong></p> </div></td> </tr> <tr> <td>Event Name</td> <td><div align="center">:</div></td> <td></td> </tr> <tr> <td>Level</td> <td><div align="center">:</div></td> <td><select name="LevelID"> <OPTION VALUE="0">Choose <?php echo $options;?> </select></td> </tr>
  5. Awesome! thank you very much for that. I have been working on this the last several days and all it was was a missing ; Cheers, Seapep
  6. HI first timer here so please forgive me if this is in the wrong section. Anyway, here goes. I have 2 tables Table 1 Levels LevelID LevelName Table 2 Members MemberID FirstName LastName Birthdate LevelID I have a form that has the LevelID populated from table 1 with a query. When I enter all my data and hit submit the data gets written to the members table. However, the LevelID is written as 0 for each and everyone record that I have entered. So the question is what am I missing? As mentioned I am very new at this so any help would be greatly appreciated. Please see below for my code. Thanks in advance <?php require_once 'dblogin1.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); if (!$db_server) die("Unable to connect to MySQL: " . mysql_error()); mysql_select_db($db_database) or die("Unable to select database: " . mysql_error()); $sql = "SELECT\n" . "levels.LevelID,\n" . "levels.LevelName\n" . "FROM\n" . "levels\n"; $result = mysql_query($sql) or die(mysql_error()); $options=""; while($row = mysql_fetch_array($result)){ $LevelId=$row["LevelID"]; $LevelName=$row["LevelName"]; $options.="<OPTION VALUE=\"$LevelID\">".$LevelName.'</option>'; } ?> <style type="text/css"> <!-- body p { color: #F00; } --> </style> <table width="500" border="1" align="center" cellpadding="0" cellspacing="1" > <tr> <td> <form name="form1" method="post" action="insert_ac.php"> <table width="100%" border="1" cellspacing="1" cellpadding="3"> <tr> <td colspan="3"><div align="center"> <p><strong>Myers Player Registration Form</strong></p> </div></td> </tr> <tr> <td>First Name</td> <td><div align="center">:</div></td> <td><input name="firstname" type="text" id="firstname"></td> </tr> <tr> <td>Last Name</td> <td><div align="center">:</div></td> <td><input name="lastname" type="text" id="lastname"></td> </tr> <tr> <td>Birthdate (yyyy-mm-dd)</td> <td><div align="center">:</div></td> <td><input name="birthdate" type="text" id="birthdate"> </td> </tr> <tr> <td>Level</td> <td><div align="center">:</div></td> <td><select name="LevelID"> <OPTION VALUE="0">Choose <?php echo $options?> </select></td> </tr> </form> </td> </tr> </table>
×
×
  • 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.