Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/11/2019 in all areas

  1. Besides the use of .test(), note the ^ $ in Barand's pattern. Those are required to make sure the regex tests the entire value from beginning to end: without, it only tests if the value contains something matching the pattern.
    1 point
  2. or test = $(".sw_ui").val(); alert(test); isnum = /^\d+$/.test(test); alert(isnum);
    1 point
  3. Yes. Here's a simplified version of your application as an example FORM CODE <?php // // FOR DEBUG PURPOSES ONLY - LIST CONTENTS OF SESSION PLAYLIST // session_start(); if (isset($_SESSION['playlist'])) { echo '<pre>', print_r($_SESSION['playlist'], 1), '</pre>'; echo "</hr><br>\n"; } ?> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $().ready( function() { $(".btn").click( function() { var vid = $(this).data("id"); var vname = $(this).data("name"); $.post( "my_cart.php", { "voice_id" : vid, "voice_name" : vname}, function(resp) { var list = "<tr><td><b>ID</b></td><td><b>Title</b></td></tr>\n"; $.each(resp, function(k, v) { list = list + "<tr><td>" + k + "</td><td>" + v + "</td></tr>\n" }) $("#playlist").html(list) }, "JSON" ) }) }) </script> </head> <body> Song 1 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="1" data-name="song-1.mp3">Add to PlayList </button> <br> Song 2 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="2" data-name="song-2.mp3">Add to PlayList </button> <br> Song 3 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="3" data-name="song-3.mp3">Add to PlayList </button> <br> Song 4 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="4" data-name="song-4.mp3">Add to PlayList </button> <br> Song 5 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="5" data-name="song-5.mp3">Add to PlayList </button> <br> Song 6 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="6" data-name="song-6.mp3">Add to PlayList </button> <br> <br> <h2>Playlist</h2> <table style="width:600px" id="playlist"> </table> </body> </html> MY_CART.PHP <?php session_start(); if ($_SERVER['REQUEST_METHOD']=='POST') { $voice_id = $_POST['voice_id'] ?? 0; $voice_name = $_POST['voice_name'] ?? ''; if ($voice_id && $voice_name) { $_SESSION['playlist'][$voice_id] = $voice_name; exit(json_encode($_SESSION['playlist'])) ; } } exit("ERROR") ; ?>
    1 point
  4. An alternative approach is to create an array during your first pass of the data. This array would contain arrays of records for each rep. EG $salesdata = [ 'Sales_rep1' => [ 0 => [ 'Col1', 'Col2', 'Col3' ], 1 => [ 'Col1', 'Col2', 'Col3' ], 2 => [ 'Col1', 'Col2', 'Col3' ] ], 'Sales_rep2' => [ 0 => [ 'Col1', 'Col2', 'Col3' ], 1 => [ 'Col1', 'Col2', 'Col3' ], 2 => [ 'Col1', 'Col2', 'Col3' ], 3 => [ 'Col1', 'Col2', 'Col3' ] ], ]; You can then loop through the array creating your sheets for each rep. foreach ($salesdata as $rep => $sales) { create new sheet foreach ($sales as $recno => $recdata) { add new row foreach ($recdata as $col) { output column } } }
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.