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




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).




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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.

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:

Auto-populating Multiple Boxes... Php And Pg_fetch_array Problem?
There is a nice tool using jquery/php to populate multiple select boxes out
there, it must be a very stupid question but I?m trying to apply this tool to get data from postgreSQL, but I always get an empty [] value. It means that the...

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.

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]);
}
}
}

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>";.......

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'];

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>";
}

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 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:

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.

Populating A Select Box
What I want to do for members of my website is to allow them to click a button that will add their name to a list that populates a select box.  I can do this on my own, but I was curious if I have to use a database in order for this to be possible. 

PHP + MYSQL, Populating Drop Down Box
I am looking to generate a dropdown box from MYSQL data:

db name = h2, table = Working, Column = Home.

Populating Dropdown List
I am wanting to know how to populate the <SELECT> dropdown menu with all existing values from the DB and also have the value associated with that id selected. This is an updating area of my admin. Any ideas? Here's the code so far. At the moment it only retrieves the value assigned to that id. PHP Code:

Populating A Drop Down Menu
How would I go about populating a Drop Down menu from data in MySQL? If you can show me wither a URL to learn this, or if you feel like telling me here, that would be great.

Dymanic Populating Checkboxes
i like to retrieve a value from DB,
accordingly i like to display the checkbox, either checked or not.

Now im able to retrieve the value from DB, i can show even show the
checkbox, but i cant make it checked????

the Code i used to display as follows,

#Require the database class
require_once('../dbinfoinc.php');

#Get an array containing the resulting
record
$query = "SELECT * FROM event";
$result = mysql_query($query);

$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {
if(($i % 2) == 0) { $c =
'"TableDetail"' }
else { $c = '"TableDetail2"' }

$event_id=mysql_result($result,$i,"event_id");

$event_name=mysql_result($result,$i,"event_name");

$event_publish=mysql_result($result,$i,"publish");
// if(($event_publish) == 0) {
$event_publish = 'No' }
// else { $event_publish = 'YES'
}
$take_action = 'Delete'
echo "<tr>
<td Class='navText'
align='center' class=$c>$event_id</td>
<td class='navText'
class=$c>$event_name</td>
<td class='navText'
align='center' class=$c><input type='checkbox'
name='publish' if($event_publish==1){'CHECKED'}?></td>
<td class='navText'
align='center' class=$c><a
href='delete_event.php?event_id=$event_id'>$take_action</a></td></tr>";

$i++;
}
?>

Re-populating A Form If Errors
I am learning php. I have created a simple Web page with a form.
After receing the POST request, I do some error checking. In case of
errors, I would like to re-post the page, but with the current values
for each field.

I have organized my files like this:
1) Webpage with the form (all in html, form action points to a php
file)
2) php file that receives the request.

Populating Form Text Box.
I have a PHP form for entering data on-line into a mySQL
table..
Because of the intended search facility, I require one field in the form
to be completed with exact and precise item names and spelling.
In testing, I had achieved this with look-up tables.
Ideally I would like the selected item from one of five drop-down lists
to autopopulate the form text field when selected.
Alternatively at least the option of copy and paste.
Copy and paste - for some reason will not work.
Autofill worked fine on a test form with no database connection
and in standard HTML and javascript, however, once the PHP
is added to the page neither method works.
Could anyone please point me in the direction of how to get the
autofill to work?

Populating A Select Box From A Database
I have a subscription database that allows you to edit a subscribers data. For example, you enter a search term like "Bob" and it returns a list of everyone named Bob. You click the one you want and it goes to a subscriber detail page, where all of his data is populated to a form. You can directly edit this form and click save to overwrite it.

The only issue is the select boxes (drop downs) - say I have four options in the drop down box, red, blue, green and black. On my details page for bob I end up with five, I have those four PLUS whatever was saved for his color, so it shows up twice. If Bob is green, my select box looks like:

Green
Red
Blue
Green
Black

How can I make it so that Green only shows up once?

Populating Drop Down And Table
I have a database with the following fields.
Name | Company | Date

values in each column could be repeated, or not. as in there could be several same names with the same company with different dates, or different names with same company.

How do I populate a table with this info and have drop down boxes, so that I can narrow down the search? For example:
Name | Company | Date
12     | 1           | 1929
13     | 1           | 1929
14     | 1           | 1929
12     | 2           | 1929
12     | 4           | 1929
13     | 1           | 1941
12     | 6           | 1929

So if in the drop down I select '12' under name, only those entries with 12 are shown, and then I can further sort it by selecting only '1' under Company.
Hope I'm clear, I manage to complicate things when I post them.

Populating An Auto_increament Attribute
I have just designed a BD. there are companies with auto increament which are integer. When I try to populate it after i tool value from another form and try to insert it into a table i recieve an error! I don't ask the companyID value from user as it is auto increament. Don't tell me to put NULL for that entry as it didn't work as well! Code:

Populating Table Information
I am trying to dynamically generate bgcolors with to help populate some information for a site. Here is the code:

Auto Populating A Drop Down Box
Basically I'm setting up a website which needs an populated drop down box made up from all fields in a specific column of a table in a mysql db....

Here's the code I've made up using various tutorials....

<?php 
$user = "";  
$host = "" 
$password = "" 
$dbName =  "" 

/* make connection to database */  
mysql_connect($host, $user, $password) OR DIE( "Unable to connect 
to database"); 
mysql_select_db($dbName); //did you forget this line? 

$sql = "SELECT model FROM usedVehicles"; 
$query = mysql_query($sql) or die(mysql_error() . "<br>$sql"); //use the or die(...) part ONLY IN DEVELOPMENT 
?>

<form action="action" method="post"> 
<select name="option"> 

<?php  
while ($row = mysql_fetch_array($result)) {  
    echo "<option value="" . $row['model'] . "">" . $row['model'] . "</option>
";  
}  
?> 
</select> 
<input type="submit"> 
</form>

I've left out the connection details for obvious reasons... When I upload and try to test this, jus a blank drop down appears... there are definately fields in the column as I have tried the query on phpMyAdmin.

Populating Fresh Data
Im building a live web chat using php, mysql, javascript, ajax I am fine with sending and retreiving data in real time using ajax as the transfer protocol However, my problem, which is becoming a nightmare, is how to I display it !! Lets say the below is the chat screen,

<div id="messages">
Jamie - Hello
Peter = Hi
Jamie = Nice Day
Peter = I know
</div>

Lets say Jamie's next message is "What are you doing today". I can send that off to the database no problem and I can get peters live chat to pull that message in, however, how do I get it to display underneath Peter = I know

As a practice I was using

document.getelementbyid('messages').innerHTML = document.getelementbyid('messages').innerHTML + "<BR>What are you doing today"

That works, but, lets just say the chat gets to 1000 lines, for each new message those 1000 lines have to be pulled out via javascript, a new line written to it and then printed back in the div

Im not sure but I'd take a good guess at this not being optimal and will cause CPU load on the users machine

What is the best way to do this! Chat messages are deleted after 1 minute, but that doesnt matter because by then they have already been sent the the users chat. Just incase you are thinking of completely repopulating there chat with every message they have sent since the chat started..

Check Boxes
I have a very little problem with check boxes. How can I write a simple PHP code to tell me when a check box has been checked, and then use the name of the checkbox in a function.

Reading POP Boxes
I've been looking round for something that will read the contents of a pop
box and populate a MySQL table.

The e-mails will all be of a fixed format and include a jpeg as an
attachment. I need to put the following columns in:

sender
subject
body
filename (possibly appended to the date to mitigate the risk of
The script would also need to save the attachment to a predetermined folder.

Does anyone know of anything that would do this? Alternatively, how much
would it cost for someone to get this working for me?

Alert Boxes
do u know the alert box in javascript?

when u write alert("somthing");

well i need that in php what is the alternative function for that in php?

Reading Directories, Populating Select Box
Can anybody tell me how to read through a directory, get the file names and populate a select box(pulldown menu) with these names? I know how to loop through a directory using something like this:

while ($files = readdir($handle)) {

$ext=substr($file,-4);

if ($files != "." && $files != ".." && $ext == ".php") {

do some wild and crazy stuff here;

}

}

It's the populating the select box (pulldown menu) while doing this that I need the help on.

Populating Form Item From SQL Enum Set Rev#2
$sql = "SHOW COLUMNS FROM table LIKE 'subject' ";
$qry = mysql_query($sql) or die("Query not valid: " . mysql_error());
$res = mysql_fetch_object($qry);
// This returns a row with a field 'Type' containing 'enum(...)'

$res->Type = str_replace('enum('', '', $res->Type);
$res->Type = str_replace('')', '', $res->Type);
//now the string is something like this: one','two','three

$temp = explode('','',$res->Type);
//temp is an array with as much elements as the enum

while ($temp)
print array_pop($temp);


This way is much more easier using the elements since they are elements
of an array. Cleaver isn't it?

Populating Array With Mysql Results
I'm returning a result set of one field in a table, and want to populate an array with the results. I can't for the life of me figure out a simple way to do this without using mysql_fetch_array() to cycle through the results, append that to a var, then explode that into a var and pass that. PHP Code:

Populating A Form Wth Database Info
I've coded a piece of code which populates a form with data read from the database:

$connection=mysql_connec ("localhost", "f2821842", "f2821842");
$result=mysql_select_db("QUERIES");
$query=mysql_query("Select * from Emp_Details where emp_num = '$employnum'");
while($row=mysql_fetch_array($query))
{$empname=$row['emp_name'];}

<form name="webregform" action="webadmin2.php" method="post">
<input name="requiredname" type="text" size="30" value="<?php echo "$empname"; ?>">
</form>

When I echo the $requiredname, I get spaces and no data, and I know that $empname is not a space-it does read a value in a database. 1. How can I get $requiredname to print a value?

Populating Dynamically Generated TextFields
If one assigns something to the value iattribute off an input /text field, that value will be displayed when the form is loaded. My problem is, when building a form dynamically, the only way I can get the text to show is by doing the above, however, as this is an update form, when the form POSTS to processUpdate.php,
both the data entered by the user AND the data in the value attribute are inserted/updated.

So, how does one dynamically build a form where the data is displayed in the text fields but value atttribute is not set. PHP Code:

Populating A Drop Down List With The Year
i'm trying to loop the years from 1960 - 2010 with the function get_year() below:
PHP Code:

Populating Form Fields With Variables
The script itself works fine: mail gets sent. If there are any missing fields the form displays again with a list of the missing fields, but I can't get the form fields of the reloaded form to be populated with teh existing values. PHP Code:

Populating DHTML Menu From MySQL
I have a client that would like to have drop down menus added to a nav
bar that is generated from MySQL. Is it possible to have a dynamically
driven DHTML menu from MySQL?

Populating Arrays From MySQL Query
I have the following code: http://pastebin.com/746601

The field 'material' in 'is_material' contains multiple values for each
record in 'is_details'. Because of this I have used
'is_material_lookup' as a reference lookup table containing the
'style_code' and 'material_code' which refer to their full details in
the respective tables.

Currently I have got the script outputting all the details and one
material then in the next block of data, repeating the details with a
different material. What I would like to achieve is having 1 block of
data with a list of all materials in that, instead of the repeat, but
sadly I can't know exactly how to do it.

Populating Dropdown With Mysql Entries
I would like to create a combobox in Flash which is populated with mysql data and programmed with php. For example: There are 3 entries in database .ie. apple, bannana, peach. Now these I want in combobox in Flash MX/flash5.

Populating A Drop Box With Results From Database
I have a MySQL database with a table (category) with two fields, catId (int) and category (char(50)). What I want to do is to get all category names in this database and place all of them into a dropdown box on a web page so that the user can choose from the list of available categories.

Populating Table With Text File
My web hosting service uses phpMyAdmin and at the bottom of the screen
iis an area where I can upload a text file to populate a table.

I have a table named groups with two fields:
groups_idauto-increment primary
groups_name

So how do I create my text file to populate this table?

I'm going to use MS Notepad.

If it's set to auto-increment, do I need to include the number? If
so, does it start at 0 (zero)?

Would the file look like:

0,students
1,faculty
2, staff

or just

students
faculty
staff




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