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 in PHP by Kichu
• 19,040 points
19 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,720 points
115 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,720 points
774 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,720 points
1,294 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,720 points
620 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,720 points
2,066 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,720 points
433 views
0 votes
1 answer
0 votes
0 answers
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 in PHP by Kichu
• 19,040 points
16 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 in PHP by Kichu
• 19,040 points
74 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP