By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,821 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

Select if in Array

P: 1
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
Share this Question
Share on Google+
1 Reply


code green
Expert 100+
P: 1,726
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

Post your reply

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