close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Array in Variable

Thread began 2/03/2011 9:58 am by swolock397582 | Last modified 2/03/2011 10:57 am by Jason Byrnes | 880 views | 3 replies |

swolock397582

Array in Variable

I would like to be able to echo some text that looks like this 'i1, i2, i3, i6, i8' where the numbers are unique IDs from a table. It seems to me I could do this with an array but I haven't been able to get it to work.

Ideally I could use the variable wherever I want on a PHP page like 'echo $thearray;'

Any ideas or help are greatly appreciated?

PS... I'm wondering if there's a way to use Create Dynamic Array from Dynamic Dropdowns.

Sign in to reply to this post

Jason ByrnesWebAssist

create a recordset to return the ids, then create the array using code similar to:

php:
<?php 
$myArray 
= array();
do { 
    
$myArray[] = "i".$row_RecordsetName['ID']; 
} while (
$row_RecordsetName mysql_fetch_assoc($RecordsetName)); 
?>


you will need to replace "RecordsetName" with the name of the recordset and ID with the name of the ID column.

convert the array to a comma separated list using this:

php:
<?php echo(implode(", ",$myArray)); ?>
Sign in to reply to this post

swolock397582

Wow! Thanks for the amazingly quick response and simple solution. It works perfectly.

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...