Jump to content

OldGrim

Members
  • Posts

    34
  • Joined

  • Last visited

About OldGrim

  • Birthday 11/03/1949

Contact Methods

  • Website URL
    https://fortworthbonsai.org

Profile Information

  • Gender
    Male
  • Location
    Ft. Worth, Texas
  • Interests
    Computing, RC models, oil painting, music, graphic art, guitar and keyboard playing.
  • Age
    71

OldGrim's Achievements

Member

Member (2/5)

0

Reputation

2

Community Answers

  1. Well HALLELUJAH !!!!!!!!! That works perfectly Barand. Thank you so much; I am very grateful. Now I can continue to write the other script to determine the winners. Of course all of this won't take place live until the actual Super Bowl.
  2. OK I'll try it Barand. But I'm just about ready to give it up for now. I even went so far as to convert my tables to use InnoDB engine and added indexes but everything went South on me in a hurry. I have another db set up with all original files so I'll experiment with that one and try your suggestion. Thanks for all your time and help Barand I really appreciate it.
  3. This is my table creation and the first 20 rows of data. Too long to show all 100 rows. CREATE TABLE `VNSB21_squares_matrix` ( `SQUARE` varchar(2) NOT NULL DEFAULT '', `NAME` varchar(25) NOT NULL DEFAULT 'AVAILABLE', `NFC` tinyint(1) UNSIGNED DEFAULT '0', `AFC` tinyint(1) UNSIGNED DEFAULT '0' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='SB Squares Matrix'; -- -- Dumping data for table `VNSB21_squares_matrix` -- INSERT INTO `VNSB21_squares_matrix` (`SQUARE`, `NAME`, `NFC`, `AFC`) VALUES ('00', 'ChuckY', 0, 0), ('01', 'ChuckY', 0, 0), ('02', 'ChuckY', 0, 0), ('03', 'ChuckY', 0, 0), ('04', 'ChuckY', 0, 0), ('05', 'ChuckY', 0, 0), ('06', 'Roger S', 0, 0), ('07', 'FredB', 0, 0), ('08', 'FredB', 0, 0), ('09', 'FredB', 0, 0), ('10', 'ChuckY', 0, 0), ('11', 'Jimmy G', 0, 0), ('12', 'Jimmy G', 0, 0), ('13', 'Jimmy G', 0, 0), ('14', 'Jimmy G', 0, 0), ('15', 'Jimmy G', 0, 0), ('16', 'FredB', 0, 0), ('17', 'Roger S', 0, 0), ('18', 'Roger S', 0, 0), ('19', 'FredB', 0, 0), etc etc etc to 99
  4. Here is the url if you care to see the live system: https://www.shade-treecoder.net/sb2/index.php
  5. Well it certainly is different now; but still not correct: This is the numbers table and then the squares_matrix table. NFC AFC 3 3 8 6 5 5 7 9 6 7 4 8 9 4 1 2 2 0 0 1 SQUARE NAME NFC AFC 00 ChuckY NULL NULL 01 ChuckY 3 NULL 02 ChuckY 8 NULL 03 ChuckY 5 NULL 04 ChuckY 7 NULL 05 ChuckY 6 NULL 06 Roger S 4 NULL 07 FredB 9 NULL 08 FredB 1 NULL 09 FredB 2 NULL 10 ChuckY NULL 3 11 Jimmy G 3 3 12 Jimmy G 8 3 13 Jimmy G 5 3 14 Jimmy G 7 3 15 Jimmy G 6 3 16 FredB 4 3 17 Roger S 9 3 18 Roger S 1 3 19 FredB 2 3 20 ChuckY NULL 6 21 JamesB 3 6 22 JamesB 8 6 23 JamesB 5 6 24 JamesB 7 6 25 Jimmy G 6 6 26 Roger S 4 6 27 FredB 9 6 28 FredB 1 6 29 Roger S 2 6 30 ChuckY NULL 5 31 Jimmy G 3 5 32 Jimmy G 8 5 33 Jimmy G 5 5 34 Jimmy G 7 5 35 FredB 6 5 36 PepperJ 4 5 37 PepperJ 9 5 38 PepperJ 1 5 39 PepperJ 2 5 40 ChuckY NULL 9 41 JamesB 3 9 42 JamesB 8 9 43 JamesB 5 9 44 JamesB 7 9 45 FredB 6 9 46 AliceK 4 9 47 PepperJ 9 9 48 PepperJ 1 9 49 PepperJ 2 9 50 JackB NULL 7 51 JackB 3 7 52 SuzieQ 8 7 53 SuzieQ 5 7 54 Roger S 7 7 55 FredB 6 7 56 AliceK 4 7 57 PepperJ 9 7 58 PepperJ 1 7 59 PepperJ 2 7 60 JackB NULL 8 61 JackB 3 8 62 AliceK 8 8 63 AliceK 5 8 64 Roger S 7 8 65 JamesB 6 8 66 JamesB 4 8 67 SuzieQ 9 8 68 SuzieQ 1 8 69 SuzieQ 2 8 70 JackB NULL 4 71 JackB 3 4 72 AliceK 8 4 73 AliceK 5 4 74 Roger S 7 4 75 SuzieQ 6 4 76 SuzieQ 4 4 77 SuzieQ 9 4 78 SuzieQ 1 4 79 SuzieQ 2 4 80 JackB NULL 2 81 JackB 3 2 82 AliceK 8 2 83 AliceK 5 2 84 Roger S 7 2 85 Sean P 6 2 86 Sean P 4 2 87 Sean P 9 2 88 Sean P 1 2 89 Sean P 2 2 90 JackB NULL 0 91 JackB 3 0 92 AliceK 8 0 93 AliceK 5 0 94 Roger S 7 0 95 Sean P 6 0 96 Sean P 4 0 97 Sean P 9 0 98 Sean P 1 0 99 Sean P 2 0 Copied directly from phpMyAdmin. This is what it should be. Only the first 20 squares: SQUARE NAME NFC AFC 00 ChuckY 3 3 01 ChuckY 8 3 02 ChuckY 5 3 03 ChuckY 7 3 04 ChuckY 6 3 05 ChuckY 4 3 06 Roger S 9 3 07 FredB 1 3 08 FredB 2 3 09 FredB 0 3 10 ChuckY 3 6 11 Jimmy G 8 6 12 Jimmy G 5 6 13 Jimmy G 7 6 14 Jimmy G 6 6 15 Jimmy G 4 6 16 FredB 9 6 17 Roger S 1 6 18 Roger S 2 6 19 FredB 0 6
  6. OK I'm going to try one more time. // save to database if (isset($RANDOM)) { for ($n=1; $n<=10; $n++) { $query="INSERT INTO VNSB21_numbers (NFC, AFC) VALUES ('".$NFC[$n]."','".$AFC[$n]."')"; $result = mysqli_query($connection, $query); if (!$result) { echo mysqli_error($connection); echo "<p>PROBLEM WRITING TO NUMBERS TABLE!</p>"; exit; } } // My new squares_matrix table number entries for ($i=0; $i<100; $i++) { $a = $AFC[intdiv($i, 10)]; $n = $NFC[$i%10]; $query="UPDATE VNSB21_squares_matrix SET NFC='".$n."',AFC='".$a."'"; $result = mysqli_query($connection, $query); if (!$result) { echo mysqli_error($connection); echo "<p>PROBLEM WRITING TO MATRIX TABLE!</p>"; exit; } } } // end squares_matrix number entries The first code sequence correctly generates the random numbers table. But the second code sequence writes 4, 0 into the NFC, AFC fields in all 100 records of the squares_matrix table. I don't understand how to code the for loop and further how to actually do the update table to get the desired results.
  7. OK thanks for more input Psycho. I see the need here for further explanation and some code from the actual scripts. People can buy from 1 to 10 squares at a time. Here is the code that writes the info into the squares table and my added code to save the buyers name(s) into the squares table and my added squares_matrix table. This is not the entire script but the relevant parts. //continue only if the square is available if ($record['DATE'] == "0000-00-00 00:00:00") { //check for required fields for ($i=1;$i<=$sqTotal;$i++) { if (($sqSelect[$i] >= 00 OR $sqSelect[$i] < 100) AND $name != '' AND $email != '') { $query="UPDATE VNSB21_squares SET NAME='".$name."', EMAIL='".$email."', NOTES='".$notes."', DATE='".$date."', CONFIRM='".$confirm."' WHERE SQUARE='".$sqSelect[$i]."' LIMIT 1"; $result = mysqli_query($connection, $query); if (!$result) { echo mysqli_error(); echo "<BR>Sorry, Technical problem occurred... your selection was not added.<br><br> Email this problem to <a href=\"mailto:".$ADMIN_EMAIL."\">".$ADMIN_EMAIL."</a>"; exit; } } else { echo "<p align='center'><br/><font color='#ff0000', size='3'>Required fields are missing!</font><br/><br/><a href='javascript:onClick=history.go(-1);'>Back</a></p>"; exit; } } // update my matrix table with buyers name(s) for ($i=1;$i<=$sqTotal;$i++) { if (($sqSelect[$i] >= 00 OR $sqSelect[$i] < 100) AND $name != '') { $query="UPDATE VNSB21_squares_matrix SET NAME='".$name."' WHERE SQUARE='".$sqSelect[$i]."' LIMIT 1"; $result = mysqli_query($connection, $query); if (!$result) { echo mysqli_error(); echo "<BR>Sorry, Technical problem occurred... your selection was not added."; exit; } } else { echo ""; exit; } } // end update matrix table This gets executed several times by the administrator until all the squares are filled. Only then can the numbers table be generated by the following code. At the end is my attempt to add the numbers to the matrix table. It actually writes numbers but not the correct ones so I know I'm not doing it right. //show table for review echo "<table width=\"95%\" border=\"1\" cellspacing=\"1\" cellpadding=\"5\" style=\"font-family: Verdana,Ariel; font-size: 10px\"> <tr> <td style=\"border-top: none; border-left: none\">&nbsp;</td>"; for ($i=1; $i<=10; $i++) { echo "<td align=\"center\">".$NFC_TEAM."&nbsp;<font size=\"3\" color=\"blue\"><strong>".$NFC[$i]."</strong></font></td>"; } echo " </tr> <tr>"; $query="SELECT * FROM VNSB21_squares ORDER BY SQUARE"; $result = mysqli_query($connection, $query); if (!$result) { echo mysqli_error($connection); exit; } $cnt_row = 0; $i=0; while ($record = mysqli_fetch_assoc($result)) { if ($cnt_row==0) { $i++; echo "<td align='center'> $AFC_TEAM<br/><font size='3' color=\"red\"><strong>".$AFC[$i]."</strong></font></td>"; } if ($record['NAME'] == "AVAILABLE") { echo "<td width='10%' title='only $".$BET."'><a href=\"signup.php?square=".$record['SQUARE']."\">".stripslashes($record['NAME'])."<br/>".$record['SQUARE']."</a></td>"; } else if ($record['NAME']!="AVAILABLE" && $record['CONFIRM']==1) { echo "<td width='10%' bgcolor='#99ff66' align='center' title=\"".$record['NOTES']."\"><strong>".stripslashes($record['NAME'])."</strong><br/>Confirmed</td>"; } else { echo "<td width='10%' bgcolor='#ff9966' align='center' title=\"".$record['NOTES']."\"><strong>".stripslashes($record['NAME'])."</strong><br/>Pending</td>"; } $cnt_row++; if ($cnt_row==10) { $cnt_row=0; echo "</tr><tr>"; } } echo "</table>"; } else { ?> <form action="" method="post"> <input type="submit" name="randomnumber" value="Random" title="Auto select numbers randomly"></input> </form> <?php } // save to database if (isset($RANDOM)) { for ($n=1; $n<=10; $n++) { $query="INSERT INTO VNSB21_numbers (NFC, AFC) VALUES ('".$NFC[$n]."','".$AFC[$n]."')"; $result = mysqli_query($connection, $query); if (!$result) { echo mysqli_error($connection); echo "<p>PROBLEM WRITING TO NUMBERS TABLE!</p>"; exit; } // My new squares_matrix table number entries for ($i=0; $i<100; $i++) { $a = $AFC[intdiv($i, 10)]; $b = $NFC[$i%10]; $query="UPDATE VNSB21_squares_matrix SET NFC='".$b."',AFC='".$a."'"; $result = mysqli_query($connection, $query); if (!$result) { echo mysqli_error($connection); echo "<p>PROBLEM WRITING TO MATRIX TABLE!</p>"; exit; } } // end squares_matrix number entries
  8. Ummm... not quite. You see once the users buy all 100 squares the code we already have in place generates the random numbers table. That is working fine. Then from that point forward the numbers table and the squares table are static as the numbers are fixed/added to the squares table. As the squares are bought my matrix table adds the users name to the square(s) bought. That is fine and works great. I need to add code (array/arrays) to add those numbers to the matrix table. Looking at the images it should be obvious that row one which is squares 00 thru 09 have an AFC number of 6 (repeated for all 10 squares) and NFC numbers from the numbers table. The second row which is squares 10 thru 19 would have an AFC number of 0 for those 10 squares and the NFC numbers would be just a repeat of the previous NFC numbers. Each block of 10 squares 00 thru 99 all have the same set of AFC numbers (from the numbers table) with the NFC number varying according to the numbers table. I was hoping my image was clear enough.
  9. I am trying to help a friend with his football pool system. First an image and then the explanation: The numbers table holds random numbers, 10 under NFC and 10 under AFC. The numbers are generated after all 100 squares are filled in the squares table and are applied to the squares table as shown in the middle image. The Matrix table is for the 100 squares holding the square number, buyer name and the numbers matrix that I am trying to build. As you can see the NFC numbers are applied to all 100 squares repeating every 10 rows. The AFC numbers are the crux of the matter here. For every 10 rows the AFC number is the same and then advances to the next AFC number. I've never tried to explain anything like this before and I hope it makes sense. I'm trying to figure out how to construct the arrays(array) needed to insert these numbers into the matrix table for later processing to determine the winners.
  10. Point taken. Thanks for explanation.
  11. As a final remark I would like to say that after reading through thousands of posts on this forum over the years, that there are many users that use many different CMS systems and I've never seen anyone get denied help just because of their system in use. Most of the time when given suggestions or sample code I am able to modify it to fit within my particular system parameters. So I am sorry Barand that you feel that way.
  12. Well, OK I guess. I converted my topics table to use InnoDB instead of MyISAM; so I guess I'll proceed from there and seek help elsewhere. Thanks for all your help in the past Barand.
  13. OK I have tried every way I can think of to make this work but it gives errors. [08-May-2021 07:16:17 America/Chicago] PHP Parse error: syntax error, unexpected 'function' (T_FUNCTION) in /home/whisperw/blog.whisperwillow.net/grims_blog/include/latest_topics.php on line 18 I tried the function in an external file to no avail. Here is what I have now: <?php echo "<div class='col-sm-12'>\n"; echo "<table width='100%' border='0'><tr><td><span class='hdspan2'><b>".$locale['gb_810']."</b></span></td></tr></table>\n"; echo "<table align='center' width='80%' border='0'><tr><td>\n"; $result = dbquery("SELECT topic_id, topic_title, topic_parentid FROM ".DB_GRIMS_BLOG_TOPICS.""); while (list($topic_id, $topic_title, $topic_parentid) = dbrows($result) { $data[$topic_parentid][] = array('id'=>$topic_id, 'name'=>$topic_title) } /** * recursive function to print a category then its child categories * * @param array $arr category data * @param int $topic_parentid parent category * @param int $level hierarchy level */ function displayHierarchy(&$arr, $topic_parentid, $level=0) { if (isset($arr[$topic_parentid])) { echo "<ul class='ul$level'>\n"; foreach($arr[$topic_parentid] as $rec) { echo "<li class='li$level'>{$rec['name']}\n"; if (isset($arr[$rec['id']])) displayHierarchy($arr, $rec['id'], $level+1); echo "</li>\n"; } echo "</ul>\n"; } } displayHierarchy($data, 0); echo "</td></tr></table><p></div>\n"; ?> BTW in case you haven't really noticed our CMS has built-in core DB functions already defined such as dbquery, dbarray, dbrows etc etc etc.
  14. OK thanks. I have to go to work now but will apply the changes tonight and report back on the results.
  15. Well that's fine and dandy but! What is this? | 10 | Cat 1 1 1 | 4 | I don't understand what the 1 1 1 is after Cat.
×
×
  • 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.