Jump to content

Caitlin-havener

Members
  • Content count

    282
  • Joined

  • Last visited

Community Reputation

3 Neutral

About Caitlin-havener

  • Rank
    Member
  • Birthday 09/04/1988

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Gender
    Male
  • Location
    Orlando, FL
  • Interests
    Web programming, graphic design

Previous Fields

  • Languages
    html, css, javascript
  1. Hey there! I'm trying to read in a csv and split the data at commas unless the string is encapsulated between double quotes. How would I do this? I know the function, its just the regular expression that confuses me!
  2. rename function file not found!

    Text file attached. Current code, below. Some files were renamed, others disappeared into the twilight zone. <?php$file=fopen("img/emvivacesupplemental2012/filelist.txt","r");$workingDir=getcwd();$directory= "\\img\\emvivacesupplemental2012\\450pxw\\";$newDirectory="\\img\\emvivacesupplemental2012\\gallery\\";$allFiles[][]= array();while (!feof($file)){$fileLine=trim(fgets($file));var_dump(scandir($workingDir.$directory));//echo $workingDir.$directory.$fileLine." is...<br/>"; //var_dump(file_exists($workingDir.$directory.$fileLine)); for($i=1000;$i<=9999;$i++) { //if first four characters if ($i==substr($fileLine,0,4)) { $allFiles[$i][]=$fileLine; foreach ($allFiles as $v1) { foreach ($v1 as $key => $v2) { rename($workingDir.$directory.$fileLine, $workingDir.$newDirectory.$i."_gallery_".$key.".jpg"); } } } else if ($i==substr($fileLine,1,4)) { $firstChar=substr($fileLine,0,1); $allFiles[$firstChar.$i][]=$fileLine; foreach ($allFiles as $v1) { foreach ($v1 as $key => $v2) { rename($workingDir.$directory.$fileLine, $workingDir.$newDirectory.$firstChar.$i."_gallery_".$key.".jpg"); } } } else if ($i==substr($fileLine,2,4)) { $allFiles[$i][]=$fileLine; foreach ($allFiles as $v1) { foreach ($v1 as $key => $v2) { rename($workingDir.$directory.$fileLine, $workingDir.$newDirectory.$i."_gallery_".$key.".jpg"); } } } else if ($i==substr($fileLine,3,4)) { $firstChar=substr($fileLine,2,1); $allFiles[$i][]=$fileLine; foreach ($allFiles as $v1) { foreach ($v1 as $key => $v2) { rename($workingDir.$directory.$fileLine, $workingDir.$newDirectory.$firstChar.$i."_gallery_".$key.".jpg"); } } } }}//print_r($allFiles);fclose($file);?> filelist.txt
  3. rename function file not found!

    I've already made the gallery folder... next... lol. Still errors mehh
  4. rename function file not found!

    Kay im still getting this error with and without the working directory specified: Warning: rename(C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8518_b.jpg,C:\wamp\www\alluringassets\img\emvivacesupplemental2012\gallery\8518_gallery_0.jpg) [function.rename]: The system cannot find the file specified. (code: 2) in C:\wamp\www\alluringassets\renamegalleryimgs.php on line 20 while (!feof($file)){$fileLine=trim(fgets($file)); for($i=1000;$i<=9999;$i++) { //if first four characters if ($i==substr($fileLine,0,4)) { $allFiles[$i][]=$fileLine; foreach ($allFiles as $v1) { foreach ($v1 as $key => $v2) { rename($workingDir.$directory.$fileLine, $workingDir.$newDirectory.$i."_gallery_".$key.".jpg"); } } }
  5. rename function file not found!

    Someone else helped me on facebook. I actually had to use trim function ! Will let you know if I have trouble with this next part shortly
  6. rename function file not found!

    It's yielding all 1's!! Do I still need to change permissions??
  7. rename function file not found!

    Forget those if statements for a moment. This is what I need to figure out. The following code is echoing does not exist for all the files. I need to first have them echoing that they do exist. $file=fopen("img/emvivacesupplemental2012/filelist.txt","r");$workingDir=getcwd(); $directory= "\\img\\emvivacesupplemental2012\\450pxw\\";$newDirectory="/img/emvivacesupplemental2012/gallery/"; $allFiles[][]= array(); while (!feof($file)){$fileLine=$workingDir.$directory.fgets($file);if (file_exists($fileLine)){ echo ($fileLine . "exists <br/>");}else{ echo ($fileLine. "does NOT exist </br>");}}?> Example of response: C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8518_b.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8518_f.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8551_b.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8551_f.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8653_b.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8653_f.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8654_b.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8654_f.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8655_b.jpg does NOT exist Those are the exact paths! I've also tried it without the working directory preceding it. Which would then read "\img\emvivacesupplemental\450pxw\8518_b.jpg does NOT exist!" I've also tried forward slashes instead of backslashes. All echo "does not exist".
  8. rename function file not found!

    I'm working on wamp local server trying to rename some files with the following code: <?php$file=fopen("img/emvivacesupplemental2012/filelist.txt","r");$workingDir=getcwd(); $directory= "\\img\\emvivacesupplemental2012\\450pxw\\";$newDirectory="/img/emvivacesupplemental2012/gallery/"; $allFiles[][]= array(); while (!feof($file)){/*$fileLine=$workingDir.$directory.fgets($file);if (file_exists($fileLine)){ echo ($fileLine . "exists <br/>");}else{ echo ($fileLine. "does NOT exist </br>");}*/ for($i=1000;$i<=9999;$i++) { //if first four characters if ($i==substr($fileLine,0,4)) { $allFiles[$i][]=$fileLine; foreach ($allFiles as $v1) { foreach ($v1 as $key => $v2) { rename($directory.$fileLine, $newDirectory.$i."_gallery_".$key.".jpg"); } } } else if ($i==substr($fileLine,1,4)) { $firstChar=substr($fileLine,0,1); $allFiles[$firstChar.$i][]=$fileLine; foreach ($allFiles as $v1) { foreach ($v1 as $key => $v2) { rename($directory.$fileLine, $newDirectory.$firstChar.$i."_gallery_".$key.".jpg"); } } } else if ($i==substr($fileLine,2,4)) { $allFiles[$i][]=$fileLine; foreach ($allFiles as $v1) { foreach ($v1 as $key => $v2) { rename($directory.$fileLine, $newDirectory.$i."_gallery_".$key.".jpg"); } } } else if ($i==substr($fileLine,3,4)) { $firstChar=substr($fileLine,2,1); $allFiles[$i][]=$fileLine; foreach ($allFiles as $v1) { foreach ($v1 as $key => $v2) { rename($directory.$fileLine, $newDirectory.$firstChar.$i."_gallery_".$key.".jpg"); } } } }}print_r($allFiles);fclose($file);?> I ran file_exists function on each line and nothing I do is yielding a boolean yes. I've tried preceding with the working directory, both forward and backslashes.. the images ARE in the right directory. Copied straight from properties of one of the images : C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw
  9. See: http://sulley.dm.ucf...nt2/viewer.html user enters a search term, then click submit. It should open the php file via the javascript click function which performs a cURL response then returns the JSON object to the javascript to parse. Right now im just trying to get the JSON object printed to the console in the javascript function. Can anyone see the issue? in developer tools the network response shows the JSON object but its not printing to console. html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>DIG4503 – Caitlin Havener Assignment 2</title><link rel="stylesheet" type="text/css" href="css/reset.css" /><link rel="stylesheet" type="text/css" href="css/styles.css" /><script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script type="text/javascript" src="js/a2.js"></script></head><body><div id="wrapper"> <div id="header"> <img src="#" alt=""/> <h1>A Case of the "Mondays"</h1> </div> <div id="content"> <div id="search"> <input type="text" id="searchText" /> <div id="submit"><h2>Submit</h2></div> </div> <div id="thumbs"> </div> <div id="specific"> </div> </div> <div id="footer"> <h1>Designed by Caitlin Havener with Flickr API, cURL, jQuery, XHTML</h1> </div> </div></body></html> javascript: // JavaScript Document$(document).ready(function(){$("#submit").click(function(e){ e.preventDefault(); var txt=$("#searchText").val(); $.ajax( { url:'getThumbs.php', data: 'text=' + txt, type: 'POST', dataType:'json', success:function(data) { //parse console.log('success'); console.log(data); //object is in 'result' //append responseXML (json) to #thumbs //parse the json object and output images with jquery }, failure: function(){ console.log('failure') }});});}); php: <?phpini_set('display_errors', 'on');/*should contain a PHP script that performs a cURL request for datafrom Flickr using the flickr.photos.search REST API and should return an XMLresponse.*/$ch = curl_init();$txt= $_POST['text'];$url = 'http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=ccb29e24bac7fd677e1e1ba0a4ae84fa&text=' . $txt . '&content_type=1&media=photos&per_page=40&format=json';curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_URL, $url);$curl_response = curl_exec($ch);curl_close($ch); //$rsp_obj = unserialize($curl_response);echo($curl_response); /*getThumbs.php should loop through the XML response and output a set of <img />elements that contain thumbnail URLs as the src attribute and the photo_id as the altattribute of each image ONLY for images that were taken on a Monday.*/ ?>
  10. flickr api

    When the user visits viewer.html, they should be prompted to enter a search term. Oncethey have entered the term and hit the submit button, an XHR request for getThumbs.phpshould occur that performs a cURL request of the Flickr API that returns 40 results forphotos that match the search term entered by the user as XML.-­‐ That XML response should be parsed using one of the following methods: OUTPUT 1 – XML to PHPo getThumbs.php should loop through the XML response and output a set of <img />elements that contain thumbnail URLs as the src attribute and the photo_id as the altattribute of each image ONLY for images that were taken on a Monday. OUTPUT 2 – XML from PHPo getThumbs.php should return an XML object to a2.js, and a2.js should loop throughthe XML response and dynamically generate a set of <img /> elements that containthumbnail URLs as the src attribute and the photo_id as the alt attribute of eachimage ONLY for images that were taken on a Monday. Main page (when you click submit loads the php file): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>DIG4503 – Caitlin Havener Assignment 2</title><link rel="stylesheet" type="text/css" href="css/reset.css" /><link rel="stylesheet" type="text/css" href="css/styles.css" /><script type="text/javascript" src="js/a2.js"></script><script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script type="text/javascript">window.onload = function (){ var submitClicked = document.getElementById("submit"); submitClicked.addEventListener('click', function(e) { e.preventDefault(); var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { console.log("Ive loaded"); document.getElementById("thumbs").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getThumbs.php",true); xmlhttp.send(); }, false);} </script></head><body><div id="wrapper"> <div id="header"> <img src="#" alt=""/> <h1>A Case of the "Mondays"</h1> </div> <div id="content"> <div id="search"> <form name=myForm><input type="text" value="search" /></form> <input type="submit" value="Submit" id="submit"/> </div> <div id="thumbs"> </div> <div id="specific"> </div> </div> <div id="footer"> <h1>Designed by Caitlin Havener with Flickr API, cURL, jQuery, XHTML</h1> </div> </div></body></html> The php file that is loaded when submit is clicked: <?php/*should contain a PHP script that performs a cURL request for datafrom Flickr using the flickr.photos.search REST API and should return an XMLresponse.*/print "hey";$ch = curl_init();$url = ' http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=686c634ab46cfad9ea78f85912d7bc0e&text=%24searchText&content_type=1&media=photos&per_page=40&format=rest&api_sig=6c762eab06cf258c37735f5bc90a03fb';curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_URL, $url);$curl_response = curl_exec($ch);curl_close($ch);print "the response: " . $curl_response; /*$params = array('api_key' => '5aa2e3914789e3d69c436425697af6fb','method' => 'flickr.photosets.getPhotos',//'photoset_id' =>'extras' => 'original_format','format'=> 'php_serial');$encoded_params = array();foreach($params as $k => $v){$encoded_params[] = urlencode($k).'=' .urlencode($v);}*/?> The professor's powerpoint had the above code (in php file) that is not commented out. But I saw a tutorial with the commented out code (incomplete). How do I use this darn flickr.photosets.getPhotos and retrieve its xml??
  11. reference only

    <?phpsession_start();error_reporting(0);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Caitlin's Acey Ducey</title><link rel="stylesheet" type="text/css" href="style.css" /></head><body><div class="roundedBox"><div class="top"><div class="bottom"><div class="left"><div class="right"><div class="topLeft"><div class="topRight"><div class="bottomLeft"><div class="bottomRight"><div class="boxContent"><div id="content"><form method='post'><?php$nextaction = isset($_POST['dowhat']) ? $_POST['dowhat'] : '';/************ SCORING SYSTEM */if (empty($_SESSION)){$_SESSION['potscore']=200; //$potscore= $_SESSION['potscore'];$_SESSION['blackscore']=900; //$blackscore=$_SESSION['blackscore'];$_SESSION['goldscore']=900; //$goldscore= $_SESSION['goldscore'];//var_dump($_SESSION);}function maxcard_displayfunc(){//var_dump($_SESSION); $highcard=$_SESSION['maxcardsess']; switch ($highcard) { case 1: return $maxcard_display="<img class='card_display' src='images/A.jpg' alt=' ' />"; break; case 2: return $maxcard_display="<img class='card_display' src='images/2.jpg' alt=' ' />"; break; case 3: return $maxcard_display="<img class='card_display' src='images/3.jpg' alt=' ' />"; break; case 4: return $maxcard_display="<img class='card_display' src='images/4.jpg' alt=' ' />"; break; case 5: return $maxcard_display="<img class='card_display' src='images/5.jpg' alt=' ' />"; break; case 6: return $maxcard_display="<img class='card_display' src='images/6.jpg' alt=' ' />"; break; case 7: return $maxcard_display="<img class='card_display' src='images/7.jpg' alt=' ' />"; break; case 8: return $maxcard_display="<img class='card_display' src='images/8.jpg' alt=' ' />"; break; case 9: return $maxcard_display="<img class='card_display' src='images/9.jpg' alt=' ' />"; break; case 10: return $maxcard_display="<img class='card_display' src='images/10.jpg' alt=' ' />"; break; case 14: return $maxcard_display="<img class='card_display' src='images/A.jpg' alt=' ' />"; break; case 11: return $maxcard_display="<img class='card_display' src='images/J.jpg' alt=' ' />"; break; case 12: return $maxcard_display="<img class='card_display' src='images/Q.jpg' alt=' ' />"; break; case 13: return $maxcard_display="<img class='card_display' src='images/K.jpg' alt=' ' />"; break; default: return $maxcard_display=$highcard; }}function mincard_displayfunc(){// var_dump($_SESSION);$lowcard=$_SESSION['mincardsess'];switch ($lowcard) { case 1: return $mincard_display="<img class='card_display' src='images/A.jpg' alt=' ' />"; break; case 2: return $mincard_display="<img class='card_display' src='images/2.jpg' alt=' ' />"; break; case 3: return $mincard_display="<img class='card_display' src='images/3.jpg' alt=' ' />"; break; case 4: return $mincard_display="<img class='card_display' src='images/4.jpg' alt=' ' />"; break; case 5: return $mincard_display="<img class='card_display' src='images/5.jpg' alt=' ' />"; break; case 6: return $mincard_display="<img class='card_display' src='images/6.jpg' alt=' ' />"; break; case 7: return $mincard_display="<img class='card_display' src='images/7.jpg' alt=' ' />"; break; case 8: return $mincard_display="<img class='card_display' src='images/8.jpg' alt=' ' />"; break; case 9: return $mincard_display="<img class='card_display' src='images/9.jpg' alt=' ' />"; break; case 10: return $mincard_display="<img class='card_display' src='images/10.jpg' alt=' ' />"; break; case 11: return $mincard_display="<img class='card_display' src='images/J.jpg' alt=' ' />"; break; case 12: return $mincard_display="<img class='card_display' src='images/Q.jpg' alt=' ' />"; break; case 13: return $mincard_display="<img class='card_display' src='images/K.jpg' alt=' ' />";; break; case 14: return $mincard_display="<img class='card_display' src='images/A.jpg' alt=' ' />"; break; default: return $mincard_display=$lowcard; }}function wincardfunc($wincard){ switch ($wincard) { case 1: return $wincard_display="<img class='card_display' src='images/A.jpg' alt=' ' />"; break; case 2: return $wincard_display="<img class='card_display' src='images/2.jpg' alt=' ' />"; break; case 3: return $wincard_display="<img class='card_display' src='images/3.jpg' alt=' ' />"; break; case 4: return $wincard_display="<img class='card_display' src='images/4.jpg' alt=' ' />"; break; case 5: return $wincard_display="<img class='card_display' src='images/5.jpg' alt=' ' />"; break; case 6: return $wincard_display="<img class='card_display' src='images/6.jpg' alt=' ' />"; break; case 7: return $wincard_display="<img class='card_display' src='images/7.jpg' alt=' ' />"; break; case 8: return $wincard_display="<img class='card_display' src='images/8.jpg' alt=' ' />"; break; case 9: return $wincard_display="<img class='card_display' src='images/9.jpg' alt=' ' />"; break; case 10: return $wincard_display="<img class='card_display' src='images/10.jpg' alt=' ' />"; break; case 11: return $wincard_display="<img class='card_display' src='images/J.jpg' alt=' ' />"; break; case 12: return $wincard_display="<img class='card_display' src='images/Q.jpg' alt=' ' />"; break; case 13: return $wincard_display="<img class='card_display' src='images/K.jpg' alt=' ' />"; break; case 14: return $wincard_display="<img class='card_display' src='images/A.jpg' alt=' ' />"; break; default: return $wincard_display=$wincard; }}function whosturn(){if(!isset($_SESSION['turnsess']) || $_SESSION['turnsess']=="gold"){ return $_SESSION['turnsess']="black";}else{ return $_SESSION['turnsess']="gold";}}print"<h1 id='header'>Acey-Ducey</h1>";maincontent();/*print "<div class='right_side'><h2>Score:</h2><br/><h3 class='pot'>POT</h3><h3 class='pot'>" .$_SESSION['potscore']. "</h3></br><h3 class='black'>Black</h3><h3 class='black'>" .$_SESSION['blackscore']. "</h3></br><h3 class='gold'>Gold</h3><h3 class='gold'>" .$_SESSION['goldscore']. "</h3></br></div>";*/ function maincontent(){global $nextaction;if (!$nextaction || ($nextaction=="PASS") || ($nextaction=="NEXT DRAW") || ($nextaction=="CLEAR/PLAY AGAIN")){ ################### SCREEN 1################# if($nextaction=="CLEAR/PLAY AGAIN"){ $_SESSION['potscore']=200; $_SESSION['blackscore']=900; $_SESSION['goldscore']=900; } $target1=rand(2,14); $target2=rand(2,14); //$wincard=rand(1,14); $maxcard=max($target1,$target2); $mincard=min($target1,$target2); $_SESSION['maxcardsess']=$maxcard; $_SESSION['mincardsess']=$mincard; $maxcard_value=$_SESSION['maxcardsess']; $mincard_value=$_SESSION['mincardsess']; //change the way value is displayed (to look like a card J,K,Q,A) $maxcard_display=maxcard_displayfunc(); $mincard_display=mincard_displayfunc(); //////////////////////////////////////////////////////// // If card is an ace, change value of ace to 1 or 14, // whichever is more favorable to user. //////////////////////////////////////////////////////// if($maxcard_display=="A"){ $othercard=$_SESSION['mincardsess']; if($othercard-1 > 14-$othercard){ $acecard=1; $_SESSION['maxcardsess']=max($othercard,$acecard); $_SESSION['mincardsess']=min($othercard,$acecard); print "</br>Ace will have a value of $acecard, because it favors your bet."; }else{ $acecard=14; $_SESSION['maxcardsess']=max($othercard,$acecard); $_SESSION['mincardsess']=min($othercard,$acecard); print "</br>Ace will have a value of $acecard, because it favors your bet."; } }else if($mincard_display=="A"){ $othercard=$_SESSION['maxcardsess']; if($othercard-1 > 14-$othercard){ $acecard=1; $_SESSION['maxcardsess']=max($othercard,$acecard); $_SESSION['mincardsess']=min($othercard,$acecard); print "</br>Ace will have a value of $acecard, because it favors your bet."; } else{ $acecard=14; $_SESSION['maxcardsess']=max($othercard,$acecard); $_SESSION['mincardsess']=min($othercard,$acecard); print "</br>Ace will have a value of $acecard, because it favors your bet."; }} /// ///////////////////////////////////////////////////// // If cards are too close in value, generate new set //////////////////////////////////////////////////////// if(($maxcard_value-$mincard_value==0) || ($maxcard_value-$mincard_value==1)){ maincontent(); }else{ $turn=whosturn(); print "<div class='right_side'><p>It is <b>$turn</b> team's turn.</p> <br /></div>"; print "<div class='cards'><div class='cardboxes'>high card=<br/>$maxcard_display </div>"; print "<div class='cardboxes'>low card=<br/>$mincard_display</div></div><br /><br />"; print "<div class='input'>Input your bet (with a value of 1 to " .$_SESSION['potscore']. "): <input type='text' name='betvalue'></div>"; print "<div class='buttons'><input type='submit' name='dowhat' value='BET'>"; print "<input type='submit' name='dowhat' value='PASS'>"; print "<input type='submit' name='dowhat' value='CLEAR/PLAY AGAIN'></div>"; print "<div class='right_side'><h2>Score:</h2><br/><h3 class='pot'>POT</h3><h3 class='pot'>" .$_SESSION['potscore']. "</h3></br><h3 class='black'>Black</h3><h3 class='black'>" .$_SESSION['blackscore']. "</h3></br><h3 class='gold'>Gold</h3><h3 class='gold'>" .$_SESSION['goldscore']. "</h3></br></div>"; } }else if ($nextaction=="BET"){ #################### # SCREEN TWO #################### $_SESSION['inputbet']=intval($_POST['betvalue']); $turn=$_SESSION['turnsess']; print "<div class='right_side'><p>It is <b>$turn</b> team's turn.</p> <br /></div>"; $wincard=rand(2,14); $wincard_display=wincardfunc($wincard); $maxcard_display=maxcard_displayfunc(); $mincard_display=mincard_displayfunc(); $maxvalue=$_SESSION['maxcardsess']; $minvalue=$_SESSION['mincardsess']; print "<div class='cards'><div class='cardboxes'>highcard=<br/>$maxcard_display </div>"; print "<div class='cardboxes'>target=<br/>$wincard_display </div>"; print "<div class='cardboxes'>lowcard=<br/>$mincard_display </div></div>"; if (($wincard<$maxvalue) && ($wincard>$minvalue)) { print "<div class='buttons'><br /><br/><p class='bigtext'>You win!</p><br/>"; /**********SCORING SYSTEM*/ $_SESSION["{$turn}score"] += $_SESSION['inputbet']; $_SESSION['potscore'] -= $_SESSION['inputbet']; }else{ print "<div class='buttons'><br /><br/><p class='bigtext'>You lose!</p><br/>"; /**********SCORING SYSTEM*/ $_SESSION["{$turn}score"] -= $_SESSION['inputbet']; $_SESSION['potscore'] += $_SESSION['inputbet']; } print "<input type='submit' name='dowhat' value='NEXT DRAW'></div>";/***********SCORING SYSTEM*/ //run out of money in pot if($_SESSION['potscore']==0){ $_SESSION['potscore']=200; $_SESSION['blackscore'] -= 100; $_SESSION['goldscore'] -= 100; }print "<div class='right_side'><h2>Score:</h2><br/><h3 class='pot'>POT</h3><h3 class='pot'>" .$_SESSION['potscore']. "</h3></br><h3 class='black'>Black</h3><h3 class='black'>" .$_SESSION['blackscore']. "</h3></br><h3 class='gold'>Gold</h3><h3 class='gold'>" .$_SESSION['goldscore']. "</h3></br></div>"; //winner loser }else if($_SESSION['goldscore']==0){ print "<p class='bigtext'>Black team wins!</p>"; }else if($_SESSION['blackscore']==0){ print"<p class='bigtext'>Gold team wins!</p>"; } else{ print "Error 100: nextaction=$nextaction, but I don't know what to do.";}}?><tt>Website and program by Caitlin Havener. <br/>Card graphics from http://sopapeldeparede.com.br.</tt></form></div></div></div></div></div></div></div></div></div></div></div></body></html>
  12. ajax help

    YAYY I got everything to work. Thank you so much! I used my own code though and implemented some of your stuff. Mine of course isn't as pretty but I didn't understand everything in yours and I had been looking at mine for so long so I just stuck to most of it
  13. ajax help

    You guys are so funny! LOL working on it this morning. Need to get it done today! MEHH
  14. How do I get practical experience?

    Make some websites. For friends... whatever... can only get better by doing it.
  15. ajax help

    var numberQuestions = 8;var numberOfQuestions= new Array();//preload functionfunction init(){var anchor = document.getElementsByTagName('a');//set up flag for how many times a given anchor is clickedfor (i=1; i<=numberQuestions; i++){ anchor[i].addEventListener('click', function(e) { e.preventDefault(); getAnswers(this.name); }, false); //OWEN IM HAVING THE SAME PROBLEM HERE WHERE I WANT TO USE THE ELEMENTS OF AN ARRAY AS INDIVIDUAL COUNTERS FOR EACH QUESTION... will this work? var clickCounter= newArray(); //flag to count how many times a given link is clicked clickCounter[i] = 0;}//httprequest number of questions for each questionvar xhr = new XMLHttpRequest();if (xhr){ xhr.onreadystatechange = function() { displayResponse(xhr); } xhr.open("GET", "answers.txt", true); xhr.send(null);} function displayResponse(xhr){ if (xhr.readyState == 4) { if (xhr.status == 200 || xhr.status == 304) { var allAnswers = xhr.responseText.split('\n'); //loop through the questions for(var i = 1; i <= 8; i++){ //define a variable to map question to answers var question = 'q' + i; var answersPerQuestion = 0; console.log('QUESTION => ' + question); //loop through the answers, and split on the * for(var j = 0; j < allAnswers.length; j++) { var line = allAnswers[j]; var pieces = line.split('*'); //determine if the current line contains an answer for our question if(pieces[0] == question) { //increment our number of answers for this question answersPerQuestion++; }; }; console.log('Number of answers for question #' + i + ' => ' + answersPerQuestion); numberOfQuestions[i] = answersPerQuestion; //put numbers in seperate corresponding question variables //place number in the DOM for name==questionVariable numberIntoAnchor=document.createElement(toString(numberOfQuestions[i])); getAnchors=document.getElementsByName(i)[0]; getAnchors.appendChild(numberIntoAnchor); }; } else if (xhr.status == 404) { console.log("Oops, file not found!"); } }} }window.onload = init; //where to place this?//PAGE NOW HAS LOADED WITH NUMBER OF QUESTIONS LINK NEXT TO EACH QUESTION//WHEN USER CLICKS QUESTION NUMBER FUNCTION IS CALLED W/ ANCHOR NAME AS PARAMETERfunction getAnswers(name){var nameInt = parseInt(name);//comes in as string so parseclickCounter[nameInt]++;if (nameInt % 2 != 0)//IF clickCounter[parseInt(name)] is NOT divisible by two, which means it was clicked once or third time back on{//httprequest split questions into pieces//filter looking for name to match pieces[0]//when they match, output pieces[1] to Ul.name var xhr = new XMLHttpRequest(); if (xhr) { xhr.onreadystatechange = function() { displayResponse(xhr); } xhr.open("GET", fileName, true); xhr.send(null); } function displayResponse(xhr) { if (xhr.readyState == 4) { if (xhr.status == 200 || xhr.status == 304) { var allAnswers = xhr.responseText.split('\n'); //loop through the questions for(var i = 1; i <= 8; i++) { //loop through the answers, and split on the * for(var j = 0; j < allAnswers.length; j++) { var line = allAnswers[j]; var pieces = line.split('*'); //determine if the current line contains //an answer for our question if(pieces[0] == question) { //add the answer under the appropriate question in the DOM var output = document.getElementById(nameInt); //is nameInt what we use?? output.innerHTML += "<li>" + pieces[1] + "</li>"; }; }; }; } else if (xhr.status == 404) { console.log("Oops, file not found!"); } } }}else if (nameInt % 2 == 0){ //take the answers to each question off the page} }
×