Ok I have this form that has a few multiple selects on it. Those array's are to pass to another page that displays information. What I am trying to do is use the information from the array's to help build an sql script. Basically I want to take the elements of the array and put it into a single variable. (code to follow) It works as far as the "IDEA" goes, but i keep getting [variable]'array' instead of [variable]'elements of array'.
Here is the form code.
<form action="rpt600a.php" method="post">
<? echo("<input type=hidden name=prevmenu value='$prevmenu'>"); ?>
<table align='center' width="800">
<tr>
<td width=50% align="right">Start Date:</td>
<td width=50%><input type="text" name="startdate" size="10" maxlength="10" onFocus="javascript:vDateType='1'" onKeyUp="DateFormat(this,this.value,event,false,'1')" onBlur="DateFormat(this,this.value,event,true,'1')"></td>
</tr>
<tr>
<td width=50% align="right">Stop Date:</td>
<td width=50%><input type="text" name="stopdate" size="10" maxlength="10" onFocus="javascript:vDateType='1'" onKeyUp="DateFormat(this,this.value,event,false,'1')" onBlur="DateFormat(this,this.value,event,true,'1')"></td>
</tr>
<tr>
<td width=50% align="right">Total Gift Amounts Greater Than (Inclusive):</td>
<td width=50%><input type="text" name="greaterthan" size="10" maxlength="10"></td>
</tr>
<tr>
<td width=50% align="right">Total Gift Amounts Less Than (Inclusive):</td>
<td width=50%><input type="text" name="lessthan" size="10" maxlength="10"></td>
</tr>
<!--
<tr>
<td width=50% align="right">Sort By:</td>
<td width=50%><input type="radio" name="orderby" value="0" checked> Name <input type="radio" name="orderby" value="1"> Date <input type="radio" name="orderby" value="2"> Amount </td>
</tr>
-->
<tr>
<td width=50% align="right">Constituency:</td>
<td><select name="constituency[]" size="4" multiple="yes">
<!--<option value="0"></option>-->
<?
$qs = "select * from sup_con_code";
$q = mysql_query($qs);
while ($row = mysql_fetch_array($q))
{
echo "<option value='$row[0]'";
echo ">$row[1]:$row[2]</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td width=50% align="right">Campaign:</td>
<td><select name="campaign[]" size="4" multiple="yes">
<!--<option value="0">N/A</option>-->
<?
$qs = "select * from sup_campaign where active='y'";
$q = mysql_query($qs);
while ($row = mysql_fetch_array($q))
{
echo "<option value='$row[0]'";
echo ">$row[1]:$row[2]</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td width=50% align="right">Appeal:</td>
<td><select name="appeal[]" size="4" multiple="yes">
<!--<option value="0">N/A</option>-->
<?
$qs = "select * from sup_appeal";
$q = mysql_query($qs);
while ($row = mysql_fetch_array($q))
{
echo "<option value='$row[0]'";
echo ">$row[1]:$row[2]</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td width=50% align="right">Account:</td>
<td><select name="acct_code[]" size="4" multiple="yes">
<!--<option value="0">N/A</option>-->
<?
$qs = "select * from sup_acct_code";
$q = mysql_query($qs);
while ($row = mysql_fetch_array($q))
{
echo "<option value='$row[0]'";
echo ">$row[1]:$row[2]</option>\n";
}
?>
<!-- 8-28-2006 Added in drop down list to select Type of Gift as requested from Dianne -->
<tr>
<td width=50% align="right">Gift Type:</td>
<td>
<select name="gift_type[]" size="4" multiple="yes">
<!--<option value="0">All - Except IN-Kind</option>-->
<?php
$qs = "select * from sup_typegift";
$q = mysql_query($qs);
while ($row = mysql_fetch_array($q)){
echo "<option value = '$row[0]'";
echo ">$row[1]</option>\n";
}
?>
<!-- End Added Script -->
</select>
</td>
</tr>
<!--
<tr>
<td width=50% align="right">Constituent:</td>
<td width=50%>
<input type=button onClick='if2=document.forms[0].zname;ifield=document.forms[0].zcon; chooser=window.open("relate_chooser.php", "chooser", "toolbar=no,menubar=no,scrollbar=no,width=400,height=300");chooser.ifield = ifield;chooser.if2=if2' value="...">
<input type="text" name="zname">
<input type="hidden" name="zcon" value="0">
</td>
</tr>
-->
<tr>
<td><input type="hidden" name="action" value="submitted"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Preview"></td>
</tr>
</table>
</form>
<div align="center">
<?
if ($prevmenu<>"")
{
echo ("<div align='center'><a href='menu.php?menu=$prevmenu'>Return to previous Menu</a></div>");
}
?>
Here is the partial code of the page it goes to where the sql script is generated.
if ($campaign>0)
{
$zsearch=$zsearch." and g.campaign='$campaign'";
}
if ($appeal>0)
{
$zsearch=$zsearch." and g.appeal='$appeal'";
}
if ($acct_code>0)
{
$zsearch=$zsearch." and g.acct_code='$acct_code'";
}
if ($gift_type>0){
$zsearch=$zsearch." and g.typegift='$gift_type'";
}else{
$zsearch=$zsearch." and g.typegift<>'4'";
}
if ($greaterthan <> "")
{
$zsearch1=$zsearch1." total >= '$greaterthan'";
}
if ($lessthan <> "")
{
if ($greaterthan == "")
{
$zsearch1=$zsearch1." total <= '$lessthan'";
} else {
$zsearch1=$zsearch1." and total <= '$lessthan'";
}
}
if ($zcon>0)
{
$zsearch=$zsearch." and c.con_id='$zcon'";
}
elseif ($constituency>0)
{
$zsearch=$zsearch." and (constituency0='$constituency' or constituency1='$constituency' or constituency2='$constituency' or constituency3='$constituency' or constituency4='$constituency' or constituency5='$constituency' or constituency6='$constituency' or constituency7='$constituency' or constituency8='$constituency' or constituency9='$constituency')";
}
This is what I get if I echo $zsearch
and g.campaign='Array' and g.appeal='Array' and g.acct_code='Array' and g.typegift='Array' and (constituency0='Array' or constituency1='Array' or constituency2='Array' or constituency3='Array' or constituency4='Array' or constituency5='Array' or constituency6='Array' or constituency7='Array' or constituency8='Array' or constituency9='Array')
I would like for it to look like this.
and g.campaign='1,2,3,4' and g.appeal='1,2,3,4' and g.acct_code='123,234,345,456' (etc...)
Here is the form code.
<form action="rpt600a.php" method="post">
<? echo("<input type=hidden name=prevmenu value='$prevmenu'>"); ?>
<table align='center' width="800">
<tr>
<td width=50% align="right">Start Date:</td>
<td width=50%><input type="text" name="startdate" size="10" maxlength="10" onFocus="javascript:vDateType='1'" onKeyUp="DateFormat(this,this.value,event,false,'1')" onBlur="DateFormat(this,this.value,event,true,'1')"></td>
</tr>
<tr>
<td width=50% align="right">Stop Date:</td>
<td width=50%><input type="text" name="stopdate" size="10" maxlength="10" onFocus="javascript:vDateType='1'" onKeyUp="DateFormat(this,this.value,event,false,'1')" onBlur="DateFormat(this,this.value,event,true,'1')"></td>
</tr>
<tr>
<td width=50% align="right">Total Gift Amounts Greater Than (Inclusive):</td>
<td width=50%><input type="text" name="greaterthan" size="10" maxlength="10"></td>
</tr>
<tr>
<td width=50% align="right">Total Gift Amounts Less Than (Inclusive):</td>
<td width=50%><input type="text" name="lessthan" size="10" maxlength="10"></td>
</tr>
<!--
<tr>
<td width=50% align="right">Sort By:</td>
<td width=50%><input type="radio" name="orderby" value="0" checked> Name <input type="radio" name="orderby" value="1"> Date <input type="radio" name="orderby" value="2"> Amount </td>
</tr>
-->
<tr>
<td width=50% align="right">Constituency:</td>
<td><select name="constituency[]" size="4" multiple="yes">
<!--<option value="0"></option>-->
<?
$qs = "select * from sup_con_code";
$q = mysql_query($qs);
while ($row = mysql_fetch_array($q))
{
echo "<option value='$row[0]'";
echo ">$row[1]:$row[2]</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td width=50% align="right">Campaign:</td>
<td><select name="campaign[]" size="4" multiple="yes">
<!--<option value="0">N/A</option>-->
<?
$qs = "select * from sup_campaign where active='y'";
$q = mysql_query($qs);
while ($row = mysql_fetch_array($q))
{
echo "<option value='$row[0]'";
echo ">$row[1]:$row[2]</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td width=50% align="right">Appeal:</td>
<td><select name="appeal[]" size="4" multiple="yes">
<!--<option value="0">N/A</option>-->
<?
$qs = "select * from sup_appeal";
$q = mysql_query($qs);
while ($row = mysql_fetch_array($q))
{
echo "<option value='$row[0]'";
echo ">$row[1]:$row[2]</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td width=50% align="right">Account:</td>
<td><select name="acct_code[]" size="4" multiple="yes">
<!--<option value="0">N/A</option>-->
<?
$qs = "select * from sup_acct_code";
$q = mysql_query($qs);
while ($row = mysql_fetch_array($q))
{
echo "<option value='$row[0]'";
echo ">$row[1]:$row[2]</option>\n";
}
?>
<!-- 8-28-2006 Added in drop down list to select Type of Gift as requested from Dianne -->
<tr>
<td width=50% align="right">Gift Type:</td>
<td>
<select name="gift_type[]" size="4" multiple="yes">
<!--<option value="0">All - Except IN-Kind</option>-->
<?php
$qs = "select * from sup_typegift";
$q = mysql_query($qs);
while ($row = mysql_fetch_array($q)){
echo "<option value = '$row[0]'";
echo ">$row[1]</option>\n";
}
?>
<!-- End Added Script -->
</select>
</td>
</tr>
<!--
<tr>
<td width=50% align="right">Constituent:</td>
<td width=50%>
<input type=button onClick='if2=document.forms[0].zname;ifield=document.forms[0].zcon; chooser=window.open("relate_chooser.php", "chooser", "toolbar=no,menubar=no,scrollbar=no,width=400,height=300");chooser.ifield = ifield;chooser.if2=if2' value="...">
<input type="text" name="zname">
<input type="hidden" name="zcon" value="0">
</td>
</tr>
-->
<tr>
<td><input type="hidden" name="action" value="submitted"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Preview"></td>
</tr>
</table>
</form>
<div align="center">
<?
if ($prevmenu<>"")
{
echo ("<div align='center'><a href='menu.php?menu=$prevmenu'>Return to previous Menu</a></div>");
}
?>
Here is the partial code of the page it goes to where the sql script is generated.
if ($campaign>0)
{
$zsearch=$zsearch." and g.campaign='$campaign'";
}
if ($appeal>0)
{
$zsearch=$zsearch." and g.appeal='$appeal'";
}
if ($acct_code>0)
{
$zsearch=$zsearch." and g.acct_code='$acct_code'";
}
if ($gift_type>0){
$zsearch=$zsearch." and g.typegift='$gift_type'";
}else{
$zsearch=$zsearch." and g.typegift<>'4'";
}
if ($greaterthan <> "")
{
$zsearch1=$zsearch1." total >= '$greaterthan'";
}
if ($lessthan <> "")
{
if ($greaterthan == "")
{
$zsearch1=$zsearch1." total <= '$lessthan'";
} else {
$zsearch1=$zsearch1." and total <= '$lessthan'";
}
}
if ($zcon>0)
{
$zsearch=$zsearch." and c.con_id='$zcon'";
}
elseif ($constituency>0)
{
$zsearch=$zsearch." and (constituency0='$constituency' or constituency1='$constituency' or constituency2='$constituency' or constituency3='$constituency' or constituency4='$constituency' or constituency5='$constituency' or constituency6='$constituency' or constituency7='$constituency' or constituency8='$constituency' or constituency9='$constituency')";
}
This is what I get if I echo $zsearch
and g.campaign='Array' and g.appeal='Array' and g.acct_code='Array' and g.typegift='Array' and (constituency0='Array' or constituency1='Array' or constituency2='Array' or constituency3='Array' or constituency4='Array' or constituency5='Array' or constituency6='Array' or constituency7='Array' or constituency8='Array' or constituency9='Array')
I would like for it to look like this.
and g.campaign='1,2,3,4' and g.appeal='1,2,3,4' and g.acct_code='123,234,345,456' (etc...)