fetch

PHP MySql Fetch multiple data



Sharing buttons:

hey guys we are back in the previous

tutorial I have shown you how we can

fetch the simple data and a single data

from the PHP tape from the MySQL table

using PHP application and in this

tutorial I will show you that how we can

fetch all of these table data in a

program okay so we use the coding of the

same program we just save as right okay

fetch underscore multiple underscore

data dot PHP right um we just remove

these things because they're going to

make this program much more efficient

one right so let's do it so we have done

in the previous one on something like

this okay so this thing this court only

fetched a single data but now we want to

fetch multiple data so we'll be using a

while loop so as you have as you know

that vital loop is used to fetch

multiple data it is used to it is not

actually used to fetch multiple data is

actually used to iterate things so what

we do we iterate the table here so that

we can fetch more and more data out of

it alright so what we do now we go in

there go to the while loop and paste it

here so what does this mean so as as far

as this dollar row has value within it

till then while loop will be executing

okay so what we have now we have dollar

row that will be changing its array

values again and again

so each time by look at red we receive

these values and we print the same in a

table format it will be very good to

understand so let's on let's develop a

table here table with border e bar

equals to R 1 px is enough okay close

the table and let's close the table here

so anything within this while loop will

be printed as table row and table data

okay so first thing we have to do now we

have to fetch the on elements out of it

dollar I T sorry dollar username equals

to dollar row the second in first index

dollar email equals to dollar row second

last one dollar H equals to dollar row

third

alright so now that we have fetched the

values from the error variable we have

to print them so this is TR right

echo TR close echo or DD start TD close

and within these be okay let's leave it

for now let's just copy-paste it four

times because we need for table data so

what we have to do now we have to append

these things and we put here dollar ID

now PHP has a very smart engine and

anything we are even if

I put anything in curly braces even if

they are within the double goods

it prints the value of the variable

itself so it's quite smart isn't it so

we don't need to close you double quotes

again and again and we don't know we do

not need to put a pending operator again

and again so it's a very good advantage

of PHP it's a very good thing to be used

in PHP so I hope you you got what I am

saying okay oh I'm sorry we have put ID

on the second number so that's just for

it on the last key now another early

braces with dollar age at as last

element so that that's all for this code

it's quite simple let's see if we have

any errors or just we have to put fetch

underscore multiple underscore data okay

you can see that the values are being

fetched successfully all right so we can

see that there are two values now okay

and two values in the table so there are

two values here what if we insert one

more entry here

the name PHP by fire three and email

address add as a a at gmail.com

these are just dummy email theorem which

I'm putting it is 23 go so I do not need

to change anything in that code itself I

believe so so let's just refresh the

page refresh yep and we have got the

result and the quite a successful one as

you can see as soon as we have

incremented the table added a new entry

it has a built by itself it means that

we do not need to make query again and

again and this code is quite dynamic in

its own way we just use the while loop

here and predict some entries in table

form

so in this tutorial you have seen how we

can fetch multiple values out of the out

of the same table and how we can

structure them and print them on the on

the in the table format using PHP script

so that's all for this tutorial

you can inspect the element of it and

you can see um okay not in Spyder lament

we can just view the page source oops

it's it's it's not an ordered manner but

you can see in the structure it's

printing table right it's putting TR TD

TD close and D DTD whatever is necessary

to display data on the browser is all

given here so that's all for this

tutorial

any doubts or queries comment below on

the YouTube

thank you very much state you don't

by fire for daily updates thank

you very much