inserting data into two db tables using php

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ต.ค. 2024
  • How to insert data into two different tables in the database using php

ความคิดเห็น • 36

  • @justgotravel6646
    @justgotravel6646 2 ปีที่แล้ว +2

    I guess you never heard the concept of relational database.
    How would you be able to link the user to the message? The way you do it would be a mess. If a message record is deleted/wrong inserts you would have a mismatch in primary keys. Furthermore if you later on want to extend with more tables then all the autoincrement keys are not in sync.
    I suggest you add userid column to the message table. Then you need to insert the user in first SQL insert, have the new user ID returned (you can do this in PHP), do the second SQL2 query adding the message and userid to the message table.
    With this method you can have several messages for the same user record.
    And now you have a relationship - Relational Database.

  • @kotimunkansi3055
    @kotimunkansi3055 4 ปีที่แล้ว

    This video was very helpful... i had lost so much hope in finding a solution

  • @bstechideas2173
    @bstechideas2173 2 ปีที่แล้ว

    Thank you so much for this. Been looking for this fro 2 months! You got yourself another subscriber. Bravo

  • @rakaadiprasetya6863
    @rakaadiprasetya6863 ปีที่แล้ว

    thank you so much for this video bro, finally got the answer for my problem👍👍👍👍👍👍👍👍👍👍

  • @johnjack577
    @johnjack577 3 หลายเดือนก่อน

    Boss kindly do a tutorial on a foreign key, relating two tables together on a database

  • @dennischarles4384
    @dennischarles4384 3 ปีที่แล้ว

    Thanks indeed, your contribution is the best!

  • @niwamicha226
    @niwamicha226 3 ปีที่แล้ว +1

    thank you so much for this tutorial , can i you please do it for the foreing key

  • @sharthakrai4482
    @sharthakrai4482 3 ปีที่แล้ว

    just the video I needed for my assignment! thanks

  • @afrikblog5162
    @afrikblog5162 4 ปีที่แล้ว +1

    Sir please I will really appreciate it if you could do a video on how to insert into a table that has a foreign key constraint and also teach on auto date with php ..which means when a user click on the submit button they should be a auto date of the registration

    • @petermsomphola4497
      @petermsomphola4497 3 ปีที่แล้ว

      on auto date just create current timestamp in your database

  • @diedsoul7591
    @diedsoul7591 2 ปีที่แล้ว

    great but i have a quest, how can we put the id the same i mean in the messages table the id should be the same to the id of the table user

  • @Shr3zza
    @Shr3zza 3 ปีที่แล้ว +1

    Hi How would i do this if I wanted to insert it into 3 different tables ?

  • @samtadhanve8539
    @samtadhanve8539 3 ปีที่แล้ว

    Thank u so much it's help me lot..

  • @Giangbpro
    @Giangbpro 4 ปีที่แล้ว

    Gracias me ha ayudado mucho

  • @kainatit4649
    @kainatit4649 3 ปีที่แล้ว

    I wanna use database tables as options in drop down menu to insert data of different semester's student into different separate tables. how can I do this?

  • @aymanechnaif9308
    @aymanechnaif9308 3 ปีที่แล้ว

    Thanks for the video it was great

  • @priyankasawant2083
    @priyankasawant2083 4 ปีที่แล้ว +1

    thank you man thank you so much its help me a lot.

  • @balogunsemako1912
    @balogunsemako1912 3 ปีที่แล้ว

    Nice Video Bro
    how can i insert into two db table base on gander select

  • @mouradmessaoud7440
    @mouradmessaoud7440 5 ปีที่แล้ว

    hello, it's beautiful I understood everything but I ask you a query that is inserted in two tables with recovery of identifier auto increment after each request, then inserted into the third table, thank you very much and good continuity.

  • @afiqahsaid5763
    @afiqahsaid5763 2 ปีที่แล้ว

    hi, how do you do for auto increment unique id (same for 2 tables in database) so that we know based on the same id (connected between 2 table)? really appreciate your help on this . thanks

    • @justgotravel6646
      @justgotravel6646 2 ปีที่แล้ว

      I suggest you add userid column to the message table. Then you need to insert the user in first SQL insert, have the new user ID returned (you can do this in PHP), do the second SQL2 query adding the message and userid to the message table.

  • @dianaabdulrasyid4766
    @dianaabdulrasyid4766 2 ปีที่แล้ว

    May God bless you

  • @marigiyvonne294
    @marigiyvonne294 3 ปีที่แล้ว

    Very Helpful

  • @akhilkazi1454
    @akhilkazi1454 4 ปีที่แล้ว

    Hello sir please update a video as price qty total with inserting to database.

  • @abrakadabrajordan5184
    @abrakadabrajordan5184 4 ปีที่แล้ว

    I tried this code and it worked, although the second time it did not work, and then after that it never worked again, can anyone explain this?

  • @therandompostguy
    @therandompostguy 4 ปีที่แล้ว +2

    I was thinking you could do this project for me. Do provide your email so we can talk privately.

    • @zegitalacademy6281
      @zegitalacademy6281  4 ปีที่แล้ว +1

      zegitalmedia@gmail.com

    • @therandompostguy
      @therandompostguy 4 ปีที่แล้ว +1

      @@zegitalacademy6281Thank you so much for replying, I have sent you an email.

  • @0sawelucky815
    @0sawelucky815 3 ปีที่แล้ว

    Thanks

  • @anxious3350
    @anxious3350 2 ปีที่แล้ว

    Its always failed, why ?

  • @gokulg2756
    @gokulg2756 3 ปีที่แล้ว

    Code plz