All, Thanks for your help, but this shouldn't be so freaking hard to do. <sigh>
1) I have a multiple select input on one page that is populated with a list of campuses. The user selects which campus(es) to search on. 2) the user submits the form and goes to the next page. 3) I want a list of the selected campus(es) at the top of the page Page 1 **** user sees this **** Select Campus(es) ------------------- Cal State San Bernardino University of Redlands University of California, Riverside Universtiy of California, San Diego ************************* -- code -- <?php session_start();?> <?php if(isset($_POST['Submit'])){ $_SESSION['sv_CampusList']= implode( ', ', $_POST['campus'] ); header("Location: " . "search.php"); exit; } ?> Page 2 <?php session_start();?> <?php require_once('Connections/CCB.php'); ?> <?php $cList = $_SESSION['sv_CampusList']; mysql_select_db($database_CCB, $CCB); $query_GetCampuses = "SELECT * FROM campuses WHERE inst_id IN ($cList) ORDER BY name ASC"; $GetCampuses = mysql_query($query_GetCampuses, $CCB) or die(mysql_error()); $row_GetCampuses = mysql_fetch_assoc($GetCampuses); $totalRows_GetCampuses = mysql_num_rows($GetCampuses); $c = implode( ', ', $row_GetCampuses ); echo $c; ?> <table> <tr><td>Campuses: <?php echo $c; ?></td></tr> ***** user is supposed to see this ***** Campuses: Cal State San Bernardino, University of Redlands I did check the MySQL table and inst_id is an integer. When playing around with the Query in PhpMyAdmin, I found that I needed to surround the values in the IN clause with single quotes. Perhaps I'm going about this the wrong way. Any advice or suggestions would be appreciated. Thanks, James -----Original Message----- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2003 1:12 PM To: James Johnson; 'Chris Boget'; [EMAIL PROTECTED] Subject: Re: [PHP] Array to List From: "James Johnson" <[EMAIL PROTECTED]> > Actually, I'm using $campusList for a SQL statement: > > SELECT name FROM campuses WHERE inst_id IN ('$campusList'); > > It wasn't working until I found out that $campusList needs to look > like '1','2','3'. > > $campusList = implode( ', ', $_POST['campus'] ); > > Returns 4,2,3 (whatever was selected) > > I've looked in the manual on implode, but don't see how to surround > each value with single quotes. Is there another function that will do > this? You don't need the quotes if the values are integers, but if you insist... $campusList = "'" . implode("','",$_POST['campus']) . "'"; The implode "pattern" is a single quote, comma, single quote, then surround the whole implode result by single quotes to complete it. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php