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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:03:47+00:00 2026-05-30T21:03:47+00:00

I need to select a whole column. So my question is how do i

  • 0

I need to select a whole column.
So my question is how do i get a whole column ?

        $query  = "SELECT * ";
        $query .= "FROM employees ";
        $query .= "WHERE id=*";
        $query .= "ORDER BY id ASC ";

I tried id=* but no luck …
My goal is to cycle through all IDs but some may be missing so i figured i put them in a numeric or associative array and use foreach. If there is a better way , please do share.

EDIT:

function get_all_ids()
    {
        global $connection;
        $query  = "SELECT * ";
        $query .= "FROM employees ";
        $query_result = mysql_query ( $query , $connection );
        confirm_query($query_result);
        $query_result_array = mysql_fetch_assoc($query_result);
        return $query_result_array;
    }

i use this to print the array

  $all_id = get_all_ids();
// preparing the table;
    echo "<pre>";
    print_r($table);
    print_r($all_id);
    echo "</pre>";

and this is the array

  Array
    (
        [id] => 1
        [department_id] => 1
        [name] => jordan
        [EGN] => 9108121544
        [email] => testEmail
        [address] => testAddress
        [country] => testCounty
    )
  • 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-30T21:03:48+00:00Added an answer on May 30, 2026 at 9:03 pm

    If there’s more than one row in your result set, you need to keep fetching until all results are retrieved:

    $q = mysql_query('SELECT * FROM `table`');
    while (($row = mysql_fetch_assoc($q)) != FALSE)
    {
    // Do something with *one* result
    }
    mysql_free_result($q);
    

    If you’d like to retrieve all ids in a single fetch, you could do:

    $q = mysql_query('SELECT GROUP_CONCAT(`id`) AS `id_list` FROM `table`');
    $row = mysql_fetch_assoc($q);
    mysql_free_result($q);
    
    $list_of_ids = explode(',', $row['id_list']);
    

    WARNING: GROUP_CONCAT() usually has a result limit of 1024 bytes; meaning your results will be truncated for large tables. You could either resort to the first solution, or increase group_concat_max_len for the current connection.

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

Sidebar

Related Questions

I need a select from table which does not have column that tells when
I need to select the counts from two tables that share a common column
I need to select a datetime column in a table. However, I want the
I need to select and act on a table element with JQuery, but only
I create the checkbox column in datagrid. and it works fine. But i need
Just using a SELECT in my MySQL statement, trying to get a column. $last_visit
I'm selecting rows from a table select name,age from tabl1 I need to add
I need to add a new SELECT statement whose search condition include something like
how can i express in xpath a) need select elements which contains specified keyword.
I need to select data when a page is viewed and update the 'views'

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.