List/menu and mysql
Below is my code. How can I make the month selected in the
list/menu bring up the dynamic data from the mysql database. I have
spent hours but no luck.
Found my own error. Posting here quickly made me see the
error in my INSERT INTO query.
Similar Messages
-
HELP - List Menu 2 fields?
I have a recordset that returns a list of Manager names and
corresponding Manager ID numbers, which are two separate fields in
my database. I would like to create a dynamic list menu and display
both fields. This list menu would be used to drive another search
based on the what was selected from the menu. I need to be able to
only select the manager ID number for the search since it is unique
whereas the manager name could have duplicates. Is this possible???
Your help is appreciated in advanceDo you really need them shown? - i.e. a refresh?
or are you just looking to update 3 fields in the database?
If you are looking to update the database, you can use the
$_POST variable to insert into as many fields in the record as you
want. But his would be done in the MySQL statement, not the
form. -
Two options in select list menu
Let's say I have a select (list/menu) and I've added a dynamic source to it.
The menu will show a list of names. However, in the database the names are stored in two tables:
first_name
last_name
I don't want the list to just show last names because what if more than one person has a last name, how would you know who is who?
So, I've tried to get it to show the first and last name. Here is the code with just a last name showing:
<label for="employees"></label>
<select name="employees" id="employees">
<?php
do {
?>
<option value="<?php echo $row_getEmployee['employee_id']?>"><?php echo $row_getEmployee['lastname']?></option>
<?php
} while ($row_getEmployee = mysql_fetch_assoc($getEmployee));
$rows = mysql_num_rows($getEmployee);
if($rows > 0) {
mysql_data_seek($getEmployee, 0);
$row_getEmployee = mysql_fetch_assoc($getEmployee);
?>
</select>
The important part being:
I tried changing this:
<option value="<?php echo $row_getEmployee['employee_id']?>"><?php echo $row_getEmployee['lastname']?></option>
to this:
<option value="<?php echo $row_getEmployee['employee_id']?>"><?php echo $row_getEmployee['firstname' . 'lastname']?></option>
but that only showed the first letter of each last name and nothing else.
So - does anyone know how I could do this?Ok, first my standard disclaimer - I do not know PHP. But it seems to me that you can't include both column names in one call to the recordset. Try this instead:
<option value="<?php echo $row_getEmployee['employee_id']?>"><?php echo $row_getEmployee['firstname']." ".$row_getEmployee['lastname']?></option>
However, I would probably do my concantenation in the SQL select instead. -
List/Menu (multiple selected) insert into MySQL
I have been building a feedback form and I am running into a
issue that when I place a list/menu that allows multiple selections
when I submit my form in my MySQL database it collected the
information but only on the last multiple selection.
For example, this is what my list/menu looks like.
<select name="occasion" size="5" multiple="MULTIPLE"
id="occasion">
<option value="Spur of the moment,">Spur of the
moment</option>
<option value="Family dinner">Family
dinner</option>
<option value="Special occasion (i.e.
birthday)">Special occasion (i.e. birthday)</option>
<option value="Office get together">Office get
together</option>
<option value="Romantic dinner">Romantic
dinner</option>
<option value="Night out with friends">Night out with
friends</option>
<option value="Business meeting">Business
meeting</option>
<option value="Other">Other</option>
</select>
And my MySQL database I have it set up as...
Field Type
occasion mediumtext
I do not know why I cannot have more than one selection
inputed into my field, what must I do to correct this? Everything
works perfectly expect the multi selected list/menu. I want to
place all that is selected in the list/menu in that one database
field called occasion..oO(MikeL7)
>>You should also test with isset() and is_array() if
$_POST['occasion']
>>is available at all and of the expected type. The
code above will also
>>throw a notice if $insert_string is not initialized
before the loop.
>
> I use both isset and is_array in my code, When you say
notice, you dont mean
>a script stoppiong error?
Nope. An E_NOTICE error won't terminate the script, but
shouldn't happen
nevertheless. While developing, the error_reporting directive
should be
set to E_ALL|E_STRICT and _all_ reported problems should be
solved. It's
not only better coding style, but also helps to prevent real
errors. In
this particular case it was just a guess, because it was only
a part of
the code. But using an uninitialized variable with a '.='
operator for
example would lead to a notice, which should be fixed.
>>But of course this is a really bad DB design, as it
already violates the
>> first normal form (1NF). Just some ideas for queries
that might come to
>> mind, but would be really hard to do with such a
comma-separated list:
>
> A better table design would be to have column for |
list_ID | user_ID |
>song_ID | and do a insert for each song selected.
Yes, something like that.
>Thanks for the input, i like escaping the variables from
a string as they
>stand out more in code view, is the single quote method
faster? And which one
>will be or is already deprecated?
All are correct and won't be deprecated. IMHO it's more or
less just
personal preference. It also depends on the used editor and
its syntax
highlighting capabilities. For example I use Eclipse/PDT for
all my PHP
scripts, which can also highlight variables inside a string.
But if the
above is your preferred way, there's nothing really wrong
with it.
Just some additional thoughts:
Personally I prefer as less escaping and concatenating as
possible,
because such a mixture of single quotes, double quotes, dots
and
sometimes even escaped quote signs (for example when printing
HTML)
_really_ confuses me. I like to keep my code clean and
readable.
Something like this:
print "<img src=\"".$someVar."\" ...>\n";
not only hurts my eye, it is also quite error-prone. It's
easy to miss a
quote or a backslash and get a parse error back, especially
in editors
with limited syntax highlighting (or none at all). So I would
prefer
print "<img src='$someVar' ...>\n";
or even
printf("<img src='%s' ...>\n", $someVar);
When it comes to performance issues, of course there's a
difference
between the various methods. But for me they don't really
matter. In
practice you usually won't notice any difference between an
echo, a
print or a printf() call for example, as long as you don't
call them
a million times in a loop.
So I always just use the method that leads to the most
readable code.
In many cases, especially when a lot of variables or
expressions are
involved, (s)printf() wins. Not for performance, but for
readability.
But as said - personal preference. YMMV.
Micha -
Http Session combing HTML forms and List / Menu Components
My problem is the following one... I have a .jsp page that includes a form with three List / Menu Components. I want my second List / Menu Component to be filled with data depending on the selection I have made to the first List / Menu Components. (Of course there is a MYSQL database behind). And I want the third List Menu Component to be filled with data depending on the selection I have made to the second one.
Three options:
1) use incredibly large javascript arrays to hold the data for the second and third lists and use onChange events in the first and second list to alter the list contents based on selection
2) use ajax calls to fetch the data for the second and third list, still using javascript events to listen for selections.
3) do a form submit on each selection and fill the lists server side.
The third option is of course by far the easiest, but that will give you submits in between that you may not want. Ajax is a good solution to this problem in my opinion. -
While using a drop-down menu i.e. File, edit, image, or even when saving as and choosing the file type; the list appears and I am able to highlight what i want but cannot click on anything. This is becoming incredibly frustrating. It happens at random time and a restart of the computer is all that helps, then with out any notice it starts to do this again. Mac Book Pro i7 2.2 16 GB 1333 Ram, (2) 450GB SSD both internal to machine. At this point I am losing file because I am unable to save in the file type I need. Does anyone out there know how to solve this issue?
Thanks
philI haven't been unify photoshop much in the past month, but I did try your suggestion and it seemed to work for a while. Today when i went to save a document the same thing happened: click on file>save at this point I can not click on save even though it is highlighted. Tryed to use command s that brings up the save dialogue box, but when I try to change file type I again cannot select it from the drop down menu.
-
Please help! How can I validate Radio Buttons and List Menu with PHP.
Hello everyone, I have been learning PHP step by step and
making little projects.
The point is I find it easy to learn by doing "practical
projects."
I have been reading the David Powers's Book on PHP Solutions
and it's really great, however there is nothing mentioned regarding
Validating Radio buttons. I know the book cannot cover every aspect
of PHP and maybe someone in here can help.
I have been learning how to process HTML forms with PHP.
The problem is every book or tutorial I have read or
encountered fall short on validation.
I'm wondering how I can learn to validate Radio Buttons and
Select List Menu.
I have managed to create validation for all other fields but
have no clue as to how I can get validation for Radio Buttons and
List Menu.
I would also like an error message echoed when the user does
not click a button or make a selection and try to submit the form.
I would appreciate any help.
PatrickIt's not that default value is "None." In fact it's not. It
will only be
"none" when the form is submitted.
Also if your submit button is names 'send' then
$_POST['send'] will only be
set if the form was submitted.
Make sure you didn't hit the refresh button on your browser
which usually
reposts the information. Also make sure you did not reach the
form from
another form with the same button names.
Otherwise paste the snippet.
Also you can check what fields are set in the post array by
adding this to
the top of (or anywhere on) your page:
print_r($_POST);
Cosmo
"Webethics" <[email protected]> wrote in
message
news:[email protected]...
>
quote:
Originally posted by:
Newsgroup User
> Off the top of my head this should be no different than
your radio buttons
> except that 'productSelection' will always fail the
!isset check when the
> form is submitted since the default value is "None", and
therefore always
> set. :-)
>
> So how about this..?
> <?php
> if (isset($_POST['send']) and
($_POST['productSelection'] == "None"))
> {echo "Please select a product.";}
> ?>
>
>
>
>
> "Webethics" <[email protected]> wrote
in message
> news:[email protected]...
> > Another question - how do i applied the code you
just showed me to
> > select
> > menu
> > or select list?
> >
> > This is the list:
> >
> > <div class="problemProduct">
> > <label for="productSelection"><span
class="product_label">Product
> > Name.</span></label>
> > <select name="productSelection" id="products"
class="selection">
> > <option value="None">-------------Select a
product----------</option>
> > <option value="Everex DVD Burner">Everex DVD
Burner</option>
> > <option value="Vidia DVD Burner">Vidia DVD
Burner</option>
> > <option value="Excerion Super Drive">Excerion
Super Drive</option>
> > <option value="Maxille Optical Multi
Burner">Maxille Optical Multi
> > Burner</option>
> > <option value="Pavilion HD Drives">Pavilion
HD Drives</option>
> > </select>
> > </div>
> >
> > I thought I could just change the name is the code
from operatingSystem
> > to
> > productSelection.
> >
> > Something like this:
> >
> > From this:
> >
> > <?php
> > if (isset($_POST[send]) and
!isset($_POST['operatingSystem']))
> > {echo "Please select an operating system.";}
> > ?>
> >
> > To this:
> >
> > <?php
> > if (isset($_POST[send]) and
!isset($_POST['productSelection']))
> > {echo "Please select an operating system.";}
> > ?>
> >
> > But this does not work, any ideas?
> >
> > Patrick
> >
>
>
>
>
> Hey, I tried this about but as you mentioned, since the
default product
> value
> is "None" an error message appears when the page loads.
>
> Is there a way to code this things so that even though
the default value
> is
> "None" there ia no error message untle you hit the
submit?
>
> When I applied the code, it messes up the previous code,
now the operating
> system is requiring an entry on page load.
>
> When I remove the code from the list menu everything
goes back to normal.
>
> I know this is a little much but I have no other
alternatives.
>
> Patrick
> -
Menu and funciton listing under responsibility navigator tree
Hi,
I have a doubt regarding menu and function listing in responsibility navigator tree of Oracle Application. Is there any standard program which lists all the form and functions that are attached to a responsibility or
any query that lists exactly the same list of form and funcitons that are attached to the responsibility in the same order that appears in the navigator tree.
Any help will be appreciated.
Thanks,
ACheck the post by user487104 in this thread
Re: How to check a function is accessible under responsibility?
Hope this helps,
Sandeep Gandhi -
Accordion Panels and List Menu don't work if I place html files in subfolders
Hi all,
Switched from Dreamweaver to Muse and I have very limited knowledge of code.
Not an IT expert and not a web developer this is just for my own site.
I have sub-folders in my site. All html files are inside sub-folders except index.
ie contact.html or products.html I move them manually from root to the subfolder, using the easy interface of Dreamweaver. I call the subfolder "en"
so I can have pages such as mysite.com/en/contact.html
In the subfolder I copy and paste from root the css, images and script folders,
keeping the original css/images/scripts as well, in the root, so index.html is not affected.
and same time the look of the html pages inside the subfolders does not change.
BUT
list menus and accordion panels don't work. I click and there is no movement
How can I solve this ? I know Muse does not allow the creation of subfolders,
everything is uploaded in the root.
When in Dreamweaver I had placed 50 pages in subfolders and I was indexing them in google and bing.
Now can't again put 50 pages in root and can't remove URLs and make new indexing for all these pages
Any help ? many thanks for any assistance.The iPhone, like the Ipad, uses the Mobile Safari browser, so here's an earlier thread that might give you some insight: http://forums.adobe.com/thread/613494
-
MY iPod Nano 2nd generation iPod has died on me. I've charged it both by connecting to my laptop and also separately. I press the centre wheel and menu and the apple logo appears for a few seconds, then I get a glimpse of the menu then it disappears again. I have tried everything even leaving it plugged into the power for about four hours but it made no difference. What can I do?
Probably not a good sign especially given the age of the device. Are you able to get it into Disk Mode long enough so that you can restore it in iTunes?
Putting iPod into Disk Mode
Otherwise, it might be time to have the iPod serviced or replaced.
B-rock -
List/menu options from database
Hello
I need help trying to populate 2 list/menu with some database information.
Let's suppose that this is my table:
Id
Brand
Model
1
ford
f1
2
citroen
c1
3
citroen
c2
4
citroen
c3
5
toyota
t1
6
toyota
t2
7
volvo
v1
I have 2 list/menu. One is the brand menu, which extracts the values in the brand column of the database (using the DISTINCT statement in MySql). So when you click the menu, these options appear:
ford
citroen
toyota
volvo
The code for that menu is something like this:
<select name="menu_marque" id="menu_marque">
<option value="null">select</option>
<?php do { ?>
<?php
print '<option value="'.$row_marque_recordset['marque'].'">'.$row_marque_recordset['marque'].'</option>' ;
?>
<?php } while ($row_marque_recordset = mysql_fetch_assoc($marque_recordset)); ?>
</select>
Now, I want to do the same for the model menu. The problem is that I don't know how to write in the Sql, that it should take the selected value of the brand menu. I have something like this:
SELECT modele FROM test WHERE marque = 'colname' ORDER BY modele ASC
(where colname is: $_POST['menu_marque']..... Obviously I am not getting the value by a POST method, but I tried changing it to something like:
menu_marque.selectedIndex
but it doesn't work...... Any tips on how can I solve thisHi DanielAtwood,
Thanks for your reply...
Actually when i send the variable in 'WHERE Clause' in Db Adapter query it will retrieve more than one record as the output.
I want to put that values to a 'SelectOneChoice' component and list down all the values..
First I tried with data control. But i couldn't find the way to pass the value to the variable(in WHERE clause) to the query in data control view.
Thanks,
Nir -
Dynamic list/menu update page
Hi,
I am using PHP, Mysql. MySQL has different tables. Created list/menu to show data off one of the table that works great and when I select the value and hit the updae button it updates the database correctly. Problem I am having is that when I go to update the page again, it always defaults to the first value of the drop down list. I need it to remember the value that was selected. Hope this explains it well.Hi,
So the first example I am posting is pretty much the same idea as what Gunter wrote, Gunter wrote the way to handle it in dreamweaver.
This example is what happens in the code after the DW wizard does its thing.
Right before it submits to the database you can create a session of the value.
$_SESSION['cat_id'] = $_POST['cat_id'];
Then use a string compare command to check against the session.
(If session cat_id is the same as the recordset cat_id value then echo that line as selected)
<?php if (!(strcmp($row_listCategories['id'], $_SESSION['cat_id']))) {echo "selected=\"selected\"";} ?>
Here it is included in your code sample:
<select name="cat_id" multiple="multiple" size="5" id="cat_id">
<?php do { ?>
<option value="<?php echo $row_listCategories['id']?>"<?php if (!(strcmp($row_listCategories['id'], $_SESSION['cat_id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_listCategories['cat']?></option>
<?php
} while ($row_listCategories = mysql_fetch_assoc($listCategories));
$rows = mysql_num_rows($listCategories);
if($rows > 0) {
mysql_data_seek($listCategories, 0);
$row_listCategories = mysql_fetch_assoc($listCategories);
?>
</select>
Note that at the top of your page you will need to initiate the session:
session_start();
NOTE: This is example takes note that you added the multiple="multiple" tag to your select. If you want it so someone selects two items then after the update you want to call on both select items. (so all they selected is still selected, not just the last item.).
<select name="select[]" id="select" multiple="multiple">
<?php do { ?>
<?php if (is_array($_SESSION['cat_id'])) { ?>
<option value="<?php echo $row_listCategories['id']?>"<?php if (in_array($row_listCategories['id'], $_SESSION['cat_id'])) {echo "selected=\"selected\"";} ?>><?php echo $row_listCategories['cat']?></option>
<?php } else { ?>
<option value="<?php echo $row_listCategories['id']?>"<?php if (!(strcmp($row_listCategories['id'], $_SESSION['cat_id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_listCategories['cat']?></option>
<?php } ?>
<?php
} while ($row_listCategories = mysql_fetch_assoc($listCategories));
$rows = mysql_num_rows($listCategories);
if($rows > 0) {
mysql_data_seek($listCategories, 0);
$row_listCategories = mysql_fetch_assoc($listCategories);
?>
</select>
You will probably have to make an adjustment to your database input query to handle the array $_POST['cat_id']. I didnt have time to test that part. -
What is the difference between Oracle and MySQL
Hi,
I would like to know the major difference between Oracle and MySQL. I have a project to generate XML files from database tables, i have used oracle's built XML functions XMLELEMENT, XMLATTRIBUTES, XMLFOREST, XMLAGG. I really want to know if these functions (or) similar functions are supported/availabe in MySQL.
I am having a hard time to find out best linux distro for installing Oracle11g, so i am planning to switch to MySQL. Please help, Thanks in advance.Oracle_Walker wrote:
Hi,
<snip>>
I am having a hard time to find out best linux distro for installing Oracle11g, Then you must be "looking for love in all the wrong places."
What's so hard about finding a "best linux distro for installing Oracle11g"? The supported distros are listed in the fine Installation Guide for Linux. At the top of the list is Oracle's own Oracle Linux, which is in the same family as Red Hat.
so i am planning to switch to MySQL. Please help, Thanks in advance. -
How do you create a link to a pdf in Muse? Thought it was going to show that with Katie's menu and can't find in any of the tutorials.
The steps would be :
- Add files from file menu > select pdf > add to site
- Select the content (rectangle,text etc) and click on hyperlink dropdown > it should show you the added files list
- Select the file you want to link
Thanks,
Sanjit -
How do I pass a username form variable from a drop down list/menu to another page?
Hi,
I have a login_success.php page that has a drop down list/menu (which lists usernames). I want the user to click on their user name, and when they click the submit button the username information to be passed over to the username.php page which will contain a recordset, sorted by username.
How do I pass the username info from the drop down list/menu to the username.php page?
The drop down menu is connected to a recordset listUsername, I have filtered the recordset with the Form Variable = username, and I have used the POST method to send the username to the page username.php. I'm not sure how to structure the php or which page to place it on.
<form id="form1" name="form1 method="post" action="username.php">
<label for="username_id">choose username:</label>
<select name="username_id" id-"username_id">
<option value="1">username1</option>
<option value="2">username2</option>
<option value="3">username3</option>
<option value="4">username4</option>
</select>
<input type="submit" name="send" id="send" value="Submit" />
<input type="username" type="hidden" id="username" value="<?php echo $row_listUsername['username']; ?>" />
</form>
Could somebody help me please?
Thanks.I would not post the variable over, In this case I personally would send it through the URL and use the $_GET method to retreve it. For Example.
<html>
<head>
<title>Test Page</title>
<script type="text/javascript">
function userID(){
//var ID = form1.userIDs.selectedIndex;
var user = form1.userIDs.options[form1.userIDs.selectedIndex].value;
window.location = "test.html?userID=" + user;
</script>
</head>
<body>
<form id="form1">
<select name="userIDs" id="userIDs" onchange="userID();">
<option>Select a User</option>
<option value="1">User 1</option>
<option value="2">User 2</option>
<option value="3">User 3</option>
<option value="4">User 4</option>
</select>
</form>
</body>
</html>
//PAGE TO RETRIEVE THE USERNAME
<?php
if(isset($_GET['userID'])
$userID = $_GET['userID'];
echo $userID;
die;
Maybe you are looking for
-
I tried updating my iPod 5th gen to iOS 8 but it only shows me a picture of the iTunes logo and a charger at the bottom, I'm not sure what this means or what I need to do. Can someone please help me?
-
IPhone 3g only pulled in location of photographs taken in UK and USA
I have returned recently from a cruise , flying out to SIngapore and sailing back to Southampton, calling in at various locations, Thailand ,Malaysia, India, Oman,Jordan, Egypt, Greece and Rome. A great trip, took lots of photographs plus a lot with
-
How do I delete photos from an external hard drive before downloading to my new Mac?
I have a Seagate FreeAgent GoFlex external hard drive that has all my photos from my old computer on it Because there are thousands, I want to delete a bunch of them before downloading onto my new Mac. However, when I click on the photos, they say
-
*Unsolved Mystery* New Mini and my USB key
This has been a real mystery to me. I am usually great about problem solving. I have a MBP that recognizes and uses the iLok USB key without a problem. I bought a new Mac Mini, and the key will not work on the new computer. I have installed all t
-
Scanning and recognizing highlighted text
Is there a way to print a PDF: Highlight with a marker by hand. Then rescan the document and the software shall recognize the highlighted text and then highlight it "electronically" in the PDF. The reason is that I need to print it out as I need mult