Jump to content

aja

Members
  • Posts

    2
  • Joined

  • Last visited

aja's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. thanks, calvin182... sorry if you spent that much time on it. The reason I posted it was hoping someone could just dash it off. I guess the tutorial should have said something more like: If you check the link, it was part of a tutorial on AJAX at the w3schools.com site. Sometimes it seems a little odd to me that they post so many of the server-side examples in ASP when you consider that more people and servers use PHP than ASP, but I guess that's just what the authors use most themselves.Anyhow, your version works a lot better than the one I posted, thanks. It still has a couple of minor errors that keep it from working like the ASP version, but it inspired me to go back and finish debugging my own.
  2. Am trying the W3S's AJAX tute, which uses an ASP script, and says "It could easily be rewritten in PHP, or some other server language." I'd like to finish this, but my PHP script's still not working, although it's probably 90% functional. Can anyone help get it up and running?Here's the source page:http://www.w3schools.com/ajax/ajax_source.aspThe script is called "gethint.asp." and is in the 3rd CODE section, under the Head "The AJAX Server Page."Here's my PHP version so far: <?php$a = array();$a[1] = "Anna";$a[2] = "Brittany";$a[3] = "Cinderella";$a[4] = "Diana";$a[5] = "Eva";$a[6] = "Fiona";$a[7] = "Gunda";$a[8] = "Hege";$a[9] = "Inga";$a[10] = "Johanna";$a[11] = "Kitty";$a[12] = "Linda";$a[13] = "Nina";$a[14] = "Ophelia";$a[15] = "Petunia";$a[16] = "Amanda";$a[17] = "Raquel";$a[18] = "Cindy";$a[19] = "Doris";$a[20] = "Eve";$a[21] = "Evita";$a[22] = "Sunniva";$a[23] = "Tove";$a[24] = "Unni";$a[25] = "Violet";$a[26] = "Liza";$a[27] = "Elizabeth";$a[28] = "Ellen";$a[29] = "Wenche";$a[30] = "Vicky";$q = strtoupper($_GET("q"));if ( strlen($q) > 0) { $hint = ""; for ($i = 1; $i <= 30; $i++) { if ($q = strtoupper( substr( a[$i], 1, strlen($q))) { if ($hint = "" ) { $hint = $a[i]; } else { $hint = $hint . " , " . $a[i]; } } }}}if ($hint = "") { echo "no suggestion";}else { echo $hint;}?> Some probable problems are 1. I'm unsure if ECHO's the right way to output the response.2. Number of braces -- didn't check these yet, may be off.Any help would be appreciated, thx.
×
×
  • Create New...