Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. how to use implode and explode

how to use implode and explode

Scheduled Pinned Locked Moved Database
databasephptutorialquestionannouncement
3 Posts 3 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    piano0011
    wrote on last edited by
    #1

    Hey guys! I am not sure if this is a good idea but am trying to insert multiple options for the user into a single column in my memberships table.. My table looks like this:(I can't paste the link) but this is my code in trying to use explode to convert back to an arrray so that I can do some checks. Is the last part correct where I use the foreach loop to check for a certain variable to be true or not?

    1. {
      while($row = mysqli_fetch_assoc($result)) {
      $subscriptionplan = $row['subscriptionplan'];

                                $expirydate = $row\['expirydate'\];
                                $expirydate2 = $row\['expirydate2'\];
                                $expirydate3 = $row\['expirydate3'\];
                                $activate = $row\['activate'\];
                                $token2 = $row\['token2'\];
                              
                                if ($activate == 0) {
                                   header("Location: index.php?level1=premiumplannotactivated");
                                   exit();
                                } else {
      
                                  
      
      
      
                        
                                   // already expired, so delete user's plan.
      
                                if ($subscriptionplan == 'Level 1' && date("Y-m-d") > $expirydate && $activate == 1) {
                                   
                                   $sql = "UPDATE memberships
                                           SET subscriptionplan = '', subscriptionplandate = '', expirydate = ''
                                           WHERE user\_uid = '".$\_SESSION\['u\_uid'\]."'
      
                                          ";
      
    L P 2 Replies Last reply
    0
    • P piano0011

      Hey guys! I am not sure if this is a good idea but am trying to insert multiple options for the user into a single column in my memberships table.. My table looks like this:(I can't paste the link) but this is my code in trying to use explode to convert back to an arrray so that I can do some checks. Is the last part correct where I use the foreach loop to check for a certain variable to be true or not?

      1. {
        while($row = mysqli_fetch_assoc($result)) {
        $subscriptionplan = $row['subscriptionplan'];

                                  $expirydate = $row\['expirydate'\];
                                  $expirydate2 = $row\['expirydate2'\];
                                  $expirydate3 = $row\['expirydate3'\];
                                  $activate = $row\['activate'\];
                                  $token2 = $row\['token2'\];
                                
                                  if ($activate == 0) {
                                     header("Location: index.php?level1=premiumplannotactivated");
                                     exit();
                                  } else {
        
                                    
        
        
        
                          
                                     // already expired, so delete user's plan.
        
                                  if ($subscriptionplan == 'Level 1' && date("Y-m-d") > $expirydate && $activate == 1) {
                                     
                                     $sql = "UPDATE memberships
                                             SET subscriptionplan = '', subscriptionplandate = '', expirydate = ''
                                             WHERE user\_uid = '".$\_SESSION\['u\_uid'\]."'
        
                                            ";
        
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      PHP: explode - Manual[^] ..it is not a very good idea to put an array into a single field. Put them in a separate table and link to it from the original table.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

      1 Reply Last reply
      0
      • P piano0011

        Hey guys! I am not sure if this is a good idea but am trying to insert multiple options for the user into a single column in my memberships table.. My table looks like this:(I can't paste the link) but this is my code in trying to use explode to convert back to an arrray so that I can do some checks. Is the last part correct where I use the foreach loop to check for a certain variable to be true or not?

        1. {
          while($row = mysqli_fetch_assoc($result)) {
          $subscriptionplan = $row['subscriptionplan'];

                                    $expirydate = $row\['expirydate'\];
                                    $expirydate2 = $row\['expirydate2'\];
                                    $expirydate3 = $row\['expirydate3'\];
                                    $activate = $row\['activate'\];
                                    $token2 = $row\['token2'\];
                                  
                                    if ($activate == 0) {
                                       header("Location: index.php?level1=premiumplannotactivated");
                                       exit();
                                    } else {
          
                                      
          
          
          
                            
                                       // already expired, so delete user's plan.
          
                                    if ($subscriptionplan == 'Level 1' && date("Y-m-d") > $expirydate && $activate == 1) {
                                       
                                       $sql = "UPDATE memberships
                                               SET subscriptionplan = '', subscriptionplandate = '', expirydate = ''
                                               WHERE user\_uid = '".$\_SESSION\['u\_uid'\]."'
          
                                              ";
          
        P Offline
        P Offline
        phan anh huan
        wrote on last edited by
        #3

        alotinhay[^].

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups