Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 28th, 2005, 08:17 AM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Store Items from dropdown menu in mysql database

Hi,
I was wondering if someone could help me. i have a form where the user is given two menus each with four options the user can choose from. when the user selects from one of the menus and clicks enter it runs a insert.php script that executes an insert query. if the user chooses from the data menu i want it to input the data info in the mysql db table or if they select from the time menu i want it to input the time info into the table.

this code gives the user thier menu options:

//data menu
<input type = "radio" name = "DataFrm" value = "Data">Data

<select name = "DataOptionFrm">
<?php
$qry = "SELECT TimeData, Cost, Description FROM Chrgtbl WHERE TimeData Like '%MB%'";

$result = mysql_query($qry);
while($row = mysql_fetch_array($result))
echo '<option value = "'.$row['TimeData'].'">'.$row['TimeData'].' || € '.$row['Cost'].' || '.$row['Description'].'</option>';
?>
</select>

//time menu
<input type = "radio" name = "TimeFrm" value = "Time">Time

<select name = "TimeOptionFrm">
<?php
$qry = "SELECT TimeData, Cost, Description FROM Chrgtbl WHERE TimeData Like '%MB%'";

$result = mysql_query($qry);
while($row = mysql_fetch_array($result))
echo '<option value = "'.$row['TimeData'].'">'.$row['TimeData'].' || € '.$row['Cost'].' || '.$row['Description'].'</option>';
?>
</select>


i have used the following code to insert the choice into the database but can't get it to work:
if ($DataOptionFrm)
{
$qry = "select ChrgID from chrgtbl where chrgtbl.TimeData = '$DataOptionFrm'";
$result = mysql_query($qry) or die(mysql_error());
$row = mysql_fetch_object($result);

$insert = "insert into tickettbl (AccID, ChrgID, TicketNo, TimeData, RecDate)values ('$TTAccID', '$row->ChrgID', '$Random', '$DataOptionFrm', '$TodaysDate')";

$result = mysql_query($insert) or die(mysql_error());

}
else
{
$qry = "select ChrgID from chrgtbl where chrgtbl.TimeData = '$TimeOptionFrm'";
$result = mysql_query($qry) or die(mysql_error());
$row = mysql_fetch_object($result);

$insert = "insert into tickettbl (AccID, ChrgID, TicketNo, TimeData, RecDate)values ('$TTAccID', '$row->ChrgID', '$Random', '$TimeOptionFrm', '$TodaysDate')";

$result = mysql_query($insert) or die(mysql_error());
}

it enters the right details if i select from the data menu i.e. if i choose 5MB it enters in ID 1. however if i choose any of the four options from the time menu it enters ID 1 which is data and not ID 5,6,7,8. None of the Time options gets entered even if selected. it just keeps entering the 1st Data menu option even if i choose from the Time menu

Can anyone help, i'm really stuck.

Thanks,

scoobie


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how many items can mysql store? yulin11 MySQL 1 December 6th, 2007 11:58 AM
Populate Select Menu from MySQL Database joviyach PHP Databases 4 June 24th, 2006 09:38 PM
How I store & retrieve List/Menu Mysql/PHP gsedrak1 PHP Databases 3 September 15th, 2005 08:49 PM
Store Checkbox values in MySQL Database jkilgore Beginning PHP 1 July 7th, 2005 03:43 PM
Two data items from a populated dropdown menu bear1138 Dreamweaver (all versions) 1 August 13th, 2003 09:52 AM



All times are GMT -4. The time now is 10:15 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.