Jump to content

Too many comas


adam1972

Recommended Posts

I think I figured out how to convert an array into a string and use the string in a query... I have an array with over 40 options on a multi-select drop down list that I want to pass from a form using post to use in a query. When I do it I end up with too many commas and it fails. Here's what I've got..


<?php
echo "You selected ".count($display)." for your search";
if (count($display)==1)
   {
       for($i=0;$i            {
               $display3 = $display[$i].""; 

               echo $display3;
           }
   }
else
   {
       for($i=0;$i            {
               $display2 = $display[$i].","; 
               $display3 = substr($display2,0,-1);
                               // I've even tried $display3=eregi_replace(',$', '', $display2); 
               echo $display3;
           }
   }
?>


 

These methods end up removing the commas across the whole string.. Not just the one at the end.

 

What am I doing wrong? :rolleyes:

Link to comment
Share on other sites

Here's the page:

 

>







</pre>
<table width="99%" border="0" align="center">Search:Column to Search: 

ForeclosureType

RadarID

APN

County

Address

City

State

Zip

Owner

OwnerFirstName

OwnerLastName

OwnerSpouseFirstName

Owner2

OwnerAddress

OwnerCity

OwnerState

OwnerZip

OwnerPhone

PropertyType

SqFt

YearBuilt

Beds

Baths

LotSize

EstimatedValue

EstimatedTotalLoanBalance

RecordingDate

Trustee

TrusteeSaleNum

Sort by:

ForeclosureType

RadarID

APN

County

Address

City

State

Zip

Owner

OwnerFirstName

OwnerLastName

OwnerSpouseFirstName

Owner2

OwnerAddress

OwnerCity

OwnerState

OwnerZip

OwnerPhone

PropertyType

SqFt

YearBuilt

Beds

Baths

LotSize

EstimatedValue

EstimatedTotalLoanBalance

RecordingDate

Trustee

TrusteeSaleNum

</table>
<br><br><br><br><br><div align="left">

ForeclosureType
RadarID
APN
County
Address
City
State
Zip
Beds
Baths
SqFt
LotSize
Owner
OwnerFirstName
OwnerLastName
OwnerSpouseFirstName
Owner2
OwnerAddress
OwnerCity
OwnerState
OwnerZip
OwnerPhone
PropertyType
YearBuilt
EstimatedValue
EstimatedTotalLoanBalance
RecordingDate
Trustee
TrusteeSaleNum
TrusteePhone
SaleDate
SaleTime
SalePlace
PublishedBid
OpeningBid
WinningBid
EstimatedLoanPosition
LoanDate
LoanDocNum
LoanAmount
loan1RecDate
loan1DocNumber
loan1LoanAmount
loan2RecDate
loan2DocNumber
loan2LoanAmount
loan3RecDate
loan3DocNumber
loan3LoanAmount

</div>
<br><br><br

Link to comment
Share on other sites

Try this link: http://jlhaslip.trap17.com/sm/select.php

 

Go to that page and select the information available in the drop-downs and 'submit the form' to see the output.

It outputs the POST array followed by a comma separated list of the 'display' array.

 

The php code to create the list is as follows:

       $out = implode($_POST['display'], ',');
       echo 'Output after implosion of POST[display] array :' . $out;

 

Of course, i don't have the Database to work with, but you should be able to use this method to create the information as you require.

 

Post back if you need anything else.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...