Jump to content

Jayfromsandiego

Members
  • Content Count

    24
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Jayfromsandiego

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. NotSunfighter, thank you for trying to help. I don't feel welcomed here anymore and I will be moving on to a better forum where there are friendly people like yourself who want to help others. As for you ginerjm get your head out of your ass you miserable son of a bitch. You sound like a bitter man. I bet you walk through life with a chip on your shoulder. Go do something productive and get that negative attitude out of your system. If you don't have nice things to say, then stay quiet next time and move on.
  2. Hello. I am trying to code a voting poll in php, but don't know how to get started. I came across a javascript type quiz that seems to do what I have in mind, but it needs to be tweaked and coded in php. The reason being that anyone can browse the javascript source code and cheat. Anyhow please see the attached files that show what I am trying to accomplish. The code has 3 files index.html, quiz.css and quiz.js <html> <head> <title>Website - Voting Poll (Javascript)</title> <link rel="stylesheet" href="quiz.css"> <link href="https://fonts.googleapis.com/css?family=Josefin+Sans" rel="stylesheet"> </head> <body> <div id="container"> <h1>Voting Poll >> In Less Than A Minute</h1> <br/> <div id="quiz"></div> <div class="button" id="next"><a href="#">Next</a></div> <div class="button" id="prev"><a href="#">Prev</a></div> </div> <script src="https://code.jquery.com/jquery-3.4.0.min.js"></script> <script src="quiz.js"></script> </body> </html> body { font-family: 'Josefin Sans', sans-serif; } h1 { text-align: center; } .button { width: 80px; height: 25px; text-align: center; float:right; background-color: #fff; margin: 0 2px 0 2px; cursor: pointer; } .button a { text-decoration: none; color: #555; line-height: 25px; } #container { width:50%; margin: 150px auto; padding: 50px 30px; background-color: #3f51b5; border-radius:3px; color: #fff; box-shadow: 0 0 10px 0 #999; } ul { list-style-type: none; padding: 0; margin: 0; width: 500px; } ul li { background: #223394; width: 200px; margin: 10px; padding: 5px; display: inline-block; } #prev { display:none; } #start { display:none; width: 100px; } input[type="radio"]{ cursor: pointer; } (function() { var allQuestions = [{ question: "IMAGE 1 .jpg goes here", options: ["Yes", "No"], answer: 0 }, { question: "IMAGE 2 .jpg goes here", options: ["Yes", "No"], answer: 1 }, { question: "IMAGE 3 .jpg goes here", options: ["Yes", "No"], answer: 1 },{ question: "IMAGE 4 .jpg goes here", options: ["Yes", "No"], answer: 0 }, { question: "IMAGE 5 .jpg goes here", options: ["Yes", "No"], answer: 1 },{ question: "IMAGE 6 .jpg goes here", options: ["Yes", "No"], answer: 0 }]; var quesCounter = 0; var selectOptions = []; var quizSpace = $('#quiz'); nextQuestion(); $('#next').click(function () { chooseOption(); if (isNaN(selectOptions[quesCounter])) { alert('Please select an option !'); } else { quesCounter++; nextQuestion(); } }); $('#prev').click(function () { chooseOption(); quesCounter--; nextQuestion(); }); function createElement(index) { var element = $('<div>',{id: 'question'}); var header = $('<h2>Question No. ' + (index + 1) + ' :</h2>'); element.append(header); var question = $('<p>').append(allQuestions[index].question); element.append(question); var radio = radioButtons(index); element.append(radio); return element; } function radioButtons(index) { var radioItems = $('<ul>'); var item; var input = ''; for (var i = 0; i < allQuestions[index].options.length; i++) { item = $('<li>'); input = '<input type="radio" name="answer" value=' + i + ' />'; input += allQuestions[index].options[i]; item.append(input); radioItems.append(item); } return radioItems; } function chooseOption() { selectOptions[quesCounter] = +$('input[name="answer"]:checked').val(); } function nextQuestion() { quizSpace.fadeOut(function() { $('#question').remove(); if(quesCounter < allQuestions.length) { var nextQuestion = createElement(quesCounter); quizSpace.append(nextQuestion).fadeIn(); if (!(isNaN(selectOptions[quesCounter]))) { $('input[value='+selectOptions[quesCounter]+']').prop('checked', true); } if(quesCounter === 1) { $('#prev').show(); } else if(quesCounter === 0) { $('#prev').hide(); $('#next').show(); } } else { var scoreRslt = displayResult(); quizSpace.append(scoreRslt).fadeIn(); $('#next').hide(); $('#prev').hide(); } }); } function displayResult() { var score = $('<p>',{id: 'question'}); var correct = 0; for (var i = 0; i < selectOptions.length; i++) { if (selectOptions[i] === allQuestions[i].answer) { correct++; } } score.append('Final TOTAL is ' + correct + ' out of ' +allQuestions.length); return score; } })();
  3. That looks nice. I was only able to get the Input. I'm trying, <?php // Get the input string of comma-separated numbers // explode into an array and trim off any spaces $input_str = "572, 545, 884, 123, 802, 337, 879, 307, 759, 227, 211, 002, 968, 532, 459, 895, 681, 967, 580, 399, 664, 077, 307, 227, 461, 594, 645, 859, 484, 827, 618, 675, 302, 246, 007, 842, 471, 006, 161, 171"; $input_arr = array_map('trim', explode(',', $input_str)); // now split each number into a 3-element array // and store in $input foreach ($input_arr as $n) { $input[] = str_split($n, 1); } // get the counts in each position $freqs = array_fill_keys(range(0,9), [0,0,0]); for ($pos=0; $pos<3; $pos++) { $digits = array_column($input, $pos); $occurs = array_count_values($digits); foreach ($occurs as $n => $tot) { $freqs[$n][$pos] += $tot; } } ?> <html> <head> <title>Digit Frequency Box</title> </head> <body> <!-- INPUT Table --> <table border="1" width="30%"> <tr><p><b>Input</b></p> <td bgcolor="#F5F5DC"><span style="font-family: verdana,arial,helvetica; font-size: 14px; font-weight: color: #000000;"><?php echo "$input_str"; ?></span></td> </tr> </table> <!-- Digit Frequencies Table --> <table border="1"> <tr><p><b>Digit Frequencies</b></p> <tr><td bgcolor="#00994c"><span style="font-family: verdana,arial,helvetica; font-size: 14px; font-weight: bold; color: #ffffff;">DIGIT</span></td><td bgcolor="#00994c"><span style="font-family: verdana,arial,helvetica; font-size: 14px; font-weight: bold; color: #ffffff;">P1</span></td><td bgcolor="#00994c"><span style="font-family: verdana,arial,helvetica; font-size: 14px; font-weight: bold; color: #ffffff;">P2</span></td><td bgcolor="#00994c"><span style="font-family: verdana,arial,helvetica; font-size: 14px; font-weight: bold; color: #ffffff;">P3</span></td><td bgcolor="#00994c">&nbsp;</td><td bgcolor="#00994c"><span style="font-family: verdana,arial,helvetica; font-size: 14px; font-weight: bold; color: #ffffff;">DIGIT TOTALS</span></td></tr> <tr><td><b>0</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;=</td><td>&nbsp;</td></tr> <tr><td><b>1</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;=</td><td>&nbsp;</td></tr> <tr><td><b>2</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;=</td><td>&nbsp;</td></tr> <tr><td><b>3</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;=</td><td>&nbsp;</td></tr> <tr><td><b>4</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;=</td><td>&nbsp;</td></tr> <tr><td><b>5</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;=</td><td>&nbsp;</td></tr> <tr><td><b>6</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;=</td><td>&nbsp;</td></tr> <tr><td><b>7</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;=</td><td>&nbsp;</td></tr> <tr><td><b>8</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;=</td><td>&nbsp;</td></tr> <tr><td><b>9</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;=</td><td>&nbsp;</td></tr> </table> <div>&nbsp;</div> <!-- FINAL DIGIT :: DISTRIBUTION LINE Table --> <table border="1"> <tr><p><b>DISTRIBUTION LINE</b></p> <td bgcolor="#F5F5DC">&nbsp; <b>?</b> - <b>?</b> - <b>?</b> - <b>?</b> - <b>?</b> - <b>?</b> - <b>?</b> - <b>?</b> - <b>?</b> - <b>?</b> &nbsp;</td> </tr> </table> </body> </html> but I still have no idea how to grab and insert the individual digit data and put it inside PHP echo statements so they appear on the table columns.
  4. Hi Barand. So like this .. but how do I get 3-digit numbers inside the array to work <?php // display count to values $input = []; for ($i=0; $i<5; $i++) { $input[] = str_split(sprintf('%03d',mt_rand(1,999)), 1); } $p1 = array_column($input, 0); $p2 = array_column($input, 1); $p3 = array_column($input, 2); $arr = array(912,296,325,249,125,530); $result = array_count_values($arr); echo "DIGIT FREQUENCY RESULTS ..<br><br>"; for ($d=0; $d<10; $d++) { echo "{$d}s : " . ($result[$d] ?? 0) . '<br>'; } ?> <html> <body> <div>&nbsp;</div> <div> * Need to find out how to count 3-digit number strings inside an array. It currently counts single digits only. </div> </body> </html>
  5. Please see the attached file for what I am trying to accomplish. This PHP code is what I have so far .. <?php // display count to values $arr = array('9','2','3','2','1','5'); $result = array_count_values($arr); echo "DIGIT FREQUENCY RESULTS ..<br><br> 0s: $result[0]<br> 1s: $result[1]<br> 2s: $result[2]<br> 3s: $result[3]<br> 4s: $result[4]<br> 5s: $result[5]<br> 6s: $result[6]<br> 7s: $result[7]<br> 8s: $result[8]<br> 9s: $result[9]"; ?> <html> <body> <div>&nbsp;</div> <div> * Need to find out how to count 3-digit number strings inside an array. It currently counts single digits only. </div> </body> </html>
  6. Barand. You are the man. You have outdone yourself again. That's exactly what I was trying to code. Thank you so much. 😁 Now I need to dive in this code and learn exactly where everything goes and why it works. gw1500se your advice is appreciated as well. My head is upside down right now I think I need to take a break and step away from the code for a while before I return to it.
  7. I don't need a break tag, I just need to give the output some spacing. Also, lets forget about the actual color appearing on the browser. I'm not concerned with that part. I only need help with the PHP code that provides the actual words either "Black" or "Red" to appear beside each number. (Even numbers are BLACK and odd numbers are RED) I can't seem to figure out why it will not work. πŸ™
  8. <?php error_reporting(0); $position1 = $_POST['p1']; $position2 = $_POST['p2']; $position3 = $_POST['p3']; $position4 = $_POST['p4']; $position5 = $_POST['p5']; if ($_POST['clear']) { $position1=""; $position2=""; $position3=""; $position4=""; $position5=""; $message1=""; $message2=""; $message3=""; $message4=""; $message5=""; } if ($_POST['send']) { $message1 = "P1:" ."\r\n" .$position1; // to create space we typed in ."\r\n" $message2 = "P2:" ."\r\n" .$position2; $message3 = "P3:" ."\r\n" .$position3; $message4 = "P4:" ."\r\n" .$position4; $message5 = "P5:" ."\r\n" .$position5; } ?> </div> <!-- START :: Input Form --> <div align="center"> <form action = "" method = "POST"> <body> <table border="0"> <tr> <td> P1: </td> <td> <input type = text name = p1 value = "<?php echo $position1;?>" size="2" autofocus></td> <td> P2: </td> <td> <input type = text name = p2 value = "<?php echo $position2;?>" size="2"></td> <td> P3: </td> <td> <input type = text name = p3 value = "<?php echo $position3;?>" size="2"></td> <td> P4: </td> <td> <input type = text name = p4 value = "<?php echo $position4;?>" size="2"></td> <td> P5: </td> <td> <input type = text name = p5 value = "<?php echo $position5;?>" size="2"></td> <tr> <td colspan="10">&nbsp;</td> </tr> <tr> <td colspan="10" align="center"> <p> <input type = "submit" name="send" value = "GET POSITION COLORS" title="Click here to display color values."> <input type = "submit" name="clear" value = "RESET" title="Click here to clear text boxes."> </p> <?php echo "<br><br>"; echo "<font face='arial' size='4'>"; echo $message1 ."\r\n" .$color1; $color1 = $_REQUEST['$position1']; if ($position1 == "2,4,6,8,10") echo "Black"; elseif ($position1 == "1,3,5,7,9") echo "Red"; else echo "This number is not in game range."; echo "<br>"; echo $message2 ."\r\n" .$color2; $color2 = $_REQUEST['$position2']; if ($position2 == "2,4,6,8,10") echo "Black"; elseif ($position2 == "1,3,5,7,9") echo "Red"; else echo "This number is not in game range."; echo "<br>"; echo $message3 ."\r\n" .$color3; $color3 = $_REQUEST['$position3']; if ($position3 == "2,4,6,8,10") echo "Black"; elseif ($position3 == "1,3,5,7,9") echo "Red"; else echo "This number is not in game range."; echo "<br>"; echo $message4 ."\r\n" .$color4; $color4 = $_REQUEST['$position4']; if ($position4 == "2,4,6,8,10") echo "Black"; elseif ($position4 == "1,3,5,7,9") echo "Red"; else echo "This number is not in game range."; echo "<br>"; echo $message5 ."\r\n" .$color5; $color5 = $_REQUEST['$position5']; if ($position5 == "2,4,6,8,10") echo "Black"; elseif ($position5 == "1,3,5,7,9") echo "Red"; else echo "This number is not in game range."; echo "</font>"; ?> </td> </tr> </table> </form> </div> <!-- END :: Input Form --> </body> </html>
  9. I am working on a form that takes in 5 numbers as INPUT (the number range is from 1 to 10). Then, the OUTPUT will display the 5 numbers entered with their associated color. I am having problems getting the color value to show on the browser. Can someone please help as to what I am doing wrong? Below is the code I have so far. <?php error_reporting(0); $position1 = $_POST['p1']; $position2 = $_POST['p2']; $position3 = $_POST['p3']; $position4 = $_POST['p4']; $position5 = $_POST['p5']; if ($_POST['clear']) { $position1=""; $position2=""; $position3=""; $position4=""; $position5=""; $message1=""; $message2=""; $message3=""; $message4=""; $message5=""; } if ($_POST['send']) { $message1 = "P1:" ."\r\n" .$position1 ."\r\n" .$color1; // to create space we typed in ."\r\n" $message2 = "P2:" ."\r\n" .$position2 ."\r\n" .$color2; $message3 = "P3:" ."\r\n" .$position3 ."\r\n" .$color3; $message4 = "P4:" ."\r\n" .$position4 ."\r\n" .$color4; $message5 = "P5:" ."\r\n" .$position5 ."\r\n" .$color5; $color1 = $position1; if ($position1 == "2,4,6,8,10") echo "Black"; elseif ($position1 == "1,3,5,7,9") echo "Red"; else echo "Number entered is not in game range."; $color2 = $position2; if ($position2 == "2,4,6,8,10") echo "Black"; elseif ($position2 == "1,3,5,7,9") echo "Red"; else echo "Number entered is not in game range."; $color3 = $position3; if ($position3 == "2,4,6,8,10") echo "Black"; elseif ($position3 == "1,3,5,7,9") echo "Red"; else echo "Number entered is not in game range."; $color4 = $position4; if ($position4 == "2,4,6,8,10") echo "Black"; elseif ($position4 == "1,3,5,7,9") echo "Red"; else echo "Number entered is not in game range."; $color5 = $position5; if ($position5 == "2,4,6,8,10") echo "Black"; elseif ($position5 == "1,3,5,7,9") echo "Red"; else echo "Number entered is not in game range."; } ?> </div> <!-- START :: Input Form --> <div align="center"> <form action = "" method = "POST"> <body> <table border="0"> <tr> <td> P1: </td> <td> <input type = text name = p1 value = "<?php echo $position1;?>" size="2" autofocus></td> <td> P2: </td> <td> <input type = text name = p2 value = "<?php echo $position2;?>" size="2"></td> <td> P3: </td> <td> <input type = text name = p3 value = "<?php echo $position3;?>" size="2"></td> <td> P4: </td> <td> <input type = text name = p4 value = "<?php echo $position4;?>" size="2"></td> <td> P5: </td> <td> <input type = text name = p5 value = "<?php echo $position5;?>" size="2"></td> <tr> <td colspan="10">&nbsp;</td> </tr> <tr> <td colspan="10" align="center"> <input type = "submit" name="send" value = "GET POSITION COLORS" title="Click here to display color values."> <input type = "submit" name="clear" value = "RESET" title="Click here to clear text boxes."> <?php echo "<br><br>"; echo "<font face='arial' size='4'>"; echo $message1; echo "<br>"; echo $message2; echo "<br>"; echo $message3; echo "<br>"; echo $message4; echo "<br>"; echo $message5; echo "</font>"; ?> </td> </tr> </table> </form> </div> <!-- END :: Input Form --> </body> </html> ----- EOF ----
  10. I am trying to get this form to submit, but it doesn't go anywhere. I checked the browser console and I see "Failed to load resource: the server responded with a status of 500 (Internal Server Error)". Can someone help me resolve this error? CODE: <html> <head> <title>PICK 5 :: 13 Ticket System (3 of 5 WHEEL)</title> <style> .wrap{ text-align:center; width:900px; margin: 0 auto; } .row{ margin: 18px 0; } .input{ border:1px solid #ccc; width:800px; float:left; margin:10px; } .output{ width:700px; margin:0 auto; text-align:left; } .output .str{ } .output .number{ font-weight:bold; margin-right:5px; } .clear{ clear:both; } </style> </head> <body bgcolor="#F5F5F5"> <div class="wrap"> <form method="post" action=""> <div class="row"><p><span style="font-weight: bold; color: #0000FF;">PICK 5 :: 13 Ticket System (3 of 5 WHEEL)</span></p> <p>(Guaranteed <span style="font-weight: bold; color: #0080ff;">3-WIN</span>, if 5 of the numbers drawn are in your set of 15 numbers)</p> <label>Please enter 15 numbers and separate them with a comma ","<br></label> <input type="text" name="num" value="<?= isset($_POST['num'])?$_POST['num']:'1,2,3,4,5,6,7,8,9,10,11,12,13,14,15' ?>" /> </div> <div class="row"><input type="submit" name="submit" value="Go" /> </div><br> <?php if(isset($_POST['submit'])){ $num = $_POST['num']; $num_array = explode(',',$num); $alpha_array = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'); $array1 = array(); for($i=0; $i<15; $i++) { $array1[$alpha_array[$i]] = trim($num_array[$i]); } $array2 = array( array('A', 'B', 'C', 'L', 'M'), // Start 15# (3if5 Wheel) - 13 Lines array('A', 'B', 'D', 'H', 'I'), // Where .. (A1, B2, C3, D4, E5, F6, G7, H8, I9, J10, K11, L12, M13, N14, O15) array('A', 'C', 'G', 'H', 'O'), array('A', 'E', 'K', 'N', 'O'), array('A', 'F', 'G', 'J', 'L'), // LINE 5 array('B', 'D', 'F', 'L', 'O'), array('B', 'E', 'F', 'G', 'I'), array('B', 'H', 'J', 'K', 'N'), array('C', 'D', 'E', 'F', 'J'), array('C', 'I', 'K', 'L', 'N'), // LINE 10 array('D', 'G', 'K', 'M', 'N'), array('E', 'F', 'H', 'L', 'M'), array('F', 'I', 'J', 'M', 'O'), // LINE 13 ); $data = ""; foreach($array2 as $arr){ $data1 = ""; foreach($arr as $a){ $data1 .= $array1[$a] . ', '; } $data[] = rtrim($data1,', '); } ?> <div class="output"> <?php foreach($data as $k=>$v){ echo '<span class="number">'.($k+1) . '.</span><span class="str">' . $v . '</span><br>'; } } ?> </div> <div class="clear"></div> </form> </div> </body> </html>
  11. Barand that's exactly what I needed. Thank you for pointing that reference point again.
  12. Thank you for your help and suggestions, as always requinix. πŸ™‚ I think I am also going to look into >> array_diff($a, $b),
  13. Hello group. I need some help with my code. <?php $a1 = array("line1"=>"1-2-3-10-14","line2"=>"1-2-3-10-34","line3"=>"1-2-7-16-35","line4"=>"1-2-3-17-19","line5"=>"2-5-11-15-32"); $a2 = array("inputnumber"=>"1-2-3-10-34"); $result = array_intersect($a1,$a2); print_r($result); ?> Right now, I can only search and find an exact match of all 5-Numbers. I want to code a PHP form that will take a (5-number string) as input and then compare that string against an array database of (5-number strings) to find all matching number occurrences for each β€œLINE 1 thru LINE 5”. For instance, if I were to type the 5-number string β€œ1-2-3-10-34” as input. The Output populated results would look like this ..
×
×
  • 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.