mysqli fetch array while loop columns

0 votes

I have this code to iterate over a mysqli query:

while($row = mysqli_fetch_array($result)) {
    $posts[] = $row['post_id'].$row['post_title'].$row['content'];
}

It works but it returns:

Variable #1: (Array, 3 elements) ↵ 0 (String): "4testtest" (9 characters) 1 (String): "1Hello world!Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!" (99 characters) 2 (String): "2Sample PageThis is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes)." (161 characters)

The problem is that it puts all three columns into one column, so I can't access them separately.

Can someone please guide me on this?.

Jun 4, 2022 in PHP by Kichu
• 19,040 points
1,478 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to exclude certains columns while using eloquent using php?

Hello @kartik, using hidden array in model is good, but ...READ MORE

answered Nov 6, 2020 in PHP by Niroj
• 82,840 points
1,315 views
0 votes
1 answer

How to merge two arrays while keeping keys instead of reindexing in php?

Hello, Considering that you have $replaced = array('1' => ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,840 points
3,045 views
0 votes
1 answer

How to merge two arrays while keeping keys instead of reindexing?

Hello, Considering that you have $replaced = array('1' => ...READ MORE

answered Apr 15, 2020 in PHP by Niroj
• 82,840 points
2,763 views
0 votes
1 answer

Error:while importing Table for WORDPRESS

Hello @kartik, I had the same error when ...READ MORE

answered May 8, 2020 in PHP by Niroj
• 82,840 points
1,711 views
0 votes
1 answer

How do I specify unique constraint for multiple columns in MySQL?

Hello @kartik, Use this: ALTER TABLE `votes` ADD UNIQUE ...READ MORE

answered Aug 18, 2020 in PHP by Niroj
• 82,840 points
4,890 views
0 votes
1 answer

How to move columns in a MySQL table?

Hello @kartik, If empName is a VARCHAR(50) column: ALTER ...READ MORE

answered Aug 19, 2020 in PHP by Niroj
• 82,840 points
3,103 views
0 votes
1 answer
0 votes
1 answer

mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in.

The issue is that the query given to mysqli_query() is ...READ MORE

answered May 1, 2022 in Other DevOps Questions by narikkadan
• 63,600 points
1,696 views
0 votes
0 answers

Warning: mysqli_query() expects at least 2 parameters, 1 given. What?

I have to build a PHP page ...READ MORE

May 12, 2022 in PHP by Kichu
• 19,040 points
1,276 views
0 votes
0 answers

Object of class mysqli_result could not be converted to string

Code: $result = mysqli_query($con, "SELECT classtype FROM learn_users ...READ MORE

May 15, 2022 in PHP by Kichu
• 19,040 points
1,574 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP