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 8314169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:43:57+00:00 2026-06-08T20:43:57+00:00

Ok basically I can’t figure out how to get the imploded result from mysql

  • 0

Ok basically I can’t figure out how to get the imploded result from mysql back to a usable variable in php. The array is throwing me for a loop, and driving me nuts.

The checkboxes that are being dynamically created from the db:

<input name="tournament_id[]" value="'.$row['tournament_id'].'" type="checkbox">'.$row['tournament_name'].'

The posted value getting imploded (no sql injection prevention implemented yet):

$got_tournament_id = implode(",",$_POST['tournament_id']);

This gets inserted into mysql like this:

id   user_id   tournament_id
1    16942627  1,10

This is my mysql query to grab the imploded data:

$query = ("SELECT tournament_id FROM tournament WHERE user_id=16942627");
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$got_it = $row['tournament_id'];    
}
$bust_him = var_dump(explode(",", $got_it));
echo $bust_him;

The above using var_dump is returning the following:

array(2) { [0]=> string(1) "1" [1]=> string(2) "10" }

Now this is where I am totally lost, and can’t figure out what to do to get the values 1 and 10 from the array into individual variables. I have tried several ways to do it and I keep ending up with errors, or just the word array. I need some help if anybody can give some. Thanks in advance.

  • 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-08T20:43:58+00:00Added an answer on June 8, 2026 at 8:43 pm

    Don’t var_dump(), whose purpose is debugging, not code or display logic. Just store the output of explode() into $bust_him (what a weird variable name):

    // Store the output of explode() directly
    $bust_him = explode(",", $got_it);
    // No need for individual variables, just access via array keys.
    echo $bust_him[0];
    echo $bust_him[1];
    // etc...
    

    If you have a fixed number of elements, you can use list() to place into variables:

    // You know you only have two, so you can use list()
    // to store directly into variables
    list($first, $second) = explode(",", $got_it);
    echo $first;
    echo $second;
    

    In the long run, a better solution than storing comma-separated values in your table is to create a separate, properly normalized table which links tournament_id to user_id. You then have multiple rows per user_id, each containing one tournament_id. This makes for much simpler and more efficient querying in a lot of instances, enabling the use of COUNT() aggregates for example, among many other benefits.

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

Sidebar

Related Questions

How can I basically carry out a unique constraint on a string data-type field.
Basically just looking to see if you can capture an image from the webcam
Basically I can't get it right. I need something like this: if($p == 1)
I've a field of type char(1) in my MySQL table which basically can have
I'm creating word by word coloring tool. Basically user can select few letters from
I have a variable that contains some text, some html, basically can be a
Basically I can't get the div that holds all the content to move down
basically I can't add Inet control in vb6 via drag and click from the
I have to make a password meter from scratch basically (can't use outside frameworks
Okay, so basically I can't get it to work with parent as the class

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.