{"id":57643,"date":"2022-11-28T03:01:35","date_gmt":"2022-11-27T17:01:35","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=57643"},"modified":"2022-11-27T18:04:57","modified_gmt":"2022-11-27T08:04:57","slug":"ajax-php-your-games-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/ajax-php-your-games-tutorial\/","title":{"rendered":"Ajax PHP Your Games Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Ajax PHP Your Games Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/ajax_php_example_yours.jpg\" title=\"Ajax PHP Your Games Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Ajax PHP Your Games Tutorial<\/p><\/div>\n<p>Progressing past yesterday&#8217;s <a title='Ajax PHP Games Tutorial' href='#aphpgt'>Ajax PHP Games Tutorial<\/a>&#8216;s &#8230;<\/p>\n<ul>\n<li>hardcoded game mode to dropdown multiple choice (but static list) game mode list &#8230; and today &#8230;<\/li>\n<li>we add on a dropdown option &#8220;Your own &#8230;&#8221; where a user can enter &#8230;\n<ol>\n<li>URL containing regularised &#8220;list of&#8221; hyperlink content &#8230; and perhaps &#8230;<\/li>\n<li>specify an &#8220;a&#8221; href determining HTML snippet delimitation<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p> &#8230; the dropdown &#8220;onchange&#8221; Javascript logic <font color=blue>changing this way<\/font> &#8230;<\/p>\n<p><code><br \/>\n<font color=blue>var proposedu='';<\/font><br \/>\n<br \/>\nfunction selvalit(selo) {<br \/>\n  <font color=blue>proposedu='';<\/font><br \/>\n  document.getElementById('fname').value='';<br \/>\n  document.getElementById('txtHint').innerHTML='';<br \/>\n  if (selo.value.trim() == '') {<br \/>\n    <font color=blue>if (selo.value != '') {<br \/>\n      proposedu=prompt('Please enter a \"List of\" type of URL eg. http:\/\/en.wikipedia.org\/wiki\/List_of_rivers', '');<br \/>\n      if (proposedu == null) { proposedu=''; }<br \/>\n      selval='&' + proposedu.split('\/')[eval(-1 + proposedu.split('\/').length)].split('?')[0].split('#')[0].replace(\/\\ \/g,'_').replace('List_of_','') + '=' + encodeURIComponent(proposedu) + '&delim=' + encodeURIComponent('&lt;li&gt;&lt;a href=\"\/wiki\/');<br \/>\n      document.getElementById('stopics').innerHTML+='&lt;option value=\"' + proposedu.split('\/')[eval(-1 + proposedu.split('\/').length)].split('?')[0].split('#')[0].replace(\/\\ \/g,'_').replace('List_of_','') + '\" data-selval=\"' + selval + '\"&gt;' + proposedu.split('\/')[eval(-1 + proposedu.split('\/').length)].split('?')[0].split('#')[0].replace(\/\\ \/g,'_').replace('List_of_','').replace(\/\\_\/g,' ').substring(0,1).toUpperCase() + proposedu.split('\/')[eval(-1 + proposedu.split('\/').length)].split('?')[0].split('#')[0].replace(\/\\ \/g,'_').replace('List_of_','').replace(\/\\_\/g,' ').substring(1) + '&lt;\/option&gt;';<br \/>\n      document.getElementById('stopics').value=proposedu.split('\/')[eval(-1 + proposedu.split('\/').length)].split('?')[0].split('#')[0].replace(\/\\ \/g,'_').replace('List_of_','');<br \/>\n      getdelim(proposedu);<br \/>\n    }<br \/>\n    if (proposedu == '') {<br \/>\n      selval=selo.value.trim();<br \/>\n    }<br \/>\n  } else if (document.getElementById('stopics').innerHTML.indexOf(' value=\"' + selo.value.trim() + '\" data-selval=\"') != -1) {<br \/>\n    selval=document.getElementById('stopics').innerHTML.split(' value=\"' + selo.value.trim() + '\" data-selval=\"')[1].split('\"')[0];<br \/>\n    proposedu=decodeURIComponent(selval.substring(1).split('=')[1].split('&')[0]);<br \/>\n    getdelim(proposedu);<\/font><br \/>\n  } else {<br \/>\n    selval='&' + selo.value.trim() + '=';<br \/>\n  }<br \/>\n  document.getElementById('fname').focus();<br \/>\n}<br \/>\n<\/code><\/p>\n<p> &#8230; and in the helping PHP snippet <font color=blue>it changed this way handling the array $a<\/font> below &#8230;<\/p>\n<p>&lt;?php<br \/>\n<code><br \/>\n$c=[];<br \/>\n<br \/>\n\/\/ Start of \/usr\/share\/dict\/propernames intervention<br \/>\nif (isset($_GET['capitals'])) {<br \/>\n$a=[];<br \/>\n$c=[];<br \/>\n$cont=file_get_contents('http:\/\/en.wikipedia.org\/wiki\/List_of_national_capitals');<br \/>\n$tableih=explode(\"&lt;tbody\", explode(\"&lt;\/table&gt;\", $cont)[1])[1];<br \/>\n\/\/file_put_contents('za.za','is ' . '&lt;td&gt;&lt;a href=\"\/wiki\/ in ' . $tableih);<br \/>\n$capitals=explode('&lt;td&gt;&lt;a href=\"\/wiki\/', $tableih);<br \/>\nfor ($ii=1; $ii&lt;sizeof($capitals); $ii++) {<br \/>\n  if (strpos($capitals[$ii], '&lt;a href=\"\/wiki\/') !== false) {<br \/>\n  array_push($a, str_replace('+',' ',urldecode(explode('\"', $capitals[$ii])[0])) . ' (' . str_replace('+',' ',urldecode(explode('\"', explode('&lt;a href=\"\/wiki\/', $capitals[$ii])[1])[0])) . ')');<br \/>\n  }<br \/>\n}<br \/>\n\/\/sort($a);<br \/>\n} else if (isset($_GET['hobbies'])) {<br \/>\n$a=[];<br \/>\n$c=[];<br \/>\n$cont=file_get_contents('http:\/\/en.wikipedia.org\/wiki\/List_of_hobbies');<br \/>\n$hobbies=explode('&lt;li&gt;&lt;a href=\"\/wiki\/', $cont);<br \/>\nfor ($ii=1; $ii&lt;sizeof($hobbies); $ii++) {<br \/>\n  array_push($a, str_replace('+',' ',str_replace('_',' ',urldecode(explode('\"', $hobbies[$ii])[0]))));<br \/>\n}<br \/>\nsort($a);<br \/>\n} else if (isset($_GET['fruits'])) {<br \/>\n$a=[];<br \/>\n$c=[];<br \/>\n$cont=file_get_contents('http:\/\/simple.wikipedia.org\/wiki\/List_of_fruits');<br \/>\n$fruits=explode('&lt;li&gt;&lt;a href=\"\/wiki\/', $cont);<br \/>\nfor ($ii=1; $ii&lt;sizeof($fruits); $ii++) {<br \/>\n  array_push($a, str_replace('+',' ',str_replace('_',' ',urldecode(explode('\"', $fruits[$ii])[0]))));<br \/>\n}<br \/>\nsort($a);<br \/>\n} else if (isset($_GET['vegetables'])) {<br \/>\n$a=[];<br \/>\n$c=[];<br \/>\n$cont=file_get_contents('http:\/\/simple.wikipedia.org\/wiki\/List_of_vegetables');<br \/>\n$vegetables=explode('&lt;li&gt;&lt;a href=\"\/wiki\/', $cont);<br \/>\nfor ($ii=1; $ii&lt;sizeof($vegetables); $ii++) {<br \/>\n  array_push($a, str_replace('+',' ',str_replace('_',' ',urldecode(explode('\"', $vegetables[$ii])[0]))));<br \/>\n}<br \/>\nsort($a);<br \/>\n} else <font color=blue>if (strpos(('' . $_SERVER['QUERY_STRING']), '&') === false)<\/font> {<br \/>\n\/\/ With \/usr\/share\/dict\/propernames intervention ...<br \/>\n$moren=explode(\"\\n\", file_get_contents('\/usr\/share\/dict\/propernames'));<br \/>\nfor ($ii=0; $ii&lt;sizeof($moren); $ii++) {<br \/>\n   if (!in_array($moren[$ii], $a)) { array_push($a, $moren[$ii]); }<br \/>\n}<br \/>\nsort($a);<br \/>\n} <font color=blue>else {<br \/>\n$concept=explode('=', explode('&', str_replace('&delim=','#delim=',('' . $_SERVER['QUERY_STRING'])))[1])[0];<br \/>\n$url='HTTP:' . str_replace('http:','',str_replace('https:','',str_replace('+',' ',urldecode(explode('#', explode('&', explode('=', explode('&', ('' . $_SERVER['QUERY_STRING']))[1])[1])[0])[0]))) );<br \/>\n$delimidea='&lt;li&gt;&lt;a href=\"\/wiki\/';<br \/>\n$minidelim='\"';<br \/>\n$spacesub='_';<br \/>\n$plusbit='';<br \/>\nif (isset($_GET['delim'])) {<br \/>\n$delimidea=str_replace('+',' ',urldecode($_GET['delim']));<br \/>\nif (strpos(str_replace(' ','',strtolower($delimidea)), \" href='\") !== false) {<br \/>\n$minidelim=\"'\";<br \/>\n} else if (strpos(str_replace(' ','',strtolower($delimidea)), ' href=\"') === false && strpos(str_replace(' ','',strtolower($delimidea)), ' href=') !== false) {<br \/>\n$minidelim=\" \";<br \/>\n}<br \/>\n}<br \/>\nif (strpos(strtolower($url), 'wikipedia.') === false) {<br \/>\n$spacesub=\"%20\";<br \/>\n}<br \/>\nif (strpos($delimidea, (' href=' . trim($minidelim))) !== false) {<br \/>\n  $plusbit=trim(explode((' href=' . trim($minidelim)), $delimidea)[1]);<br \/>\n  if (substr(($plusbit . '  '),0,2) != '\/\/' && substr(($plusbit . '  '),0,1) == '\/') {<br \/>\n  if (strpos($url, $plusbit) !== false) { $upre=explode($plusbit, $url)[0] . $plusbit;  $plusbit=$upre;  }<br \/>\n  } else if (substr(($plusbit . '  '),0,2) != '..' && substr(($plusbit . '  '),0,1) == '.') {<br \/>\n  if (strpos($url, $plusbit) !== false) {<br \/>\n    $upre=explode($plusbit, $url)[0];  $plusbit=$upre . $plusbit;<br \/>\n  } else if (strpos($url, substr($plusbit,1)) !== false) {<br \/>\n    $upre=explode(substr($plusbit,1), $url)[0];  $plusbit=$upre . substr($plusbit,1);<br \/>\n  }<br \/>\n  } else if (substr(($plusbit . '  '),0,2) == '..') {<br \/>\n  if (strpos($url, $plusbit) !== false) {<br \/>\n    $upre=explode($plusbit, $url)[0];  $plusbit=$upre . $plusbit;<br \/>\n  } else if (strpos($url, substr($plusbit,2)) !== false) {<br \/>\n    $upre=explode(substr($plusbit,2), $url)[0];  $plusbit=$upre . substr($plusbit,2);<br \/>\n  }<br \/>\n  } else if (substr(($plusbit . '  '),0,2) == '\/\/') {<br \/>\n  $plusbit='http:' . $plusbit;<br \/>\n  } else if (strtolower(substr(($plusbit . '          '),0,5)) == 'http:') {<br \/>\n  $plusbit='http:' . substr($plusbit,5);<br \/>\n  } else if (strtolower(substr(($plusbit . '          '),0,6)) == 'https:') {<br \/>\n  $plusbit='http:' . substr($plusbit,6);<br \/>\n  } else if (substr(($plusbit . '    '),0,4) == 'www.') {<br \/>\n  $plusbit='http:\/\/' . $plusbit;<br \/>\n  }<br \/>\n}<br \/>\n$a=[];<br \/>\n$c=[];<br \/>\n$origplusbit=$plusbit;<br \/>\n$cont=file_get_contents($url);<br \/>\n$things=explode($delimidea, $cont);<br \/>\nfor ($ii=1; $ii&lt;sizeof($things); $ii++) {<br \/>\n  $plusbit=$origplusbit;<br \/>\n  if ($plusbit !== '') {<br \/>\n    $plusbit=' ' . str_replace(' ','_','(' . $origplusbit . explode('&gt;', explode($minidelim, $things[$ii])[0])[0] . ')');<br \/>\n  }<br \/>\n  array_push($a, str_replace('List of ','',explode('#', explode('&', explode('?', explode(\"\/\", str_replace('+',' ',str_replace($spacesub,' ',urldecode(explode('&gt;', explode($minidelim, $things[$ii])[0])[0]))))[-1 + sizeof(explode(\"\/\", str_replace('+',' ',str_replace($spacesub,' ',urldecode(explode('&gt;', explode($minidelim, $things[$ii])[0])[0])))))])[0])[0])[0]) . $plusbit);<br \/>\n}<br \/>\nsort($a);<br \/>\n}<\/font><br \/>\n\/\/ ... end of \/usr\/share\/dict\/propernames intervention<br \/>\n<\/code><br \/>\n?&gt;<\/p>\n<p> &#8230; whereby relative URLs can be mapped to absolute ones in these personalization based modifications in <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html--GETME\" title=''>the extended<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html--GETME\" title=''>third draft<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html\"><font size=1>(now yet more than)<\/font> Firstname Game<\/a> web application calling on <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/gethint.php--GETME\" title=''>the extended<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/gethint.php--GETME\" title=''>gethint.php<\/a> helper.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/ajax-php-your-games-tutorial\/'>Ajax PHP Your Games Tutorial<\/a>.<\/p-->\n<hr>\n<p id='aphpgt'>Previous relevant <a target=_blank title='Ajax PHP Games Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/ajax-php-games-tutorial\/'>Ajax PHP Games Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Ajax PHP Games Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/ajax_php_wikipedia.jpg\" title=\"Ajax PHP Games Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Ajax PHP Games Tutorial<\/p><\/div>\n<p>Once you have a good web application &#8220;basis for design&#8221; it&#8217;s pretty inevitable that to extend that web application is pretty easy to do.  This was definitely the case, working off the start yesterday&#8217;s <a title='Ajax PHP Firstname Game Primer Tutorial' href='#aphpfgpt'>Ajax PHP Firstname Game Primer Tutorial<\/a> gave us.<\/p>\n<p>The PHP organizes data.  The HTML and Javascript supervisor calls the PHP and displays the data.<\/p>\n<p>The HTML and Javascript supervisor starts the day with a hardcoding &#8220;First name&#8221;.  We add to the functionality by turning that &#8220;First name&#8221; into a dropdown (ie. select) element with a first option of &#8220;First name&#8221;, and subsequent (non default) options titling other <i>sub-games<\/i> of the web application, today being &#8230;<\/p>\n<p><select size=5 data-onchange=selvalit(this); style=display:inline-block;><option value=''>First name<\/option><option value='capitals'>National capital<\/option><option value='hobbies'>Hobby<\/option><option value='fruits'>Fruit<\/option><option value='vegetables'>Vegetable<\/option><\/select><\/p>\n<p>Why these <i>sub-options<\/i>?  We found good publicly available data sources for <i>Lists<sub>_<\/sub>of<sub>_<\/i> these topics on <a target=_blank title=Wikipedia href=hpps:\/\/wikipedia.org>Wikipedia<\/a>.  As ever, thanks!<\/p>\n<p>Please try <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html-GETME\" title=''>the extended<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html-GETME\" title=''>second draft<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html\"><font size=1>(now more than)<\/font> Firstname Game<\/a> web application.<\/p>\n<p>The rest of the changes, with PHP logic, in <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/gethint.php-GETME\" title=''>the extended<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/gethint.php-GETME\" title=''>gethint.php<\/a>, is sometimes referred to as &#8220;data scraping&#8221;, form extensions to the functionality of the web application.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/ajax-php-games-tutorial\/'>Ajax PHP Games Tutorial<\/a>.<\/p-->\n<hr>\n<p id='aphpfgpt'>Previous relevant <a target=_blank title='Ajax PHP Firstname Game Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/ajax-php-firstname-game-primer-tutorial\/'>Ajax PHP Firstname Game Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Ajax PHP Firstname Game Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/name_meaning.jpg\" title=\"Ajax PHP Firstname Game Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Ajax PHP Firstname Game Primer Tutorial<\/p><\/div>\n<p>The combination of &#8230;<\/p>\n<ul>\n<li>HTML and Javascript client supervisor &#8230; using &#8230;<\/li>\n<li><a target=_blank title='Ajax information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Ajax_%28programming%29'>Ajax<\/a> logic &#8230; calling on &#8230;<\/li>\n<li>PHP data helperer outerer<\/li>\n<\/ul>\n<p> &#8230; are W3School<sub>s<\/sub> enthusiasms we wholeheartedly agree with regarding <a target=_blank title='https:\/\/www.w3schools.com\/xml\/ajax_php.asp' href='https:\/\/www.w3schools.com\/xml\/ajax_php.asp'>AJAX PHP Example<\/a>.  And thanks to <a target=_blank title='https:\/\/www.w3schools.com\/' href='https:\/\/www.w3schools.com\/'>W3Schools<\/a> for some excellent code basis for a Firstname Game today.  We add some niceties to the HTML and Javascript, adding in a dropdown option for the names which, if used, takes the user to a public <a target=_blank data-href='http:\/\/www.names.org\/' href='http:\/\/www.behindthename.com' title='Search for your favorite name'>Search for your favorite name<\/a> website, thanks, that can add to the background information on the name chosen.<\/p>\n<p>And as far as the <i>PHP data helperer outerer<\/i> goes, we just add more names to the array list already there via a lookup of Linux or macOS &#8220;read of&#8221; &#8230;<\/p>\n<p><code><br \/>\n\/usr\/share\/dict\/propernames<br \/>\n<\/code><\/p>\n<p> &#8230; via the additions to PHP $a array &#8230;<\/p>\n<p>&lt;?php<br \/>\n<code><br \/>\n\/\/ With \/usr\/share\/dict\/propernames intervention ...<br \/>\n$moren=explode(\"\\n\", file_get_contents('\/usr\/share\/dict\/propernames'));<br \/>\nfor ($ii=0; $ii&lt;sizeof($moren); $ii++) {<br \/>\n   if (!in_array($moren[$ii], $a)) { array_push($a, $moren[$ii]); }<br \/>\n}<br \/>\nsort($a);<br \/>\n\/\/ ... end of \/usr\/share\/dict\/propernames intervention<br \/>\n<\/code><br \/>\n?&gt;<\/p>\n<p> &#8230; you might recall us talking about with <a title='First Name Guessing Game for Two Primer Tutorial' href='#fnggtpt'>First Name Guessing Game for Two Primer Tutorial<\/a> in times past.<\/p>\n<p>The whole effect is very <a target=_blank title='Autocompletion information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Autocomplete'>&#8220;autocomplete&#8221;<\/a><sub>y<\/sub>, am sure you&#8217;d agree, using HTML and Javascript <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html_GETME\" title=''>proof of concept and first draft<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html\">Firstname Game<\/a> web application that calls on PHP <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/gethint.php_GETME\" title=\"gethint.php\">gethint.php<\/a> helperer outerer, you can also try below &#8230;<\/p>\n<p><iframe src='http:\/\/www.rjmprogramming.com.au\/ajax_php_example.html' style='width:100%;height:800px;'><\/iframe><\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/ajax-php-first-name-game-primer-tutorial\/'>Ajax PHP First Name Game Primer Tutorial<\/a>.<\/p-->\n<hr>\n<p id='fnggtpt'>Previous relevant <a target=_blank title='First Name Guessing Game for Two Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/first-name-guessing-game-for-two-primer-tutorial\/'>First Name Guessing Game for Two Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/nameguessgame.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"First Name Guessing Game for Two Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/nameguessgame.jpg\" title=\"First Name Guessing Game for Two Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">First Name Guessing Game for Two Primer Tutorial<\/p><\/div>\n<p>It may not be immediately imaginable what would be the synergies between today&#8217;s proposed &#8220;First Name Guessing Game for Two&#8221; and <a title='Word Guessing Game for Two Primer Tutorial' href='#wggtpt'>Word Guessing Game for Two Primer Tutorial<\/a>&#8216;s &#8220;Word Guessing Game for Two&#8221;.  Other than that a First Name is a Word, isn&#8217;t there too much difference here to clone the &#8220;Word Guessing Game for Two&#8221; into a new &#8220;First Name Guessing Game for Two&#8221; when even dictionaries usually do not venture into the world of First Names, so much a product of our culture and history?  But, believe it or not these two games are so alike that, apart from tweaks to prompt wordings and message wordings, all that is needed to succeed after the cloning is to make the middle<strike>man<\/strike>person surprise.php get called for Linux (or Mac OS X FreeBSD) dictionary file usage such that instead of accessing a dictionary file called &#8230;<\/p>\n<p><code><br \/>\n\/usr\/share\/dict\/words<br \/>\n<\/code><\/p>\n<p> &#8230; that contains a list of singular, in our case, English, words to access, for the purposes of our new &#8220;First Name Guessing Game for Two&#8221; the dictionary file &#8230;<\/p>\n<p><code><br \/>\n\/usr\/share\/dict\/propernames<br \/>\n<\/code><\/p>\n<p> &#8230; cute,huh?!  But a big ask for a complete list of First Names around the world!  Nevertheless, it is good to have this list for our game today, and some other ideas that you can think of, am sure.  Maybe, a basis in letters for part of a password idea, for example.  Seeing this same dictionary file on both Mac OS X and Linux was an encouraging sign of support from the operating systems here.<\/p>\n<p>The event and organizational side of the web application is just as described for <a title='Word Guessing Game for Two Primer Tutorial' href='#wggtpt'>Word Guessing Game for Two Primer Tutorial<\/a> below.  We just call surprise.php with an extra &#8230;<\/p>\n<p><code><br \/>\n&amp;firstname=y<br \/>\n<\/code><\/p>\n<p> &#8230; within its URL.  Also, references to the online <a target=_blank href=\"http:\/\/www.thefreedictionary.com\/\">English<\/a> dictionary become a bit inapplicable, but we substitute in, here, on these <i>a<\/i> links, use of the excellent <a target=_blank title='Behind the Name' href='http:\/\/www.behindthename.com\/'>Behind the Name<\/a> website, thanks.<\/p>\n<p>So here&#8217;s a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/nameguessgame.html\" title='Click picture'>live run<\/a> and here is the HTML programming source code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/nameguessgame.html-GETME\" title=\"nameguessgame.html\">nameguessgame.html<\/a> which <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/nameguessgame.html-GETME\" title=\"nameguessgame.html\">got created via these cloning changes<\/a>.<\/p>\n<p>You can also see this play out at WordPress 4.1.1&#8217;s <a target=_blank  href='https:\/\/www.rjmprogramming.com.au\/ITblog\/first-name-guessing-game-for-two-primer-tutorial\/'>First Name Guessing Game for Two Primer Tutorial<\/a>.<\/p>\n<hr>\n<p id='wggtpt'>Previous relevant <a target=_blank title='Word Guessing Game for Two Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/word-guessing-game-for-two-primer-tutorial\/'>Word Guessing Game for Two Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/wordguessgame.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Word Guessing Game for Two Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/wordguessgame.jpg\" title=\"Word Guessing Game for Two Primer Tutorial\" \/><\/a><p class=\"wp-caption-text\">Word Guessing Game for Two Primer Tutorial<\/p><\/div>\n<p>Word Games help vocabulary for <a target=_blank title='English as a second or foreign language' href='https:\/\/en.wikipedia.org\/wiki\/English_as_a_second_or_foreign_language'>ESL<\/a> students.  There is also not much doubt that collaboration can help ESL students, who also learn quicker with other students present.<\/p>\n<p>Today we create a web application Word Guessing Game designed for two.  Not two devices, the one device for two users (hovering over it).  So for &#8230;<\/p>\n<ul>\n<li>non-mobile users can play the game with one user using the mouse and the other using the keyboard<\/li>\n<li>mobile users can play with one user using touch on the blue areas of the web application and the other using touch on other places<\/li>\n<\/ul>\n<p>The events we code for are &#8230;<\/p>\n<ul>\n<li><a target=_blank title='Javascript onclick event information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/event_onclick.asp'>onclick<\/a>  &#8230; will be recognised on non-mobile platforms<\/li>\n<li><a target=_blank title='Javascript ontouchstart event information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/dom_obj_event.asp'>ontouchstart<\/a>  &#8230; will be recognised on mobile platforms (where it will supercede any onlick event)<\/li>\n<li><a target=_blank title='Javascript onkeyup event information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/event_onkeyup.asp'>onkeyup<\/a> &#8230;  will be recognised on non-mobile platforms<\/li>\n<\/ul>\n<p> &#8230; so you can see that the colour coding of the webpage becomes important for the mobile platform usage.<\/p>\n<p>Today&#8217;s game tests English vocabulary skills.  Why just English?   Well, it uses English words, based on the dictionary arrangements at its (web) server, which happens to be based on English.<\/p>\n<p>Programmers often use <a target_blank title='Words (unix) information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Words_%28Unix%29'>Linux dictionary files<\/a> as a means to get a word list, and that list could be in any language, and for ours it is English.<\/p>\n<p>Here&#8217;s a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/wordguessgame.html\" title='Click picture'>live run<\/a> and here is the HTML programming source code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/wordguessgame.html_GETME\" title=\"wordguessgame.html\">wordguessgame.html<\/a> which, again, uses some PHP we&#8217;ve talked about with a lot of our <a target=_blank title='Word Games' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/word-game'>word games<\/a> at this blog, on a &#8220;Client Pre-Emptive Iframe&#8221; scenario in a couple of HTML iframe elements we include into today&#8217;s game.  We thank this free online <a target=_blank href=\"http:\/\/www.thefreedictionary.com\/\">English<\/a> dictionary that gets called on if the user chooses to.<\/p>\n<p>We hope you try it, and like it.  By the way, you can also play the game as a single user.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d17485' onclick='var dv=document.getElementById(\"d17485\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=SQL\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d17485' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d36912' onclick='var dv=document.getElementById(\"d36912\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/linux\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d36912' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d57625' onclick='var dv=document.getElementById(\"d57625\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/autocompletion\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d57625' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d57635' onclick='var dv=document.getElementById(\"d57635\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/wikipedia\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d57635' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d57643' onclick='var dv=document.getElementById(\"d57643\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/personalization\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d57643' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Progressing past yesterday&#8217;s Ajax PHP Games Tutorial&#8216;s &#8230; hardcoded game mode to dropdown multiple choice (but static list) game mode list &#8230; and today &#8230; we add on a dropdown option &#8220;Your own &#8230;&#8221; where a user can enter &#8230; &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/ajax-php-your-games-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,12,14,37],"tags":[4162,52,69,2129,2125,1695,4117,212,3570,2463,318,367,476,3362,576,609,652,2505,919,932,997,1045,1866,1122,1675,1319,1345,3048,1431],"class_list":["post-57643","post","type-post","status-publish","format-standard","hentry","category-ajax","category-elearning","category-event-driven-programming","category-tutorials","tag-absolue","tag-absolute-url","tag-ajax","tag-architecture","tag-autocomplete","tag-autocompletion","tag-backward-compatibility","tag-client","tag-data-scraping","tag-default","tag-design","tag-dropdown","tag-game","tag-hardcoding","tag-html","tag-input","tag-javascript","tag-name","tag-personalization","tag-php","tag-programming","tag-relative-url","tag-select","tag-server","tag-textbox","tag-tutorial","tag-url","tag-w3schools","tag-wikipedia"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/57643"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=57643"}],"version-history":[{"count":3,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/57643\/revisions"}],"predecessor-version":[{"id":57646,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/57643\/revisions\/57646"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=57643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=57643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=57643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}