473,326 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Select if in Array

I have a query that works fine with single state selections but I need to be able to query based on multiple state selections in a multiple select list and populate the second textarea on the same page with the according emails. The states are chosen and the joined emails should be returned.

The query I currently have is:

"SELECT DISTINCT email, email2, email3 FROM customers LEFT JOIN email_cust ON email_cust.email_ID = customers.customer_ID LEFT JOIN state_cust ON state_cust.state_ID = customers.customer_ID WHERE state IN ('" . implode(",", $state) . "')"

The first list is of states:

<select name="state[]" size="5" multiple="multiple" id="state">
<?php
do {
?>
<option value="<?php echo $recordset2['state']?>"><?php echo $recordset2['state']?></option>
<?php
} while ($recordset2 = mysql_fetch_assoc($recordset2));
$rows = mysql_num_rows($recordset2);
if($rows > 0) {
mysql_data_seek($recordset2, 0);
$recordset2 = mysql_fetch_assoc($recordset2);
}
?>
</select>

and the second list is of nothing until a selection is made in the state list and submitted:

<textarea name="email" cols="40" rows="40" id="email" type="text"><?php do { ?><?php if ($row_Recordset1['email'] != '') { echo $row_Recordset1['email'].";\n"; } else { echo ""; } ?>
<?php if ($row_Recordset1['email2'] != '') { echo $row_Recordset1['email2'].";\n"; } else { echo ""; } ?>
<?php if ($row_Recordset1['email3'] != '') { echo $row_Recordset1['email3'].";\n"; } else { echo ""; } ?>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</textarea>

Error: Warning: implode() [function.implode] Bad arguments

Not sure where Im going wrong here.
Dec 18 '07 #1
1 1996
code green
1,726 Expert 1GB
If you echo your first query out you will see where you are going wrong.
As you haven't bothered to use code tags it hurts too much to study the query.
Dec 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: point | last post by:
Hello there... I'm a PHP programmer and starting to learn JS... I have a following problem.... I have 3 select boxes! one is hotel one is destination and one is country... if someone...
3
by: Stewart | last post by:
Dear comp.lang.javascript, I have more than once wanted to manipulate the contents of select boxes dynamically, whilst the boxes contain <optgroup> tags. Manipulation of a select box containing...
1
by: supline | last post by:
I have a function that creates a select list: function make_select_ns($name,$array,$persist){ $string = "<select name=\"$name\">"; $string .="<option selected>" . ucfirst($name) . "</option>\n";...
2
by: BrianP | last post by:
Hi, I have had to invent a work-around to get past what looks like a JavaScript bug, the malfunctioning Perl-like JavaScript array functions including SPLICE() and UNSHIFT(). I have boiled it...
4
by: Matt Ratliff | last post by:
Hello, I would appreciate any assistance you have with the following problem: I have (as an example) an array of values as follows: arrayvalues=new Array("0001","0003","0005") where each is the...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
6
by: cathyisfrustrated | last post by:
Hey, I've been trying to learn javascript for a few days. I'm a bit stuck! I'd appreciate any links to get me going in the right direction or any advice I can get. I've written a...
25
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. ...
4
tjc0ol
by: tjc0ol | last post by:
Hi guys, I'm a newbie in php and I got error in my index.php which is: 1054 - Unknown column 'p.products_id' in 'on clause' select p.products_image, pd.products_name, p.products_id,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.