47: Inserting database results into array in PHP - PHP tutorial

  Рет қаралды 145,047

Dani Krossing

Dani Krossing

Күн бұрын

Пікірлер: 98
@roykossley4561
@roykossley4561 Жыл бұрын
Man you 're a life saver..Still helpful in 2023 👌
@Kodeispoetry
@Kodeispoetry 4 жыл бұрын
The content delivery style is excellent. No Fluff. I loved that.
@appleproahed
@appleproahed 6 жыл бұрын
Hello Daniel, Just a heads up when you show us a dump from a print_r then instead of just doing that, so it looks so messy, then arooung the print_r(); you can echo '' and close it after the print_r functions like echo '' and you will get a much more clean look..
@alrenjaygabasan8838
@alrenjaygabasan8838 3 жыл бұрын
This gives me a head start, because i code in another class which doesn't give the require output on my code thanks a bunch.
@toast_hawaii
@toast_hawaii 5 жыл бұрын
Thank you dude, im currently at my exams and you really helped me out. You dont know how much you helped people around the word with this video
@abzalbotbayev
@abzalbotbayev 5 жыл бұрын
OMG, thx bro. I'm about 10 days can't understand how this work. This video is helpfull!
@fadhilaasyam5895
@fadhilaasyam5895 4 жыл бұрын
Hi daniel, thans god you very help me out on my final project. This was very perfect solver for machine learning development. Love you, i'll promote ur channel as i cant give nothing. I am from indonesia btw. Thx
@nikolaoschairopoulos9005
@nikolaoschairopoulos9005 4 жыл бұрын
thank you so much!! you help me for my database project for the university (hello from Athens)
@KwibusOnTour
@KwibusOnTour 5 жыл бұрын
Hey, I learn a lot from this channel. I'm just a beginner in php and mysqli. Yet I already have a compexe question. I am looking for a code / instruction how to make a matrix (multiple dimensional array ????? (I don't know)). What I have is a three table database table 'user' a table 'role' and a connection table 'person2role'. Now I am looking at how I can display the roles horizontally and the users vertically. where the tables intersect should be a +. for example: role1 role2 role3 user1 x user2 x x user3 x
@cacurazi
@cacurazi 6 жыл бұрын
For a better overview of your array do this:
@LearnProgrammingYourself
@LearnProgrammingYourself 5 жыл бұрын
very nice approach of explanation.Thank you, sir.
@invsg5072
@invsg5072 3 жыл бұрын
very well explained! Thank you so much!
@nogafouz2174
@nogafouz2174 2 жыл бұрын
really you have awesome way in explain
@paulklimenko8419
@paulklimenko8419 5 жыл бұрын
Hello nice tuts. I HAVE A QUESTION. Related to array, can you explain why we put html input checkbox name= "checkbox [ ] " . How those brackets as key can turn into value in an array? I dont get it. Thanks pal you awesome.
@JOHNSWORLD-kw8zr
@JOHNSWORLD-kw8zr 7 ай бұрын
Thank you Sir . 'helped a lot.
@atendimentorocodd6631
@atendimentorocodd6631 5 жыл бұрын
You just saved me. Thanks a lot!
@Holycrabbe
@Holycrabbe 7 жыл бұрын
if I could slam a super like button i had done so! thank you my fine sir :D !
@Dani_Krossing
@Dani_Krossing 7 жыл бұрын
[!!SLAM!!] !!! .. .. .. .. ) ) ) ) ) ) ) ) O: ! (me taking the full force of the shock wave)
@khudaijasiddiqui4749
@khudaijasiddiqui4749 4 жыл бұрын
mmtuts i is shaken .O.
@antoniofuller2331
@antoniofuller2331 3 жыл бұрын
Hulk smash the subscribe button
@eminaliyev4953
@eminaliyev4953 4 жыл бұрын
For printing all the rows you can try that: for($i = 0; $i < (mysqli_num_rows($result)); $i++){ foreach($data[$i] as $item){ echo $item." "; } echo ""; }
@nakiapringley5391
@nakiapringley5391 3 жыл бұрын
Great video 💯💯💯💯
@pushparajvaghela3476
@pushparajvaghela3476 6 жыл бұрын
Would it not be better if you use references like : 1D Arrays -> | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 2D Arrays -> | 00 | 01 | 02 | 03 | | 10 | 11 | 12 | 13 | | 20 | 21 | 22 | 23 | | 30 | 31 | 32 | 33 | 3D Arrays -> as cubes instead of just saying multi-dimensional array Also you should explain how the mysqli_query() function returns the result like id text ------------------------- 0 | 1 | Hi | -> Array 1 1 | 2 | there | -> Array 2 2 | 3 | friend | -> Array 3 ResultArray = ( Array1, Array2, Array3 ) ;
@dantewins
@dantewins 5 жыл бұрын
love your videos
@abbashomayooni4749
@abbashomayooni4749 5 жыл бұрын
Hi Daniel, thank you for this tutorial, it's very helpful. but where are the 36-44 episodes ??!! there're missing. please advise. thank you
@jiph294
@jiph294 5 жыл бұрын
Wow. You helped me out so much
@ScreenPrintR
@ScreenPrintR 8 жыл бұрын
As I've been flollowing your tutorials, other subjects on KZbin pop up. Several have been Learn to send SMS Text in PHP. Why would someone want to send or receive text, and how would we implement such an application?
@taynarabarboza5842
@taynarabarboza5842 3 жыл бұрын
thank you!
@gazwanhayat2637
@gazwanhayat2637 2 жыл бұрын
Thank you very much.
@lasithadulshan7357
@lasithadulshan7357 3 жыл бұрын
Thank You!
@shyakaleonce1804
@shyakaleonce1804 5 жыл бұрын
Greetings Sir! From your example how could i use to save only these ids,texts in another table? Im using php PDOs? Waiting to hear from you!
@sahinyasar9119
@sahinyasar9119 5 жыл бұрын
can we use object of javascript as like array with foreach in php?
@Kristin-yf9rq
@Kristin-yf9rq 4 жыл бұрын
Could this be applied to a java program instead of a website and still work correctly?
@yongxinzhang754
@yongxinzhang754 6 жыл бұрын
Hi, is it possible that if I only want selected columns in array (not all at once)? Fx. I have 7 columns in my table in database. I only want to insert results from column nr. 6, 1 and 2, and I want to insert these results in this order (row[6], row[1], row[2]). What should I do so??
@peterlustig502
@peterlustig502 5 жыл бұрын
why do you name the part which is connecting to the database and executing a piece of sql code $result ? wouldnt $execute or $sqlCode be better?
@TheClarkKnight9
@TheClarkKnight9 7 жыл бұрын
Does anyone know what the best way to pass a multi-dimensional array to a new page is. Is it best to use SESSIONS or to serialise the variable and use POST and then unserialise on the other page? Or is there some other method that would be more appropriate?
@noahbroyles8828
@noahbroyles8828 4 жыл бұрын
1:24: "Which I know is not correct" Big LOL!!! 🤣
@Strelarck
@Strelarck 4 жыл бұрын
"big lol"
@inadogood5819
@inadogood5819 3 жыл бұрын
Hi can you please make a video on how to insert array result into database in PHP?
@mnunez6153
@mnunez6153 4 жыл бұрын
hi, i'm stuck on how i can do the reverse, that is, how to insert every data (from the result of COUNTING how many times a word appear in the column) into a table. I was able to display the result, but i need to also insert the data to a table in db. Pls. advice. thanks
@salahuddinakon2835
@salahuddinakon2835 6 жыл бұрын
what about if I have some empty row inside column result? how can I escape that empty row? please help....
@abnermolina8962
@abnermolina8962 6 жыл бұрын
Great!!! thanks i understand it.
@laughout199
@laughout199 4 жыл бұрын
Hi am having issue fetching several data from mysql table with repetition, can I get help
@jaydevvara9457
@jaydevvara9457 6 жыл бұрын
How to retrieve data from database and show in different different checkbox?
@pyrocom8338
@pyrocom8338 4 жыл бұрын
v goooood
@jeffersondulay3756
@jeffersondulay3756 5 жыл бұрын
Hello mmtuts how do i compare database data with form input data? They are both sentences, how do i compare each of the words of those data one by one?
@programmerinnovation1782
@programmerinnovation1782 6 жыл бұрын
this video is helpfull !!!!
@Nicole-ch1qe
@Nicole-ch1qe 5 жыл бұрын
This tutorial playlist has been amazing so far! I'm super new to php coding and I make sure to follow your tutorials asclosely as possible and it has gone well :) I did the same with the code in this video and created the database and table like yours and keep getting this error message: Warning: mysqli_connect(): (HY000/1045): Access denied for user ''@'localhost' (using password: NO) in C:\xampp\htdocs\trialsandtribs\ARRAYS\dbh.php on line 8 connection failed: Access denied for user ''@'localhost' (using password: NO) I don't know how to fix this or where to start. Please help *weeps like child*
@edwinbasa2804
@edwinbasa2804 5 жыл бұрын
Nicole did u put a password in ur code on localhost
@DramaticOgre
@DramaticOgre 6 жыл бұрын
Is it possible to get each value inside the text column separately(not all at once)? And also, without referencing the id for each text. Can someone answer this please?
@djleisheng
@djleisheng 6 жыл бұрын
First, change your $sql variable: // Get only the text column $sql = "SELECT text FROM data"; then leave everything else the same, but change your foreach loop: foreach($data as $d) { foreach($d as $key=>$value) echo "$value "; } Let me know if that's what you were looking for!
@DramaticOgre
@DramaticOgre 6 жыл бұрын
Lei Sheng Thanks for your reply. I tried your code and it's echoing out every value from the "text" column. What I'm looking to do is, for example from the text column, run one query and echo out only "Hi", then run another query to echo out only "You". I would like to do this without referencing the id column. If i was using the id as a reference I could change the sql variable to $sql="SELECT text FROM data WHERE id=4" But I would like to do the same task without referencing a primary key. Is there a way to put the column values in a index? [0],[1],[2]... etc
@kevinfoendoe6987
@kevinfoendoe6987 3 жыл бұрын
@@djleisheng Hii, Do you know how i can access the fetched data in console log for example? I followed the tutorial, and I'm able to echo my results on the screen. But is there a way i can console log the result by typing something in js?
@mydimeisup5103
@mydimeisup5103 8 жыл бұрын
Cool video but quick question. How would this be helpful in the sense that I can just use fetch assoc $row[]
@Dani_Krossing
@Dani_Krossing 8 жыл бұрын
Like the video says towards the end, when we get into OOP PHP later on, we will need to pass on our database data between multiple documents and OOP classes. One way of doing this is by inserting our results into an array. I could also imagine there being other uses for this besides OOP, which makes it useful for people who might be searching for a way to do this. :)
@mydimeisup5103
@mydimeisup5103 8 жыл бұрын
Ahh ok, thanks for the info.
@dc4rts766
@dc4rts766 4 жыл бұрын
after inserting array to database how about updating it using php
@rahullingan2119
@rahullingan2119 4 жыл бұрын
Hii... For this below lines... foreach ($datas as $loopvar ){ echo $loopvar['text']; } I'm getting this Notice: undefined index:text in c:\..... Can u help me on this.?!
@hkn5539
@hkn5539 2 жыл бұрын
Can someone help: in fact there is no difference between the array result and the array datas. Is that right?
@legendofgaming8481
@legendofgaming8481 2 жыл бұрын
I am getting this error: Cannot use a scalar value as an array
@jayveepontanares5837
@jayveepontanares5837 6 жыл бұрын
how to put these into count array?
@NicolasSouzaNCS_ofc
@NicolasSouzaNCS_ofc 4 жыл бұрын
I try this but returns from the second line ... who i can fix that?
@jacksmith3386
@jacksmith3386 8 жыл бұрын
Can you please make coffeescript tutorials?
@shrutiupari
@shrutiupari 7 жыл бұрын
how to use insert query and display the inserted data in json format?
@Dani_Krossing
@Dani_Krossing 7 жыл бұрын
I haven't started a JSON course yet, but it is on my "to-do" list :)
@koby6192
@koby6192 8 жыл бұрын
Could you help me with my footer? :s
@QuranicWorldSinghateh
@QuranicWorldSinghateh 5 жыл бұрын
hello sir how are you doing, thank you for you tutorial, but i have one issue that i want you to help me because am working on my theist and i have error to submit my student attendance using mysqli array here are the code below ( =========== this part is the form side ======== × Mark Class Attendance Grade *
@dishashetty9132
@dishashetty9132 6 жыл бұрын
It would be great if you show how to do this in C language
@antoniofuller2331
@antoniofuller2331 3 жыл бұрын
F**k C
@نسائمالجنة-ر5ن
@نسائمالجنة-ر5ن 8 жыл бұрын
8002f1f9 my ps3 error how to fix it
@aspirine999
@aspirine999 6 жыл бұрын
- how much data do we need? - like 8 datas
@user-testo21347
@user-testo21347 3 жыл бұрын
Nice
@JY-xv7ic
@JY-xv7ic 7 жыл бұрын
how to insert data array to database?
@Dani_Krossing
@Dani_Krossing 7 жыл бұрын
If you have a fixed amount of data in your array, you first seperate the array using the PHP explode() function. Then you assign a variable to each data which allow you to insert it into the database using a INSERT statement.
@pianoLee-sx9dx
@pianoLee-sx9dx 6 жыл бұрын
how do you use the explode function? Is this essential in order to insert into the database?
@pianoLee-sx9dx
@pianoLee-sx9dx 6 жыл бұрын
but how can you use the explode function to insert into separate rows?
@pro_hacker6969
@pro_hacker6969 4 жыл бұрын
actually data is the plural and datum is singular that's according to my own knowledge
@bradcasper4823
@bradcasper4823 Жыл бұрын
Shouldn't you close the connection?
@Dani_Krossing
@Dani_Krossing Жыл бұрын
Connections get automatically closed once the script is done running. 🙂 It's seen as a optional extra step, but you can close it if you want more control over when exactly it closes. You can read more about it here: www.php.net/manual/en/mysqli.close.php
@bradcasper4823
@bradcasper4823 Жыл бұрын
@@Dani_Krossing Thank you, I didn't know this.
@Luism-tz2ey
@Luism-tz2ey 6 жыл бұрын
how to insert into array in pdo?
@Dani_Krossing
@Dani_Krossing 6 жыл бұрын
My PDO series teaches this.
@mmpadyak7491
@mmpadyak7491 6 жыл бұрын
Hi sir ,
@arnelmaghirang8426
@arnelmaghirang8426 3 жыл бұрын
Multidimensional array is hard one to understand.
@tunabehe2694
@tunabehe2694 2 жыл бұрын
Where is the next part bro ???
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
In the playlist bro
@tunabehe2694
@tunabehe2694 2 жыл бұрын
@@Dani_Krossing there are only 15 videos in the php playlist
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
No there is 65. Make sure you choose the right PHP playlist on my channel. 🙂 I have 3 different PHP playlists.
@Jay-hr9ci
@Jay-hr9ci 5 жыл бұрын
I'm looking for a way to do the opposite lol
@AlienEyes
@AlienEyes 3 жыл бұрын
I swear, you are getting paid every time you say array or something
@antoniofuller2331
@antoniofuller2331 3 жыл бұрын
I need a raise. Arrays
@Pythogoras570BC
@Pythogoras570BC Жыл бұрын
Thanks for the presentation. It helped me solving several questions. However, I am using PHP 8.2.2 and the code of the presentation generates an error. I am presenting the problem that might give you an idea for resolving it The code below reads the data $i = 0; $j = 0; while ($row = mysqli_fetch_array($result)) { $dbArr[] = $row; $dbArrTest[$i][$j++] = $row['strName']; $dbArrTest[$i++][$j] = $row['meaning']; } The code below just tests the reading $i = 0; foreach ($dbArr as $strF) { if ($i !== 0) { echo $i . ": " .$strF['strName'] . " : " . $strF['meaning']; echo ""; } $i++; } If $i = 0 --> PHP 8.2.2 generates an error. I have no idea why! I bypassed it by just skipping value $i=0 The same is happening no matter what is the initial value of $i (like 1, 2, 3). My test shows that the problem is generated when rtrying to echo the 1st value of $strF, that is EMPTY!!!
48: Different types of array in PHP - PHP tutorial
2:34
Dani Krossing
Рет қаралды 43 М.
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
Turn Off the Vacum And Sit Back and Laugh 🤣
00:34
SKITSFUL
Рет қаралды 4,7 МЛН
Learning MySQL - JSON in MySQL
19:12
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 66 М.
How to Fetch Data From Database in PHP And Display HTML Tables
20:17
OnlineITtuts Tutorials
Рет қаралды 210 М.
PHP Tutorial (& MySQL) #26 - Getting Data From a Database
7:16
Net Ninja
Рет қаралды 179 М.
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 815 М.
Save HTML Form Data to a MySQL Database using PHP
24:38
Dave Hollingworth
Рет қаралды 212 М.