PHP - foreach Loops and Associative Arrays

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 พ.ย. 2024

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

  • @dayoungkim1484
    @dayoungkim1484 4 ปีที่แล้ว +5

    Thank you for making this vedio. Your voice is so smooth!

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

    Superb Sir, I just have clear my doubts, Now seeking foreach() for 2D arrays.
    Taking Fight_Club Values was Awesome!!

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

    just wow, associative array and foreach always confuses me, thank u learned soo much

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

    Steve Rogers= "I understood that (fight club) reference!"

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

    Thanks, was really clear. Nice video!

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

    thank youuuu

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

    Useful video

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

    Awesome tutorial, will you also cover pdo insert, update and viewing data in the future?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  4 ปีที่แล้ว

      I have the PDO connection tutorial in my PHP playlist - th-cam.com/video/wMm2lUoMe6k/w-d-xo.html
      And I have a whole MySQL playlist - th-cam.com/video/a9W7OpS4LfI/w-d-xo.html
      Eventually I will get back to the PHP list and add more PDO stuff but can't say when.

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

      @@SteveGriffith-Prof3ssorSt3v3 can't wait for more pdo stuff

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

    ty!!

  • @Samuel-vk6kl
    @Samuel-vk6kl 4 ปีที่แล้ว

    thanks nice tutorial

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

    How do you get to apply 'foreach' to make all names printed in a different colour. I have a phpmailer array with several error messages but my page is dark and they default to black.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  4 ปีที่แล้ว

      That is a CSS issue not a PHP one. In a webpage or email the colour is controlled by CSS

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

      @@SteveGriffith-Prof3ssorSt3v3 Hey Steve, I've managed to apply css to the 'echo' command in another php document successfully but that wasn't an array. If I try to add tags and use style="", the page implodes! I'll mess around with this some more. PHP is pretty unforgiving! Thanks for your quick response...

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  4 ปีที่แล้ว

      @@chome4 Don't use inline style properties in your HTML. stick to using CSS class names.
      Modifying my example from the video:
      foreach($assoc as $key => $name){
      echo '' . $name . '';
      }
      You just have to make sure your quotation marks are properly matched.

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

      @@SteveGriffith-Prof3ssorSt3v3 OK thanks. Echo commands now given classes.

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

    sir, how can i store an array of data (into a new table in the DB) from the result of a query? I already have this: $result=mysqli_query($con,$query); It displays the correct rows of information. But I want to store thar new information into a new table in the DB. How to do it? I used while loop (because i just couldnt figure out how to do using foreach loop) but only 1 row is inserted into the table. I wonder why. Here's my while loop: while($row=mysqli_fetch_assoc($result){...$query= "INSERT INTO...} . It insert only 1 row. Further to it, the DB duplicates everytime i refresh the browser. Im stuck....

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  3 ปีที่แล้ว

      The while loop can be used to do this as long as you are not closing the connection.
      Are you using a transaction? Are you committing the transaction?
      Have you considered using a VIEW or a Stored Procedure to copy the data?