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




Getting All Select Box Values


I'm running into a problem with a select box. Its values in PHP are not properly parsed.

<select name="frm_owners" size="10">
    <option value="1">Apples</option>
    <option value="2">Oranges</option>
</select>

Now, if I were to select both options and then output $_POST[frm_owners] on another page, all I would get is "2." But I'm looking for a comma-seperated value like "1,2." Any ideas?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Select Distinct Values In Only 2 Columns
I have a table where a customer may have multiple accounts.

I want to eliminate duplicate values for Customer_ID and Account_ID -- regardless of their state or region.

I tried this,

SELECT (DISTINCT Acct_ID, Cust_ID), Address, City,State, Zip,Country, Contact, State_ID,Region_ID,
FROM t_table

but it doesn't work.

This (below) does work, but it gives 2 records. One record when a person is listed once in a target state, and a second record if that person is listed in an overlapping region.

SELECT DISTINCT Acct_ID, Cust_ID, Address, City,State, Zip,Country, Contact, State_ID,Region_ID,
FROM t_table

(this is the same as)
SELECT DISTINCTROW Acct_ID, Cust_ID, Address, City,State, Zip,Country, Contact, State_ID,Region_ID,
FROM t_table

Is there any other way to select distinct values in only 2 columns?

Population Select Menu Using Php And Database Values
I have no idea how to go about this. so i would apreciate some help i want to populate the values in a html select menu from database values in one table

so i want all the values from 1 particular field in the database to be displayed in the select menu as separate options.

Popup Window List Of Values To Select
What i need to do is bring up a popup window with a list of values(values looked up from the database). The user should be able to select one of the values from the list and the value then populate a text box on the calling form.

Convert CSVs To Select Option Values
I was just wondering if someone could point me to a good web resource that could help me figure out how to convert a string of comma separated values (being pulled from a database) into a select menu (pulldown box) so that the values from the CSV would automatically fill in the displayed text area of the option tags as well as the value attribute so the value selected could actually be passed as a variable.

I imagine it has something to do with converting the CSV list into an array using substring parsing & then dynamically building the array from the elements of the array, but I just haven't been able to put it all together yet. If anyone is familiar with anything published on the web that might help, I'd be deeply appreciative.

Run A Select Statement Based On Array Values?
I have an array that has x number of values. I want to run a sql statement x number of times using the next array value each time. Basically I have a query that displays results based on a search. The result of the search is a list of names, the trouble is for reasons beyond my control the names are in a single db field as "FirstLast".

I want to take this value and match it up to another table that has the first and last names in separate fields. So far I have extracted the results from the first query using a while loop, the resulting array is called $name_search: Code:

Comparing User Input Values In A Form With Database Values
I want to compare user input values in a form with my database.
Basically I want to check whether the user exits in my database.
What mysql command can do that?

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:

Adding New Values To An Array That Already Contains Values..
is it possible to append new values to an array that already has values in it??

say, i have my existing array;

existing array;
$array = array([66314] => 66314 , [66315] => 66315) ;

then , when i check my checkbox on my next page, the ids should be appended to the $array:

array that needs to be added to the $array;

$array = array([66316] => 66316,[66317] => 66317,[66318] => 66318);

how should it be done??

Select Statement - Select Random ID #
I have made up a page that pull info on 13 branches of stores onto one main page. It's basically there to display all the branches on one page... then you click on the one you're interested in and then you go to a more detailed page.

Back to the main page. On the top, there's kind of a featured branch that has a bigger picture and bigger title but it's still getting pul pulled from the same table etc etc etc.

In order for me to avoid favortism to one branch (and for other branches to start complaining) I want to ramdomized the order every time someone came to page but I have no idea how.

right now I have a super simple select statement.

Assigning Values With Other Values
Say one has an array like such:

array("lang=english", "nomusic=true", "name=Fred", "menu=false");

Is there a function in which I input the array and it makes all the things into variables with the other things as the content like:

$lang="english";
$nomusic="true";
$name="fred";
$menu="false";


Set Values Once
let say that i want to allow someone (the site admin maybe) to chose
certain configuration values, for instance

* number of products per page
* picture widht
* back color
....

Right now, i just have all those info in a php page, so it can't be
modified
$number of products_per_page = 20;
$picture_widht = 2;
$back_color = #FFFFFF;

I could keep this info in the database, but i should read it every time
a page is rendered... (open connection, query, close conn)

What would be the best way to do what i'm need? Is there any chance to
"read once, keep value for ever" ?

SELECT *
If I have a lot of articles, all with a unique IDs.

First I would like to search for that ID, I could do

SELECT * from ARTICLE where ID = xx

But I also want to display the 5 articles before and after that article.

SELECT * from ARTICLE where ID > xx LIMIT 0, 10
and
SELECT * from ARTICLE where ID < xx LIMIT 0, 10

(I choose a limit of 10 in case the ID is one of the first one or one of the
last one, that way I will always have at least 10 articles).

Is it possible to do the above in one single query?

Should I even bother doing that? does it make the whole operation faster to
do it that way?

Select Box
I have a problem that I'm not quite sure what algorithm will help me on. I'm
bringing in records from MySQL using PHP and need to spit this records into
a select box. Fairly simple, here's my code for the first select box:

<option selected
value="<?=$currentCatID?>"><?=$currentCategoryName?><option>
<?php
while($rowGetCat = mysql_fetch_array($resultGetCat)){
if($rowGetCat['pCatID'] != $currentCatID){
echo "<option
value="".$rowGetCat['pCatID']."">".$rowGetCat['pCatName']."</option>";
}
}
?>
</select>

Problem is - based on their choice with the first select box, I need to
query the DB and populate a second select box. So basically, I need a 2nd
select box that is populated on the fly based on their choice from the first
select box. The only solutions I have found so far use their own form, and
the form I have now has numerous other options and values that I need to
save the state of for editing.

I was thinking AJAX might help, or maybe just regular javascript, but
without having the entire page reload I'm not sure.

Sub Select
I have this line of code:

$result = mysql_query("SELECT jobnumber, projectname, description FROM timesheets WHERE description IN(SELECT distinct jobnumber, projectname FROM timesheets)",$db);

But this returns nothing. What I want it to do is display the 3 fields jobnumber, projectname and description where the jobnumber,projectname combination is unique.

Get A Value From Select Box
I am having difficulties getting the current value of a select box to pass to a function Code:

Select The Id And The Name
I have this code that when the user provide his email address he will participate in a raffle, my problem is that i want to select the id and the name but my selection is not workin Code:

Select From
Is there a way to select from multiple mysql tabels?

Value To Use To Select All
I have done the following query:

$query = sprintf ("SELECT * FROM users WHERE country LIKE '$selCountry'");
$result = mysql_query($query,$link);

I want to obtain the users that are from a certain country but when $selCountry is equal to "All" I want to obtain all of them.
I have tried the query in mysql webpage using '%' and it works but when using this character from the php file it doesn't work.

SELECT *
What would I have to put within the $sort variable to have that request display all rows starting with a number? right now I have to put 1,2,3,4,5,6,7,8,9 seperate. Anyway I can include it all in one variable that would work below?

$q = 'SELECT * '
        . ' FROM `company_details` '
        . ' WHERE `cname` LIKE  '' . $sort . '%''
        . ' ORDER BY `cname` ASC';
$r = mysql_query($q);

SELECT MAX()
$f1 = mysql_query("SELECT MAX(id) FROM topics WHERE fid = '$f'");
$f2 = $f1+1;

now, I can't see any errors...but when I ran my code $f2 should have equalled 4, but somehow it came out with 12? what's wrong with it??

Select Box
I have a select box coded that displays MySQL data as options in the pull down menu. What I need to know is if and how I can make it so that each option has given background. Can I assign a class to each option? The code for my select box looks like this: Code:

<select>
I have a query regarding <select> name:

The script runs through a for loop for each select which gets the qty's from the DB, so the user can only select the maximum thats available in stock. Each select is given a name, which is the record ID from the DB ($wsi_id_arr[$num]). So the first select will be <select name="VB001"> for example.

However, the problem i am having is how do I get at this in another script, for example, so far I have:

for($ordercnt=0;$ordercnt<$num;$ordercnt++)
{
if(...................

Checkbox Values
Basically, I have 2 checkbox's which are printed out for each record within my table. On the next form, each checkbox is tested for being "checked" and the database is updated accordingly.

This is fine. My problem is that I dont want users to be able to select both check-box's at the same time. After talking to "andnaess" on an earlier post and doing some reading, I decided upon using some javascript to do what i wanted.

I have found a script which does exactly what i want, and i am now incorporating it into my original php script.

I am having problems assigning a name and value variable with an array to my checkbox's. Is this possible, or have i got the wrong idea?

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?

Reading Url Values
I am able to pass values to the URL as this shows. I can get the id value and select data from mysql, but I cannot access the ln value. I have use various combos and acannot get it to read the ln value and display it. What am I doing or not doing? I have used get, post and result:

$id=$_GET[id];
$ln=$_POST[ln];
echo $_RESULT[ln]

Echo Certain Values Only
I'm creating a table that has 7 columns. In the first column, I'd like to show My_SQL data. The data contains multiple fields, but there is one that matters most right now.

Right now, I show this data with:

<?php echo $row_UserData['Number'];?>

However, I only want to echo this value if another value of the same row ($row_UserData['Code']) equals a certain number.

How would I write a conditional statement like this?

2 Values In A Loop
In a guestbook the im building, I want to set the <tr> bgcolor in a difrent color each msg (the same effect is also here in these forums).The code is a while loop (to get mysql results). How can I do it ?

Monetary Values
What is the best way to remove all characters except digits from a string? ie: I may have a value: '$4,000.00' but all I want is 4000

Values From A Form
I have a form (search.html) that has 1 textbox and 3 listboxes. When I submit this form to a php file (search_res.php), I am using $HTTP_POST_VARS to get the values which is fine.

But then in my php file(search_res.php) I again have a listbox with 2 options. When I choose either one of these options to display the search results either by "Price" or "Name" I lose the values of the main form (search.html). How can I keep these values from the main form in my search_res.php page?

How Do You Add Values In Rows Together
I am using the following code to take records out of a Mysql database and display them on an HTML form. $myrow[8] is a number. At the bottom of the table, I want to display the sum of all the $myrow[8] values added together. Code:

Return Values
I have an idea about returning variables.

in 1st page, there's variable "x1". it's action page is B.
So, I can use "x1" in B.

$x11 = (int)$_POST['x1'];

B's action page is C

In that case, I want to use "x1" in C.
So, can I save "x1" in B and use it in C?

for exmaple, can I use following commend in C?

$x22 = (int)$_POST['x11'];

Adding Different Values
How can I do If I need to add some values, I am using LEFT Join and I am displaying some lists There is my code: PHP Code:

Selecting MAX Values
I have a SELECT statement where I use numerous GROUP functions, namely: SUM, MAX and COUNT to query and combine various elements of a table. My question lies around the MAX() function. The field which I am querying for the MAX function is a TINYINT field named HS with numbers ranging anywhere from 0 to 375. However, there is a second TINYINT field named NO which is also tied to it.

Basically I would like to add a "*" to the end of the HS field if the NO field is set to 1. If it is set to 0 I would just like it to display the number in the HS field alone. Is it somehow possible to select the NO field of the specific MAX value in the query? If that can be done then I can combine it when writing my php.

Compare Values From CSV.....
I have a CSV file which contains data from the search engines, which includes search engine, keyword, number of applicants and number of visits.

However in some cases there is repitition however I want to merge those figures together.

An example of what I mean....

Array (add More Values To The End)
I have an array. I wan to add more values to the end of the array. how would i go about doing this. my current code does not work. PHP Code:

Getting Values From A File
I have a file with content like:

John|10|5|7
Alec|22|9|31
Mike|23|42|1

And I can retrieve all the values using explode and a loop. But for what I'm wanting to do is be able to get the values for one particular line rather than the entire. So how can I retrieve the values for one particular line?

Get Values From Textfield
as I am new to PHP my question is related to pure basics. I wrote
simple PHP file for automated mail sending. It sends, of course, mail
with fixed text but I need "mail()" function to retrieve string values
from textfield controls in Dreamweaver instead of fixed string values.

Option Values
From my experimentation there seems to be a difference when using values from an option value as apposed to an value by a check box etc. I can quite easily input data from a check box selection, but not an option value. Code:

SSL - No $_POST Values
The problem I had was sending posted data to a SSL secure Apache server and when getting the values using $_POST they were empty.

The cause of the problem can be found here http://bugs.php.net/bug.php?id=18759&edit=1
It seems that having enctype="multipart/form-data" in the form tag was causing the problem.

Matching GET Values...
I am trying to pass each GET variable to a function and check if it was
expected.
For example, here is a sample link:

index.php?name=modname&file=filename&func=1

the problem is, instead of returning:
match
match
match

it returns:

match
no match
no match
no match
match
no match
no match
no match
match

I know the problem is something with the =each, because it is evaluating
each item against each other, I just don't know how to fix it.

function bmcheck ($bmc, $g)
{
$bmchk = 0;
while (list ($key, $val) = each ($bmc)) {
if ($val == $g) {
echo "match";
echo "<br>";
} else {
echo "no match";
echo "<br>";
}
}
}

$bmc = array("name","file","func");
foreach ($_GET as $gvalue => $g) {
bmcheck($bmc, $gvalue);
}

Basically, when I'm done, if something like this was passed:
index.php?name=modname&file=filename&func=1&bad=notsupposedtobehere
then I would see 3 "matches" and 1 "no match" for the "bad" parameter.

Get ASCII Values
is there a php(inbuilt) function to get an ASCII value of a string? if isn't ,please explain how to do it I had wanted to send redirection from a page to another page
in same folder .used below code but didn't work though didn't show any error messages.could someone tell where it went wrong? Code:

PHP Null Values
NULL is converted to blank in php array when i use mysql_fetch_array . I want something where NULL  remains as it is in php array.

Variables Not Getting The Right Values
I have a form that has the ID values of various fields from listboxes, etc.,
which are generated from a db query, assigned to variables. The variables
hold the returned $_POST['fieldvalue'] fine, but I also need variables to
hold the labels. I have tried a few options such as running a secondary
query where the selected form value = the label, i.e.

-sample code-

//set variables:

$tooltype_id = $_POST['toolType'];
$toolcat_id = $_POST['toolCat'];
$primeproj_id = $_POST['project'];

//get group and project code and set variables

$query_groupcode = "SELECT groupCode, projCode from groups, proj WHERE
groups.groupID = proj.groupID AND proj.projID = '$primeproj_id'";
$groupname = $query_groupcode['groupCode'];
$projcode = $row_projects['projCode'];

//get tooltype codes

$query_toolpath = "SELECT toolType FROM toolType WHERE toolTypeID =
'$tooltype_id'";
$tooltype = $query_toolpath['toolType'];
- end code -

I then checked to see the variable values:

-code sample-
echo $tooltype_id.' tooltype_id<br />'
echo $toolcat_id.' toolcat_id<br />'
echo $primeproj_id.' primeproj_id<br />'
echo $groupname.' groupname<br />'
echo $projcode.' projcode<br />'
echo $tooltype.' tooltype<br />'
-end code-

this is the result - the data from the db comes across only as 'S':

2 tooltype_id
3 toolcat_id
5 primeproj_id
S groupname
S projcode
S tooltype

I'm sure this is just a stupid little error that I'm not seeing....or that
there is a reasonable way to collect the label values.

Reading Values From Url
what am I doing wrong? I've got a link like this:

<a href="dispcalendar.php?month=1&year=2007">view the calendar for the rest of the year.</a>then on dispcalendar.php I have: showYear($month, $year);But it doesn't seem to be reading the values sent in the url as I just get a blank page.

Getting Form Values
I have so far been trying to get all selected check boxes on the page, quantity text fields and ordernotes text area to INSERT INTO my database but to no avail. Im using OBDC to add to the confusion.

I've tried to develop my 'product' script into some kind of a form, but now need to find out how to make the data i want variable so that i can send them into my database. Code:

Incrementing Values? $var++
I want to be able to get the highest value from my user_id field in the database and increment it by 1. So highest user id is 104... next user will be 105 etc.

I have the below code but it doesn't seem to be doing. It just puts the value in as 1 all the time. the job.

$query = mysqli_query("SELECT MAX(user_id) `user_id` FROM `phpbb_users`");
$fetch= mysqli_fetch_assoc($mysqli_connect, $query);

$get_val= $fetch['user_id'];
$get_val++;

HTTP_ACCEPT_LANGUAGE Values
I'm trying to pull the language tag out of HTTP_ACCEPT_LANGUAGE in the $_SERVER superglobal, and while I'm certain of most of the regular english encodings, I don't know many of the international ones, is there anywhere I can find a full listing of all the country tags?

In particular I'm looking for Chinese. I've checked the HTTP 1.0 and 1.1 specifications and couldn't find a listing there. I've looked through some PHP references, even though this is in the Headers department.

Hidden Values
Can any one help me in using hidden values with a form that posts to it self

the form has 2 fields one of them is selection from options I want the values of the fields to be there once the form is posted to it self. I have tried to use the following with the form, but it didn't work. Code:


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