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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:19:34+00:00 2026-05-29T11:19:34+00:00

I do this to query all data from the database $query=$this->db->get(‘tablename’, $num, $offset); I

  • 0

I do this to query all data from the database

$query=$this->db->get('tablename', $num, $offset);

I would like to add “string “.$iteratorNumber (that is string1, string2,etc) as a new element in the value array.

I have also tried this

$query=$this->db->get('tablename', $num, $offset);
$query=$query->row_array();
$i=0;
foreach($query as $row)
{ 
   array_push($row,"string".i++);
}

But this doesn’t do what I want it to.

UPDATE
The result looks like this

$data = array(
             array('Name', 'Color', 'Size'),
             array('Fred', 'Blue', 'Small'),
             array('Mary', 'Red', 'Large'),
             array('John', 'Green', 'Medium')
             );

and I would like to then acquire

$data = array(
             array('Name', 'Color', 'Size',''),
             array('Fred', 'Blue', 'Small','something'),
             array('Mary', 'Red', 'Large','something'),
             array('John', 'Green', 'Medium','something')
             );
  • 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-29T11:19:34+00:00Added an answer on May 29, 2026 at 11:19 am

    Why not just do:

    $query = $this->db->get('tablename', $num, $offset);
    $query[] = "new data here!";
    

    Then a new element is added? – If it is an array, you could just do:

    $query[] = array("data" => "new data here!");
    

    Other than the above, I can’t think what you can do without seeing even more of your code – but it does add extra data to your outputted array from the database.

    Update

    Maybe I see what you mean now… you want to add ‘string X’ (where X is the nth entry) as many times as there are rows, so the following should do it (note your question is very nearly there!), but I’d personally make a copy of the array before hand.

    $query = $copy = $this->db->get('tablename', $num, $offset);
    $i=0;
    foreach($query as $row){ 
       array_push($copy,"string".i++);
    }
    $query = $copy;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that simply fetch data from my database, this query returns
In my index file I get data from the database using this function (which
I retrieve data from database using this query: SELECT * FROM tickets_departement_groups WHERE group_id
I'm using this query to get all employees of {clients with name starting with
I'm using the following to get data from database in a php file: $query_pedVR
i have a php question, how can i get all the data from the
I am writing a prototype to programmatically get video data from a database and
is it possible to get all records from database when you do not enter
I'm trying to get data from the database in order to create a list
I'm trying to get some data from my database, and then pass it into

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.