Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7757979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:14:14+00:00 2026-06-01T13:14:14+00:00

I want to implode integers and echo them as a comma separated string. I

  • 0

I want to implode integers and echo them as a comma separated string. I have been an this for almost three hours and I can’t get it to work.
The output I am currently getting is:

104104,105104,105,106

instead of:

104,105,106

I checked the php forums and it says to use mysql_fetch_assoc to avoid this but it doesn’t work. If anyone has any ideas please help. My PHP looks like this:

<?PHP

$user_name = "root";
$password = "";
$database = "testdb";
$server = "127.0.0.1";

$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);

if ($db_found) 
{
$SQL = "SELECT TableA.c1 FROM TableA ";
$result = mysql_query($SQL);
     while ($db_field = mysql_fetch_assoc($result)) 
     { 
     $itinarry[]= $db_field['c1'];
     $string = implode(',',$itinarry);
     echo $string;
     }
mysql_close($db_handle);

}
else  
{
    echo "Database NOT Found ";
    mysql_close($db_handle);        
 }

 ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:14:15+00:00Added an answer on June 1, 2026 at 1:14 pm

    What it’s doing is

    echo implode(",", array(104))

    echo implode(",", array(104, 105))

    echo implode(",", array(104, 105, 106))

    Which results in:

    104104,105104,105,106

    Put

     $string = implode(',',$itinarry);
     echo $string;
    

    out side out the while loop;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have an array and i want to convert this array in comma seprated
I have the following code of which I want to echo array elements separated
I want to implode this array to make a string with all keys =
want to have a Hyperlink-Button in a gridView in which I can display a
I have a PHP array and want to convert it to a string. I
I have this ac.php file and this result.php file I want to use the
How to implode foreach() with comma? foreach($names as $name) { //do something echo '<a
want to know why String behaves like value type while using ==. String s1
I wonder if anyone can help - I want to select a table and
I have a PHP search script and I want to highlight the keywords that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.