Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Database values to array and shuffling it

I have a database row values like this:

Raffleticket  (column name)
00001
00002   
00003
00004
00006
00009

How may I be able to store all these raffleticket values into an array and shuffle it? Thanks in advance!

How to convert this to get it all into an array? I am only using mysqli_num_rows to count the column rows. It returns that there are 6 rows but I wanted it to use the row values instead of the column row count.

       <?php
        $sql = mysqli_query ($connect, "Select `raffleticket` from 
        employee");
            $count = mysqli_num_rows($sql);

         ?>

script:

         var count = <?php echo $count ?>;
            var numvar = 0, 
                datafromform = ''; 
            $('body').keydown(function(e){

                if(e.keyCode == 83 && numvar == 0){
                    if(datafromform != ''){
                        $('#myModal').modal('toggle'); 
                    }

                    animationTimer = setInterval(function() {
                        var randnum = Math.floor(Math.random() * count+1),
                            strnum = ""+randnum+""; 
                        if(strnum.length == 2){
                            $('#output').text(''+randnum);
                        }else{
                            $('#output').text('0'+randnum);
                        }
                    }, 500);
                    $('#instruction').text("Press 'X' to Stop Raffle");

                    numvar = numvar + 1;
                }


                if(e.keyCode == 88) {
                    numvar = 0;
                    clearInterval(animationTimer);

                    $.ajax({
                       type: "POST",
                       url: 'send.php',
                       data: 'res='+$('#output').text().trim(),
                       success: function(response){
                            var result = $.parseJSON(response);
                           $('#queryresult').html(result[0]);
                           var photo = result[1];
                            document.getElementById('imageBox').src =photo ;

                       }
                    });
                    $("#myModal").modal({backdrop: "static"});
                    $('#instruction').text("Press 'S' to Start Raffle");
                    datafromform = 'good';
                }
            });
        </script>

Sample result of the current code

Shuffling

It only uses the row count and not the database column rows above :(

Comments