Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Multi Select Combo Box - Retrieving Data


I have a combo/listbox with "multiple" enabled in an HTML form and pass this to a PHP script, I should be able to access each item as $array_name[0] etc?

Thats what my book says and what I've been able to track down on Google seems to agree, but the only element I seem to be able to retrieve is $entry_select[0] (from the form below) which contains the last value selected in the combo list. Attempts to select $entry_select[1] just result in nothing printed. Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Database Value Select In Combo Box!
This function is intended to display the current database field value as selected.. along with other values as general options.

I can't figure out how to get it work. Help is appreciated!!

function retrieve_category()
{
$cat = mysql_query("SELECT category_id FROM category");
while ($current_row = mysql_fetch_row($cat))
{
$row = $current_row[0];
if ($row == $id)
{
printf("<option selected>%s</option>
",$current_row[0]);
}
else
{
printf("<option>%s</option>
",$current_row[0]);
}
}
}

PHP String Concatination With Html Select Combo Box
I have problem in PHP String concatination with html select combo
box.

There are 3 files

addressbook.sql :
concat1.php
concat2.php

In concat1.php , if we select User Name in combo box & give input as 3
in
text box.
It display following output
subhash kanade,3 sk@yahoo.com

But, it is not display in that way.
So, please see that code & tell me correction.

addressbook.sql

-- Table structure for table `addressbook`
--

CREATE TABLE `addressbook` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `addressbook`
--

INSERT INTO `addressbook` (`id`, `name`, `email`) VALUES (1, 'pramod
kumar', 'pk@hotmail.com'),
(2, 'vinod wagh', 'vinod@rediff.com'),
(3, 'subhash kanade', 'sk@yahoo.com'),
(4, 'ketan patil', 'kp@hotmail.com');

concat1.php

<?php

mysql_connect("localhost","root")or die("Database Failed");
mysql_select_db("pradeep")or die("Failed to Connect Database");

$arr=array("concat(concat(name,','),id)","email");

$str="select ".$arr[0].", ".$arr[1]." from addressbook";

$res=mysql_query($str) or die("resultset error");

echo "<table><tr><th>User</th><th>Email</th></tr>";
while($row=mysql_fetch_array($res)){
echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td></tr>";
}

Processing Data From Multiple Multi-line Textareas Into A Multi-dimensional Array
I know that this sounds like something overly complex - because it is.
However, if I can keep the user interface the way it is, my users will
be ultra happy! That is the goal...

In general, this is an inventory receiving piece of an overall larger
web-based ERP system.

What I have is a form in which I have a dynamic number of multline
textareas for inputting (possibly barcode scanning in) many serial
numbers per line item recieved.

For example:
lineitem01 = widget01; qtyReceived = 2;
lineitem02 = widget02; qtyReceived = 3;
lineitem03 = widget03; qtyReceived = 10;

This would display a form that will generate 3 textarea elements (1
per lineitem received). Inside each textarea element will be input the
serial numbers for each of the widgets received per lineitem. i.e. 2
serial numbers will be entered for widget01; 3 for widget02; and 10
for widget03;

So, what I am trying to do is pass this data over, possibly as a multi-
dimensional array to another form ( or possibly $_SERVER['PHP_SELF'] ) to update a MySQL database to store the widget/serial numbers.

Retrieve Data From Multiple Tables Via Combo
I am working on a small project to create a single web page which retrieves data from 3 tables.

The first table is retrieved by a combo box. It only contains the primary key of the table. I know how to get the data in the combo.

The second table contains other information, related to the primary key of table 1. I know how to retrieve all the data, but not how to retrieve only the data of the selected primary key. I think I should work with a WHERE clause in the SELECT statement, but I have no idea how to get to the selected value.

The third table should work in a similar way, so when I have an answer for the second table, I can also use it for the third table.

Retrieving Full Entry From Multiple Select List
I have a list box with multiple selects. I define the name as numList[]. I
get the values from

$picked = $_POST['numList'];

It retrieves values for all those selected.

If the entries are, say,
First
Second
Third

and the first and third are select then $picked[0] has "First" and
$picked[1] has "Third".
If, however, the entries are:

First one
Second one
Third one

Then the values are for $picked[0] and $picked[1] are "First" and "Third"
respecticely.
How do I retrieve the entire value and not just the first word?

Retrieving Contents Of Select List On Form Submit
On an HTML form, I have a select list that is fed dynamically with
detail records when the master record is displayed on the form.

There is also a second lookup list, and want to allow the user to
dynamically select from this list and add to the first list. I also
want the user to be able to dynamically remove from and reorder the
first list. I think I can do all of this with JavaScript.

The question I have, is how can I retrieve the contents of the first
list when the user submits the form? I need to get it back into a php
array so I can update and add the proper database records.

Multi-select Box Validation
I'm porting a cf site to php, everything's going very well, I
like php much better (this, of course, being the correct forum to make
that statement :).

One problem I have is with validating a form that has a couple multi-
select list boxes. The idea is that when the user submits the form, it
goes to it's process script. The process script validates the responses,
and if all is ok, finishes processing and "includes" a thank you page.
If there's an error, it "includes" the original form, but with some error
vbls defined now. Those variable should mark the field's label in red
(it does) and feed values back into all the fields. Text fields and
single-select boxes work fine. Multi-select boxes only have the last-
selected item selected. It sounds like a vbl that should be an array
somewhere isn't, but I can't figure out where.

Something like this:

Retrieving Form Data.
I have two scripts - common.php and edit.php. The working is that common.php contains a form that is used initially for registration and later used again so that registered users can edit their information. edit.php contains the connection to the db to update the form with the current users information. PHP Code:

Retrieving Data From Session Id??
This is what I have done:

on Page A:
<a href="<?php echo 'pageB.php?item=docs&sSID='.session_id();
?>">Docs</a>

on PageB:
<?php
if ($sSID) {
echo $_SESSION['username']; // THIS IS WHAT I WANT TO READ HERE
switch($_REQUEST['item']) {
case "docs": echo "doc files"; break;
case "reqdocs": echo "other files"; break;
case "misc": echo "miscellaneous files"; break;
default: echo "Invalid query"; break;
}
}
?>

As you can see on PageB, I tried to read the value of
$_SESSION['username'] but it gives nothing. The session file is
correctly created in my /tmp folder with the username field containing
valid data.

Retrieving Simple Data
Im wondering if someone can point me in the right direction. My Table

id  item_id  pet_id  game 
58 30892    37359 1
57 30986    37329 1
56 30977    37329 1
55 31213    37329 1

What its used for: It keeps a record of who has read what books. What I would like to do is create a high scores (top 100) list where the person (pet) who has read the most is displayed.

My problem is, I cant work out how to make it grab the data and count how many entries there are for each pet_id and then display that. What should I be searching for in the tutorials etc?

Radio Buttons, Retrieving Data
i ahve a form that has values in form of radio buttons. depending on th value selected, next page is selected. This form if for housing services. This form is for advertisements for houses for rent. I also have a little feature for editinf the ads, wherein i bring back all the values form the database (for the add) and allow them to edit it.
Is there any way in which a radio button field can be selected using the vaue in database(mysql)??

e.g radio buttons fields for milk(value=1), beer(2),water(3). and then i submit, the database gets value 2 (i selected beer). Then i click the edit button then i shud have beer selected even though the default is milk, for any new user.

Retrieving (Data + Fieldnames) From Database To Array?
I'd like to poll a database and get the table contents, as well as the field
names from that table. I've been to php.net but this time I cannot find
something helpful.

I can get the data, and retrieve it into an array noproblem. [1]

I can get the data+fieldnames and put it into a list. [2]

But I cannot seem to be able to fill an array with the data *and* the
fieldnames. If you check both chunks of code, you will se what I'm doing....

Multi Table Insert Delete Select Function Needed.
I am going nuts here and I know with all the functions out there, there must be an easier way to do this. Maybe someone can point me to the right tutorial or even show me how to do this.

I have a $main_id and many $sub_id tables and like to “SELECT to view” INSERT and DELETE those. UPDATE must not be but would be nice.
Here is how it looks:

Pulling Data From Multi Tables.
how i can pull back the info i have entered into the database. I have 4 tables:

Auto
Dimensions
Ratios
Specs

I have a specifications for a car called Honda Civic in the database that's accross those 4 tables. Im now wanting to pull all the info for the Honda Civic and im a little stuck They all have an ID called autoid but i dunno if i need that. Code:

Redundant Data Display Based On Multi-value Fields
I have a website where I want to send an email out to a bunch of users of all the new content posted that day. My content is tagged in different genres or groups. A piece of content can have multiple tags. So an example would be that my content is called "Video Program A" and it has been tagged in the vocabulary "Genre" as "Horror" and also as "Narrative". So in my email, if a piece of content has been tagged more than once, all the other fields get printed out multiple times, too. How can I make it so that even if the there are multiple termname and vocabname data, the rest of the data (title, description) only gets printed out once? Code:

Selecting/using Multi-table Data How Do You Manage 'current Record'?
I am working on a DB for family data, and in this application the data
spans variable amount of rows in multiple tables (one for the adults
data, one for "family", one for the kids, another for employment
schedule, and another for businesses, etc.). I was thinking on
selecting the entire family (IDs of all the related records) and
storing them in a session array for easy access (from script to
script) as I edit the data, but am wondering if there is a better way;
what other methods do any of you guys have have?

Am I correct in thinking this could be contained in a class? (I kinda
get classes but not all the way yet) And if a class is a good thing
- how is it persistent from script to script?

Pushing Data Into A Multi-dimensional Array From Mysql Results
First, A result array I'd want to get could look like this:

$chart['chart_data'] = array (
array ( "Region A", 10,12,11,15,20,22,21,25,31,32,),
);

The first is "Region A" and the rest is just int's that I'd pull from the db, so to set it I'd do this:

$chart [ 'chart_data' ][ 0 ][ 0 ] = "Region A";

But the problem is when I want to insert the data in the while loop (like the 10,12,11,15...), I've tried array_push but it's not working, maybe it doesn't work with multi-dimensional arrays? Anyways, here.'s what I tried, the following inside the "while" to loop the mysql results with mysql_fetch_assoc:

while($r=mysql_fetch_assoc($res)) {
   
     $chart [ 'chart_data' ][ 0 ][ 0 ] = array_push($chart['chart_data'][0][0], $r['wght']);
     // the above line is where I have problems    ^^
}

What I want is on each loop to insert the fetched data inside the array so that it gives what I gave first at the top, but what I've written above doesn't work, it gives me a warning saying "first argument must be an array" which seems to be one, but anyway, anybody know how to do this?

Select Data From Db?
I have a db that I need to select data out of. In the field it is selecting out of there is data input there from an array and then implode is used to seperate each item with a, When I run a query and wanna select data from this row I need the data from the previous form to = only one of the items in the row, but could be any of the items. how do I tell the page or the query that it could be any of many things in the row, but only has to be equal to one of them?

Select Data In Drop-down Box
I have a two text box and one select box.

two text box will be filled with date values. (in the form of
dd-mm-year)
First text box is called "start date"
Second is "end date"

Thus, I want to put dates between "start date" and "end date" in select
box.

Is there any way to put automatically in option field?
My idea is, first calculate the date difference
and then, add date till startdate + difference.

Getting Multiple Data From <select>
Can anyone give me a quick hint for this?

Say, I have: <SELECT NAME="opt3" SIZE="15" multiple>

Then I'd like to list the items selected...
echo $_POST["opt3"];
but this gives only the first one

how do I get the rest?

SELECT NOT GETTTING DATA
I can pass the phone number, and redirect URL ok, but i cant seem to pass the phone number, or account name successfully after the post, andy ideas? Code:

Retieving Data From Multiple Select
how can I insert data coming from a multiple select box knowing that I need
to insert other form fields at the same time.

<select name="auswahl[]" size="5" multiple>
<option value="bream">bream</option>
<option value="eel>eel</option>
<option value="pike>pike</option>
....
</select>

SQL SELECT, Selecting Data Within A Cell
I guess this is more sql than php, but there doesn't seem to be an
appropiate sql ng,
so anyway,
I am trying to find the SQL command that does something like:
$query = "SELECT filename FROM main WHERE keywords CONTAINS '$keywords' ";
ie, I want it to return "filename" when the data in field "keywords" is eg
"grass trees flowers" and someone searches with $keyword = "grass"
but I can't find what to replace CONTAINS with.

PHP Sendmail Doesn't Return Data From Select Form
My new HTML form contains a number of drop down select boxes. However when the form is submitted this data does not get emailed, it just comes back blank. I am using the $_POST command to return data.

Insert Data From Multiple Select List
Am trying to insert data into a mysql database from a multiple select list. How would i do this? Code:

Multi Sorting Multi Dimensional Array?
I have been using usort to sort my multi dimensional arrays ...

function cmp($a, $b){
if($a[0] == $b[0]){
return 0;
}
return ($a[0] < $b[0]) ? -1 : 1;
}
usort($searchResults, 'cmp');

Which works fine, but I need to sort by one element in the array, then
another, preserving the previous sort.

lets say the array is as follows:

array[0] = array[0] = foo
[1] = 2
[1] = array[0] = foo
[1] = 0
[2] = array[0] = bar
[1] = 1
[3] = array[0] = bar
[1] = 0
[4] = array[0] = foo
[1] = 1
[5] = array[0] = bar
[1] = 2

Initially, I sort the array in to groups based on array[?][0] using
usort as above so the output is :

foo, 2
foo, 0
foo, 1
bar, 1
bar, 2
bar, 0

Next though, I would like to sort this output by number (array[?][1])
in the groups so that the output is :

foo, 0
foo, 1
foo, 2
bar, 0
bar, 1
bar, 2

Is this possible? I am completely at a loss as to how to do this ...

Combo Box Value
On my site, if you click on a link i want you to be taken to a contact form that contains a combo box, but what I want to do is predefine what value of a possible five selections is set... What is the best way of doing this?

If And While Combo
I want to combine an IF statement with a WHILE condition.. They work fine seperate but i can't seem to combine them the way i want. Look @ my code so far: Code:

Combo Box
I am allowing users insert data into a database using a form. I want one of the fields "department" to display all existing departments in the database in a combo box for users to choose from and also have a field in the combo box for them to add a new department. Is there a way for me to do this in using php?

Combo Box?
how to make combo box link with my database? I want my data appear when drag down the combo box Can someone help me with the code i should use???

Combo Box Values
I have values in a combo box where datas are coming
loaded dynamically. When an user selects a particular value and press search, even after refreshing the page, I want to keep the value same as the user selects. For example suppose if I selects
value PHP from combo box, after submitting the combo box should
value highlighted must be PHP. IS there any way I can do this?

PHP/MySQL Combo
How come sometimes I get the following error:

Fatal error: out of dynamic memory in yy_create_buffer() in Unknown on line 0

My code works most of the time, its a combination of PHP and mySQL, i have no function named "yy_create_buffer". And the worst problem with this error message, is that when that error comes up, its the ONLY thing that comes up.

Other error messages at least they show up inside my page and they say what I specify the error messages to say. This type of error message would look totally unprofessional on the site I'm developing and I'm curious is there anyway to prevent this or somehow pinpoint the cause.

I'm starting to lose faith in PHP/mySQL . I'm starting to doubt whether the PHP environment is effective for a search engine which searches what will be a relatively large database.

Combo Boxes Question
I am wondering how I can make the whole array appear in the code that is below with the database entry to be selected. At the moment it just displays the database entry.

Populating Two Combo Boxes
I have one combo box (Category) which is populated by a MySQL table using php. I am trying to use the onchange javascript to submit the value selected so that I can populate the other combo box (sub-category) based on what was previously choosen. So can anybody give me a clue on how to submit the first boxes value so that the second can see what was selected (javascript function).

Combo Box / Text Box Php Mysql
this is the the code, now here is the final result.... I get one combo box
<?php require_once('..library_databaseConnectionsonli nequote.php'); ?>
<?
function select_cases_price ()
{
$qy = "SELECT SellingPrice, Description FROM cases";
$rs = mysql_query ($qy) or die (mysql_error ());
while (mysql_fetch_array ($rs))
{ $select .= "<option value='{$r[0]}'>{$r[0]}</option>";
$prices[] = $r{1};
}
return array ($select, $prices);
}
?>

On your web page, call the function.

<? list ($select, $prices) = select_cases_price (); ?> And a bit of JS:
<script>
function showPrice() {
array prices (<? echo $prices ?>);
var i = document.form.item.selectedIndex; document.form.SellingPrice =
prices[i]; </script>

<select name="Description" onUpdate="showPrice()"> <? echo $select; ?>
</select> <input type="text" name="SellingPrice" value="">

Combo Box Value On Page Reload
I am new to php and mySQL so this is probably something very basic that I'm
missing. Basically, on the page I have 2 combo boxes but 1 of them is not
getting the value passed when the page is reloaded so the database can be
updated. I am echoing the field names passed and the field "theDriver" is
there but it's empty. I've include the code parts where I believe the
problem should be but I'm stumped and I've been trying to solve this for 2
days without success. Would someone mind examing the following code and
tell me what I've done wrong?

Following code constructs the combo box on the page from a MySQL table:
<?PHP
$table = "tblEmployees";
$Link = mysql_connect ($host, $user, $password);

$Query = "select concat(empID,' ',empFirstName,'
',empLastName)
as full_name from $table WHERE empTitle =
'Driver'";
$results = mysql_db_query($database, $Query, $Link);
?>

&nbsp;&nbsp;&nbsp;&nbsp;<b>Driver:</b>
<select name = "theDriver" size="1">
<Option Value=" ">Select One:</option>

<?PHP
for($u=0;$u<mysql_num_rows($results); $u++)
{
$driver=mysql_result($results,$u,'full_name');
?>
<option value="<?PHP echo($ID); ?>"><?
echo($driver); ?></option>
<?PHP
}
?> //end php

</select>

When Page is reloaded the following code is run but the combo box titled
"theDriver" is empty

foreach($_POST as $field => $value)
{
echo $field; //field names from form
echo "; ";
if ($field == "theDriver")
{
echo " - here's the driver for ya: ";
$$field = strip_tags(trim($value));
echo $$field;
$pos = strpos($driver, ";");
echo "<br> the ; is in pos $pos <br>";.......

Dynamic Combo Boxes
i have a problem with creating some dynamic combo boxes. i have a form and the user enters the number of printers required, on the recieving page i display that many combo boxes ready for their input...but the problem is its not generating the correct number of combo boxes for some reason. i think i'ts because i need to reset the cursor on the result set so it can whip through the printers again but am not sure. please see following code:

Php Checkbox And Textbox Combo
I have a form which asks:

How did you know about us?

--friend
--flyer, where_______
--web
--other, _______

I want to store in the db whether the user checked the box and on
certain questions, store the additional description, as indicated by
the _____

How do I go about in doing this? I need help getting the values to
perform an INSERT in the mysql table using php.

How To Validate A Html Combo Box
I have a combo box on my html page that i would like to validate through php processing.
the name of my combo box group is "location" how would i use an IF statement to validate the contents of this combo box?

Mysql Dynamic Combo Box
i want to have a combo box that is populated by certain filelds of a mysql table. how is this done using mysql, php. i saw some other posts about using, javascript. must i?

the table that it is calling from isn't updated very often. also, one other note. i want 4 columns of the table represented in the 1 drop down box, so that users have a more specific description of the row they are selecting.

Creating Simple Combo Box
Very new to PHP and would like to create a combo box in which:

1. I have set an intial value (e.g. "mollusca") and
2. the user has the capability of adding additional values to the list.

Add/edit Combo Form--opinions Wanted
I would like to use the same form for adding new records and editing
existing records. New form values are contained in $_POST. Database values
are contained in an associated array. It seems to me that in order to use
the same form for both tasks, I need to assign the form field values to page
variables. The flow might look something like this:

if $_POST

$variable1 = $_POST['field1'];
$variable2 = $_POST['field2'];

else if $rows

$variable1 = $row['field1'];
$variable2 = $row['field2'];

Combo/list Box Showing Values Selected
I have a combo box being populated dynamically through php using a mysql database, and everything works fine.

My question is: How would i make it keep the values selected, once the user hits the submit button? For example, let's say i have a combo box with the values 1 2 3 4 5 in it. The user selects &#393;' and hits the submit button (which posts to the same page). At that point, i'd like the combo box to still have &#393;' selected, instead of resetting itself.

Multi User/ Multi Page Redirect To Particular Clients Page
I need all of my clients to be able to go to ONE login page. based on their user ID number and password be able to login to their particular page, I do not want them seeing any of my other clients information. seems easy... now why cant i figure it out.

I want the back end of it in mySQL, with a way for: admin to easily update the information located in there...ie: go to client 1 add new invoice information, new expiration date, etc. clients to easily update their billing information, etc from their personal page, is a must also. I just want to know if going with PHP is the best bet, or if there is another way..

Multiple Select From Listbox And Execute A Sql Query Select Statement
Supposing i have a html form with 2 listbox and i name it status and resolution.

So it goes <select name='status[]'>... <select name='resolution[]'>

Then i have a another php page.
$status = $_POST['status'];
$resolution = $_POST['resolution'];

Now my question is, how do i do the sql query statement?

mysql_query("SELECT * from bugs where status=$status and resolution=$resolution");

The problem is, i select 3 options form the status listbox eg. new, closed, duplicate. And from the resolution, i chose fixed, invalid.

SELECT Error: No Database Selectedin Query: SELECT * FROM Schedule
I got the above error message after reading FAQ #10 which applied to my first error. The thing is, I thought I had selected a database. This script is copied from a tutorial, and I'm just too new at this to spot my error. PHP Code:

Retrieving HTML
I was working on php script that could pull content from another site, and post it on mine. Some of the HTML from the site is not needed and I would like to remove it. How would I remove some of the HTML but keep that part that I need?

Retrieving NT User ID
Does anyone know how to retrieve the NT user id that someone is logged in as?

System is running IIS. Have tried HTTP_AUTHENTICATION but that doesnt appear to work under MS - unless someone knows a works around.

Alternatively - how can I retrieve a UNC pathname for a specific drive mapping.

Retrieving Records With Between
I am trying to convert my asp website to php. So far so good, but I am having a problem with my SQL Statement that needs to us the Between. Here is what I am using:

$sql = "Select * From tblTrack Where DateEntered Between $start and $end";

the vars start and end come from the same form. I don't have a problem when I hard code the dates, but when I use the variables, it won't retrieve anything.


Copyright © 2005-08 www.BigResource.com, All rights reserved