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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:25:54+00:00 2026-05-24T14:25:54+00:00

I am having trouble showing a row from a database which has a list

  • 0

I am having trouble showing a row from a database which has a list of skills as an array which is delimited by a commas. Fully annotated code with explanation below is what i’ve done sor far. All help is much appreciated. Thanks in advance.

// DB Connection here

    // Execute Query 
    $sql        =   "SELECT id, skills FROM p_info";
    $result     =   mysql_query($sql);
    $row        =   mysql_fetch_array($result);

    // Delimit array by comma
    $myArray = explode(',', $row['skills']);

    // Store as array
    $myArr   = array($myArray);

    /** 
    Assume the value of is skills row in the database is: type 1, type 2,  type 3, type 4 
    i would like to show these values each on a seperate <li> element hence using a loop. 

    <li> type 1</li>
    <li> type 2</li>
    <li> type 3</li>
    <li> type 4</li>

    My guess would be to use foreach loop..but im a little confused how to  go about this. Here whats i think logically:

    **/
    ?>
        <ul>
        <?
            foreach ( $myArr as $skills ) { 
        ?>
            <li><?=$myArr;?></li>

        <? 
            } // End loop 
        ?>
        </ul>

    <!-- Can someone tell me what im doing wrong? im fairly new to PHP but im a quick learner. :) -->
  • 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-05-24T14:25:54+00:00Added an answer on May 24, 2026 at 2:25 pm

    Remove $myArr = array($myArray); and do foreach ( $myArray as $skills ) { instead.
    You are putting your array within a new array, so when you try to loop through it you end up with the original array.

    Also change <?=$myArr;?> to <?=$skills;?>, you are looping through $myArray and storing every part in $skills temporarily, $myArray doesn’t change so it’s useless trying to echo it.

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

Sidebar

Related Questions

I am having trouble initializing a constant array of constant strings. From week.h (showing
I'm having trouble showing the favicon of a subdomain (which redirects to a PHP
I am having trouble with showing items from a model defined in c++ in
I'm having trouble seeing tables from one particular SQL Server 2008 database while trying
I'm having trouble showing a list of images on a site. using this question
Im having trouble reading from a CSV file final String DELIMITER = ,; Scanner
I am having trouble with IE7. I have a header, which is an IMG.
I'm having trouble showing and hiding a tag on my page. When the page
I am having trouble with MPMoviePLAYER not showing video just audio. It doesn't work
I'm having trouble parsing an iso date from my json api/mongodb using rest kit.

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.