ArrayList PHP

Hello I am working on a University project where I have a Database which contain elements that I want to retrieve a convert into a PHP array which will be used to populate an Html file

Below is an example of the array I want my to retrieve from my database which I cant since I am really new to this

1, 'title' => '', 'intro' => '', 'imgUrl' => '', 'content' => '' ], array[ 'id' => 2, 'title' => '', 'intro' => '', 'imgUrl' => '', 'content' => '' ?>

This array will be used to populate the HTML code below:

Learn More

My question is if someone can help me retrieve the data from my database and display it as per my PHP array list so that I can populate my HTML code, I have already established the connection with the db

What I have tried:

1, 'title' => '', 'intro' => '', 'imgUrl' => '', 'content' => '' ], array[ 'id' => 2, 'title' => '', 'intro' => '', 'imgUrl' => '', 'content' => '' ?>

Learn More

I have tried using this method but it does not seem to work:

$sql = "SELECT [id, title, imgUrl, content, intro] from slider"; $data= $conn->query[$sql]; if [$slides->num_rows > 0] { $slides = $data->fetch_assoc[]; foreach[$slides as $slide]{ echo $slide['id']; } }

Video liên quan

Chủ Đề