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






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Select List With A Loop


I want to accomplish a function that creates a select list with a loop of results from the DB, I have that, it is: PHP Code:




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
Loop Through A List
I want to loop through a list and display it in a table with three columns per row, yet haven't had much luck in doing so. I was thinking if would be something like so Quote:

for ($x = 0; $x < mysql_num_rows($query); $x++) {
if ($x / 3) { ?>
<tr> <? } ?><td> Blah </td></tr></table>

Well, that's as much as I know so far.

View Replies !   View Related
Generate List Of Months Using While Loop
I want to generate a list of month names, using a while loop. I basically need a way to fetch the month name from the number i.e. how do i turn &#396;' into "June"? I dont mind if it's just a 3 letter abbreviation i.e. "Jun", but I would prefer the whole name.

Here's my code so far. It obviously returns "January" for every loop at the moment:

echo '<select name="month">'
while ($m <= 12) {

echo '<option value="'.$m.'">January'

$m = $m+1;
}
echo "</select>";

View Replies !   View Related
Select/Loop Troubleshoot
I've tried searching... read through my SAMS book a few times and my eyes are beginning to hurt. I'm trying to have this dropbox pre-populate from my database.

View Replies !   View Related
Select Query / Loop
My users are organised in a table named 'users'. Each user is a member of a department, but some users are members of more than one department, so I have another table named 'user_department'. I have another table named 'submissions' int which users submissions are stored. Right now I am developing an archive of submissions. Generally speaking a simple query will do the job like this:

$query = "SELECT * FROM submissions WHERE status != 'Pending' AND sid = '$username' ORDER BY id desc LIMIT $from, $max_results";
$result = mysql_query($query);

The problem comes when I try to select only the submissions lodged by the users department. The point being that the department head can view all submissions lodged by his department. If the department head is only head of a single department, this would work:

$query = "SELECT * FROM submissions WHERE status != 'Pending' AND department = '$users_department' ORDER BY id desc LIMIT $from, $max_results";
$result = mysql_query($query);

But if the department head is head of more than one department, I start to get lost! I can loop through the 'user_department' table to find out which departments the user is the head of like this: Code:

View Replies !   View Related
Select List
I'm creating a form that has three select lists. The first one has two values EMAIL and SMS. What I want to do is have the two other select lists (named EMAIL and SMS) work so that if EMAIL is selected only e-mail select list can be altered and vice versa with the SMS.

How can I do this? I know to use disabled in <select> -tag, but how can I check the what the value is (and the value changes) and then act acording to it?

View Replies !   View Related
2 Select Box Filled Dynamically With Do While Loop
I have two select boxes on the same page both filled dynamically and am using a do / while loop to put the information in. The first one works fine, but the second one is blank. I can't figure out why the second box shows nothing if it works on the first one. Code:

View Replies !   View Related
List Box Multiple Select
I am trying to create a drop down list that permits a person to select multiple items from the list and have the results posted on a results page. I am using Dreamerweaver MX, PHP and a MYSQL database. I was able to select multiple items but only the last selected item would be displayed. I tried to modify the list box code and now it returns nothing. Code:

View Replies !   View Related
AJAX Select List
I've been looking for an Ajax example wherein a dropdown list is populated based on a previous selection. I.e. Select List 1 - "Choose Country" - based on this selection Select List 2 would populate with Cities in that country. Found a way to do it using multiple txt files which hold the Select List 2 options, but I would prefer to use PHP MySql to populate both lists.

View Replies !   View Related
Multi-select List
I have a multi-select listbox created (and processed via PHP). As such I named it with braces in the name, like:

<select name="multilist[]" size=10 multiple>

However, I can't get javascript to reference the listbox when I name it that way (I need the javascript to dynamically insert/delete items from the list). I had originally named the list "multilist" without the braces and the javascript worked fine, and it let me multi-select, but php would only see the last item selected.

Based on hints I read elsewhere, to enable php to process the multi-selections into an array, I renamed the list with the braces [] but now the javascript simply does not work -- it will not insert data into the list. Is their any trick to the control naming I need to know?

View Replies !   View Related
Multiple Select List Box
I have a task where I have to fetch datas from mysql and display it in the multiple select list box. I have fetched the datas and it is getting diplayed correctly in the multiple select box. I have used some thing like this.

print "<select MULTIPLE SIZE=&#396;' name='db_test[]'>";
while($row = mysql_fetch_object($handle))
{

if($num 0) /*num is number of rows*/
{
print "<option value='$row->db_name'name='$row->db_name'>".$row

View Replies !   View Related
Multiple Select List
I have a form that inserts it's values into a table in a mysql database.. i also use another form to edit the contents of that table...

My problem is that i have a multipe select list ... i imploded it's values into the table like this:

$employees = implode(',',$_POST['emp_name']);

that worked fine ... but i can't figure out how to make the same values selected on my edit form's list?

View Replies !   View Related
Getting To Match & Select From List?
I have a list of values, where $list = ___, then $email = ____. I'm carrying over $list from the previous page as a hidden element of the form, and I want the php code to match the value of $list and replace it with the value of a corresponding $email. Code:

View Replies !   View Related
Dynamic Select List
I am wanting a dynamic select list which is populated from my DB. My query is:

  $query = "SELECT pk, type FROM un_styles";

I want to display the type in the select list, then use the selected type. So what i am basically asking is could someone show me the code to do this please.

View Replies !   View Related
Select List From A Database
I'm trying to dynamically generate a html select list from a MS Access database using the code below:

<?php
$conn=odbc_connect('customer','','')or die('Could Not Connect to ODBC
Database!');

$queryexe="SELECT * FROM types";

$rs=odbc_exec($conn , $queryexe)or die("Query failed: $sql<br />Error:
".mysql_error()."<br />");

echo "<SELECT name="typeId">";
while(odbc_fetch_row($rs))
{
echo "<option>".odbc_result($rs,"typeId")."</option>";
}
echo "</SELECT>";
?>

View Replies !   View Related
Need 200+ SELECT Statements Inside A Foreach Loop
I have to query 4 tables in order to get the final result. But using left join to query all the tables together is just too slow.

If I perform the queries seperately, I will need 200+ SELECT statements inside a foreach loop. Both approaches take about 10 seconds and 5 seconds respectively. Is there anyway to optimize the SQL query?

View Replies !   View Related
Loop To Select And Update Records Using Classes
I am using a group of classes to manipulate MySQL tables. I would like to be able to go through a table one line at a time to convert fields from all upper case to word upper case.

The problem I have, I think anyway, is that my result set from the first query is abandoned by the second query. I am wondering if there is an easy way around this? Code:

View Replies !   View Related
Select List/Menu Using PHP And MYSQL
Here is my code:

<select name="country" class="sidelinks">
<?php
do
{
?>
<option value="<?php echo $row_AllCountries['country_ID']." ";?>"<?php if ($row_AllCountries['country_ID'] = $acountry) { echo "selected"; }?> >
<?php echo $row_AllCountries['countryname'];?></option>
<?php
}
while ($row_AllCountries = mysql_fetch_assoc($AllCountries));
?>
</select>

A few words to describe:
-$row_AllCountries['country_ID'](get from MySQL) is a unique country ID number
-$row_AllCountries['countryname'](get from MySQL) is the name of the country
-$acountry is the country ID number that i want to be selected when the form loads

I have all the values and country names named OK...the only problem is that when the form loads it selects the last country.

View Replies !   View Related
List Data From A Select Statement
I have a page where I am trying to list data from a select statement. However, I am only getting one record from this SQL statement in a PHP script, but over 3200 records with the same statement in phpMyAdmin. Am I doing something wrong? PHP Code:

View Replies !   View Related
How Do You Select Developers From Members List
The member list at PHP Builder is quite large and lists some 2500+ coders in USA. How can we identify:

1. experienced php/mysql web developers - 2+years
2. good client relationship history - ratings or referrals
3. preferably located in or near Houston, TX
4. Preferably experiened with osCommerce backend development

View Replies !   View Related
How To Process Multi-select List
I'm not sure if my post should go here, but since I am using PHP, I figured I'd start here.

I have a table of choices that a user can select from, and can select as many as they want (it is for searching). I originally had a dummy list with checkboxes set up, and of course the name="name[]" was an array to capture each ID checked off, so I could easily use 'foreach'.

However, when the list was finalized, it has over 100 choices. Even half that would be too much for checkboxes. My two questions are:

1) Is there an alternative to a multi-select list, which is not that intuitive to use nor easily accessible?

2) How do I set it up so I can capture the values? I can't seem to find this answer anywhere. Is it because multi-select lists are to be avoided?

View Replies !   View Related
Keeping Select List Persistent
I grab data from an Oracle database and create a select list as follows:

while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) {
   print '<option value="'.$row[0].'">'.$row[1].'</option>'       
  }

The problem I have is that my error handling functions send the user back to the same form if there is a data entry problem. When this happens, I get an error that the login information (that I use to build the select list) is incorrect; basically because it is gone.

Rather than going back to the database each time the user is sent back to the form for a data entry error, is there a way to make this list persistent.

View Replies !   View Related
Select List - Edit Form
For a couple of days I have been trying to make an edit form that remembers the initial values a user entered. The edit.php page has a few textboxes and a few dropdown/select boxes. The textbox part works fine and comes from a database. Code:

View Replies !   View Related
Multi-select List Boxes
I'm trying to allow the user to make multiple selections in a date list box. The list box displays the numeric days in the month. The offical scooty I can find on this is to do something like:

$theDays = $_POST['lboxDay'];
// get the data from the list box named "lboxDay" on the previous form.

$expDays = explode (",", $theDays);

This explodes the post data into an array of all the days selected in the list box, which are supposed to be delimited with a comma (the HTML standard). So, I should then be able to see those days with something like :

echo "<br />Day 0 = $expDays[0]";
echo "<br />Day 1 = $expDays[1]";
echo "<br />Day 2 = $expDays[2]";
.
.
.

View Replies !   View Related
Displaying A List Of Categories From A Database In A Select Box
Could someone please tell me why this outputs nothing

<select name=categories>
<?
$cat_array = get_categories();
foreach($cat_array as $this_cat)
{
echo "<option value="";
echo $this_cat["category_id"];
echo """;
echo ">";
echo $this_cat["category_name"];
echo "
";
}
?>
</select>

==========================================================

function get_categories()
{
//get the list of categories from the database

$conn = mysql_pconnect("localhost", "user", "pwd");
$query = "select * from categories";
$result = mysql_query($query);
if(!$result)
return false;

$num_cats = mysql_num_rows($result);
if($num_cats == 0)
return false;

$result = db_result_to_array($result);
return $result;
}

//A function that returns a query to the database as an array
function db_result_to_array($result)
{
$res_array = array();
for($count=0; $row=@mysql_fetch_array($result); $count++)
$res_array[$count] = $row;

return $res_array;
}

View Replies !   View Related
Trying To Select Names From A Drop Down List And Display Them
So, I already have the code written where I have a drop down menu with names in it. I want to be able to select multiple names from the drop down list and have them display in a table below the drop down menu. First off, I can't get one name to display, not to mention multiples. :p How may I accomplish this?

CODE:

View Replies !   View Related
How To Response Immediately When I Select The Drop-box List
Do you have any idea when I try to select a drop box list, the data
will show up in the following textbox immediately?

eg.

Name:
---------------
drop-box list | <- when i select one of them
---------------

Age:
---------------
Textfield 1 | <- pop up immediately
---------------

Address:
---------------
Textfield 2 |
---------------

View Replies !   View Related
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.

View Replies !   View Related
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:

View Replies !   View Related
Using Multiple Values From Dynamic Select List
I have a selection list which is dynamically populated from a SQL query. When the user makes their selection, the result is passed to the next page. Code:

View Replies !   View Related
Add A List Box To A Form So That Users Can Select A Category.
i want to add a list box to a form so that users can select a category. The categories are held in a database with two fields, catid, and category.

How can i populate the list so users select the category name, but when it enters the choice it enters the catid...?

View Replies !   View Related
Multiple Select List > Search Problems
I`m building a search form which has a multiple select list, but I can`t figure out how to search for the items in the array that the list creates. Code:

View Replies !   View Related
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?

View Replies !   View Related
How I Do A Simple Match To Extract What Is Between The Quotes On A Select List
how I do a simple match to extract what is between the quotes on a select list: <option value="bla">Bla Bla</option>

I want to extract all occurrences of what is between the quotes.

View Replies !   View Related
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.

View Replies !   View Related
Dealing With List (multiple Select) Submissions From A Form
If I have this in a form, how can I deal with the $_POST result if multiple items in the list are selected? I've been searching the net for such answers, but I think I'm searching for the wrong things as I can't seem to find what I'm looking for.

From what I've tried just, only the last selected item in the list goes through on $_POST

I basically want a list of items, which would have a certain operation done on them if selected on the following page.. but need to get ALL of the selected items first! Code:

View Replies !   View Related
Use A SELECT Statement, Mysql_fetch_row() And A Foreach Loop To Cycle Through All The Rows In A Table
I believe you can use a SELECT statement, mysql_fetch_row() and a foreach loop to cycle through all the rows in a table and extract information, but I have not been able to make this happen. Code:

View Replies !   View Related
Select From Drop List To Fill Table Column With Text -- HOW ?
I want viewers to compare state laws on a single subject.

Imagine a three-column table with a drop-down box on the top. A viewer
selects a state from the list, and that state's text fills the column below.
The viewer can select states from the drop down lists above the other two
columns as well. If the viewer selects only one, only one column fills. If
the viewer selects two states, two columns fill. Etc.

I could, if appropriate, have a separate htm page with the text for each
state -- california.htm for example. When the viewer selects California from
the drop down list, the column below would "fill" with California.htm.

Or, I could conceivably use a text or mysql database with two fields for
each record: state_name and law_text -- but it would probably be easier to
use separate htm files, since there will only be about 20 states involved,
and the "database" would never have a large number of records.

The table width would be 100% and each cell would be @33%

My site is designed with FP 2002 and runs on Apache/FreeBSD. I have just had
Apache-ASP installed but I have not yet configured or used the module.

View Replies !   View Related
REGEXP To See If User Enter Any Word Matching Keyword List By Select
Say I have a list of 3 key words: 'mi go home'. Then user enters into a search such as
'm go home' that I will assemble them into a regexp such as [(m)(go)(home)]

I would like to REGEXP in mysql to see if user enter any word matching keyword list by select ... searchwordField REGEXP '[(m)(go)(home)]' 'go' and 'home' match, but 'm' should not 'mi', but it did. How to use REGEXP correctly?

View Replies !   View Related
Chain Menu But The Menu Should Be Multiple Select Menu/list
I am looking for codes to be able to do the same thing with multiple select menu/list.

PHP codes or javascripts codes are both fine.

1) javascript + php approach: Prefer to be javascripts codes to display the chain menu. I can use the php to get the all three levels menu data from the database, and assign these values to the javascript.

2) php codes only: Or use the pure php codes (the problem is if just using php codes then I have to submit the form to the server every time, when top level menu select changes to create new menu.).

View Replies !   View Related
If Loop In A While Loop Producing Incorrect Results
I have this code that checks to see what the value of "del" is and places a certain word depending on if its a 0 or 1. PHP Code:

View Replies !   View Related
Creating Table Rows For Ever Other Loop In A WHILE Loop
I'm trying to create a table using a MySQL fetch array while loop that would look like this:

CONTENT1     CONTENT2
CONTENT3     CONTENT4
CONTENT5     CONTENT6

I need a <TR></TR> for every other piece of content. But I don't know how to do this with a loop that uses a MySQL fetch array

while($row = mysql_fetch_array($result, MYSQL_ASSOC))

{
PHP CODE THAT IS LOOPED;};

I'm trying to remember from my old college Java class that we did something with loops for whenever the counter variable was even the loop would do something special... I don't know if this is possible with a while+mysql_fetch_array loop though.

View Replies !   View Related
While Loop In A Foreach Loop.... Semi-results!
I am echoing a mysql database result which is stored in the database as such "Superman, Batman, Wonder Woman, etc".

I am using the explode to split the into an array using the comma as the delimiter. Then I am trying to get it so if I click on Superman I am taken to the Superman profile page... Batman I go to the Batman profile page. Code:

View Replies !   View Related
List Contents Of A Folder, Make List Of Links
Does anyone know how I can write a script that:

- reads in all the files in a particular directory
- displays the file names in a html list and makes a link of them:
<ul>
<li><a href="filelocation1">filename 1</li>
<li><a href="filelocation2">filename 1</li>
<li><a href="filelocation3">filename 1</li>
</ul>

etc.?

So basically it creates a list of links with the contents in that directory,
so you can download them from there.

View Replies !   View Related
Get List Of Messages From One Table, Message List Indicator From
I have two tables. One has a list of messages left by users using fields named mbxno for the mailbox and msgno for the message number. I have another table that has mailbox settings for each user that contains a field named "messagelist" to indicate if they want to be included on the message list or not.

What I'm trying to create is a list of the most-recent messages with a lookup on the users table to indicate whether a message in the list should be included in the message list based on the user's mailbox settings.

SELECT messages.msgno, messages.mbxno, users.messagelist FROM messages, users WHERE (users.messagelist = &#391;') ORDER BY msgno DESC LIMIT 100

What I'm getting, though is a list that looks like this:

mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 1114 msgno: 0412141623 msglist: 1

I think what's happening is that I'm using the wrong type of join and more rows are being created than necessary.

If I add "DISTINCT" to the query, I get a list of the most-recent messages as I expect, but the "messsagelist" value is sometimes wrong (again, probably because the data is getting jumbled). For example, the messagelist value for the second row (2214) should be 0, not 1.

mbxno: 1114 msgno: 0412141623 msglist: 1
mbxno: 2214 msgno: 0412141622 msglist: 1
mbxno: 2189 msgno: 0412141408 msglist: 1
mbxno: 0000 msgno: 0412141213 msglist: 1
mbxno: 0003 msgno: 0412141213 msglist: 1
mbxno: 2265 msgno: 0412132029 msglist: 1
mbxno: 0000 msgno: 0412131950 msglist: 1

How should I be doing this? If nothing else, what kind of join will work with a long list compared to a value from a short list?

View Replies !   View Related
Produce A List Of Tables Currently Within My Database And List Them In A Drop Down Box.
I need to produce a list of tables currently within my database and list them in a drop down box.

View Replies !   View Related
Populating A List Box Or A Dropdown List Using Php And Odbc
I need to populate a list box and/or a dropdown list on a form. I have all
the bits and pieces together, all bar the code which takes the result of a
query and creates a list box.

View Replies !   View Related
Mailing List Manager, Send To List
I'm looking for a mailing list script (php) that has a function to let
users to reach out to all recipient on the list by simple send the
email to a specific maillist- address.

Mailman has this functionn but as a just got a webserver account I
can't use mailman nor install it.

View Replies !   View Related
Creating A For Loop Inside Another For Loop.
I'm trying to write a script that will display questions that are in one flat file and answers from another flat file. In addition, there are copies of these files with their own data in multiple folders.

I created a for loop to work with an array of the different file paths to the different folders. Then I created a for loop inside of that one to display the questions and answers files that is in each folder. All I get when I run the script is the first folder and it's questions and then it stops there. PHP Code:

View Replies !   View Related
Get A Varable To Loop Out Side The Loop
i need to get the varable to loop out side the loop but the condition set within the loop so the varable loop's outside. Code:

View Replies !   View Related
Loop Running Inside A Loop
Having a problem with the following; PHP Code:

$last_id = mysql_insert_id();
    
$type_count = count($types);
    
for ($i=0; $i < $type_count; $i++) {
        
$match = "";

if ($types[$i] == $featured[$i]) {
    $match = "y";
    }
                    
    $q_add_types = "INSERT into company_ins (Id, company_id, ins_id, type_featured) VALUES ('', '$last_id', '$types [$i]', '$match')";
        mysql_query($q_add_types) or die(mysql_error());
}

The INSERT query does not run when I insert the inner parenthesis. Does anybody know why?

View Replies !   View Related
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.

View Replies !   View Related
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:

View Replies !   View Related

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