Jump to content

hamburgerlove413

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by hamburgerlove413

  1. Hello, So I have this program I'm trying to create where there are 9 articles (the html tag) and I want 3 random ones to display at any one time. When you click the link in the article, it should bring up that link in an iframe. A skip button then appears and when you click it, the iframe should disappear and three different random articles should come up. It works fine for the first time you click, but any time after that it just gets more and more messed up. If anyone can look at my code and tell me where I've gone wrong, it would be a great help. <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>New Path Page</title> <meta name="description" content="The HTML5 Herald"> <meta name="author" content="SitePoint"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous"> <!-- JavaScript --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script> <style> article { color: white; } article a, article a:visited, article a:hover { color: white; } .offer-one, .offer-two, .offer-three, .offer-four, .offer-five, .offer-six, .offer-seven, .offer-eight, .offer-nine { height: 300px; padding-top: 18px; text-align: center; font-size: 20px; } .offer-one { background-color: #93104d; } .offer-two { background-color: #285b6c; } .offer-three { background-color: #368a2c; } .offer-four { background-color: #93104d; } .offer-five { background-color: #285b6c; } .offer-six { background-color: #368a2c; } .offer-seven { background-color: #93104d; } .offer-eight { background-color: #285b6c; } .offer-nine { background-color: #368a2c; } iframe { width: 100%; border: none; } </style> </head> <body> <div class="container"> <iframe></iframe> <a class="skip">SKIP</a> <div class="offers"> <div class="row"> <article class="col-md-4 offer-one"> <h2>test</h2> <a href="/newpath-sample.php">CLICK HERE</a> </article> <article class="col-md-4 offer-two"> <h2>test2</h2> <a href="/newpath-sample.php">CLICK HERE</a> </article> <article class="col-md-4 offer-three"> <h2>tes3</h2> <a href="/newpath-sample.php">CLICK HERE</a> </article> <article class="col-md-4 offer-four"> <h2>test4</h2> <a href="/newpath-sample.php">CLICK HERE</a> </article> <article class="col-md-4 offer-five"> <h2>test5</h2> <a href="/newpath-sample.php">CLICK HERE</a> </article> <article class="col-md-4 offer-six"> <h2>tes6</h2> <a href="/newpath-sample.php">CLICK HERE</a> </article> <article class="col-md-4 offer-seven"> <h2>test7</h2> <a href="/newpath-sample.php">CLICK HERE</a> </article> <article class="col-md-4 offer-eight"> <h2>test8</h2> <a href="/newpath-sample.php">CLICK HERE</a> </article> <article class="col-md-4 offer-nine"> <h2>tes9</h2> <a href="/newpath-sample.php">CLICK HERE</a> </article> </div> <? // end of row ?> </div> </div> <? //end of container ?> </body> </html> and the Jquery: <script> $(window).load(function() { $('.offers article').hide(); $('iframe').hide(); $('.skip').hide(); var offers = [".offer-one",".offer-two",".offer-three",".offer-four",".offer-five",".offer-six",".offer-seven",".offer-eight",".offer-nine"]; var offerOne = ""; var offerTwo = ""; var offerThree = ""; while (offerOne == offerTwo || offerOne == offerThree || offerTwo == offerThree) { var offerOne = offers[Math.floor(Math.random()*offers.length)]; var offerTwo = offers[Math.floor(Math.random()*offers.length)]; var offerThree = offers[Math.floor(Math.random()*offers.length)]; } $(offerOne).fadeIn(1); $(offerTwo).delay(200).fadeIn(1); $(offerThree).delay(400).fadeIn(1); $('.offers article a').click(function(e) { e.preventDefault(); var setSRC = $(this).attr('href'); $('iframe').attr('src',setSRC); $(offerOne).fadeOut(1); $(offerTwo).delay(200).fadeOut(1); $(offerThree).delay(400).fadeOut(1, function() { $('iframe').fadeIn(1, function() { $('.skip').show(); }); }); }); $('.skip').click(function(e) { e.preventDefault(); $('.offers article').hide(); $('.skip').hide(); $('iframe').fadeOut(1); $('iframe').hide(); var offerOne = ""; var offerTwo = ""; var offerThree = ""; while (offerOne == offerTwo || offerOne == offerThree || offerTwo == offerThree) { var offerOne = offers[Math.floor(Math.random()*offers.length)]; var offerTwo = offers[Math.floor(Math.random()*offers.length)]; var offerThree = offers[Math.floor(Math.random()*offers.length)]; } $(offerOne).fadeIn(1); $(offerTwo).delay(200).fadeIn(1); $(offerThree).delay(400).fadeIn(1); }); }); </script>
  2. Hello, I'm creating a website that takes flickr photos from areas that you click on the map and loads them into a jquery carousel called Slick Carousel. Everything works fine except for I have this strange issue where the autoplay only begins if you click to another window or you manually move the thumbnails to the left or right. Then it works fine. Can anyone look at the code and see if they can see what I'm doing wrong? <!DOCTYPE html> <html> <head> <!-- google maps api key --> <script src="http://maps.google.com/maps/api/js?key=AIzaSyAM4sSbWxrbwyXvGHvbH6piG5AlqLjtAMc&sensor=true" type="text/javascript"></script> <!-- jquery --> <script src="js/jquery.1.11.1.min.js"></script> <script src="js/jquery.ui.map.full.min.js"></script> <!-- scripts for lightbox --> <script src="js/lightbox.min.js"></script> <!-- script for actual display of images --> <!-- fonts --> <link href='http://fonts.googleapis.com/css?family=Pacifico|Open+Sans' rel='stylesheet' type='text/css'> <link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/jquery.slick/1.3.15/slick.css"/> <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> <link href="css/lightbox.css" rel="stylesheet" /> <link href="css/styles.css" rel="stylesheet" type="text/css"> </head> <body> <header> <h1>Time Capsule <i class="fa fa-space-shuttle"></i> </h1> <div id="drop_instructions"> <p>Ever wonder what a certain area looked like from the world's point of view? Now you can find out! Click on an area in the map and we'll show you that spot as the locals see it.</p> </div> </header> <section class="clearfix"> <div id="map_canvas"></div> <div id="imagebox" class="slider-for"> </div> </section> <div class="slider-nav"> </div> <script type="text/javascript" src="http://cdn.jsdelivr.net/jquery.slick/1.3.15/slick.min.js"></script> <script src="js/map.js"></script> </body> </html> $(document).ready(function() { $('#drop_instructions').hide(); $('#header').click(function(){ $('#drop_instructions').fadeToggle( "fast", "linear" ); }); //define lat and long globally so they can be used elsewhere var lat=0; var lng=0; var city=''; var state=''; var StartLatLng = new google.maps.LatLng(28.4158, -81.2989); $('#map_canvas').gmap({ 'center': StartLatLng, zoom: 10, styles: [{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]},{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]}] }) .bind('init', function(event, map) { $(map).click( function(event) { //define date var year = $("#year").val(); var month = $("#month").val(); var day = $("#day").val(); //give current value to lat/long on click lat=event.latLng.lat(); lng=event.latLng.lng(); var latlng= event.latLng; //input box with coordinates $('#latlng').val(lat+', '+lng); geocoder = new google.maps.Geocoder(); geocoder.geocode({'latLng': latlng}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { //Check result 0 var result = results[0]; //look for locality tag and administrative_area_level_1 for(var i=0, len=result.address_components.length; i<len; i++) { var ac = result.address_components[i]; if(ac.types.indexOf("locality") >= 0) city = ac.long_name; if(ac.types.indexOf("administrative_area_level_1") >= 0) state = ac.long_name; } //only report if we got Good Stuff if(city != '' && state != '' && year != '') { console.log("Hello to you are in "+city+", "+state+"! The date you chose is: " + month + " " + day + ", " + year); } else { console.log("YOU FORGOT TO PICK A YEAR!"); } } //end of getting city //==============Image generation================= //get location from map click and inject data into URL var locationURL = "https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=a0f6800f62ea920f00472805d767ac5c&lat="+lat+"&lon="+lng+"&format=json&nojsoncallback=1"; $.ajax({ url: locationURL, dataType: "json", success:function(data){ var farmId; var serverId; var photoId; var secret; var title; //hide instructions once content is generated $('#instructions').fadeOut(500); //title the images for the city clicked on $('#images_title').append('<h3>'+city+' , '+state+'</h3>'); console.log(data); //generate thumbnails user can click on for (i=0; i < 20; i++){ farmId = data.photos.photo[i].farm; serverId = data.photos.photo[i].server; photoId = data.photos.photo[i].id; secret = data.photos.photo[i].secret; title = data.photos.photo[i].title; // make the urls for the DOM photoURL = "https://farm"+farmId+".staticflickr.com/"+serverId+"/"+photoId+"_"+secret+"_z.jpg"; thumbURL = "https://farm"+farmId+".staticflickr.com/"+serverId+"/"+photoId+"_"+secret+"_s.jpg"; //append the clickable thumbnails to the dom $('.slider-for').slickAdd('<div><img src="'+photoURL+'" alt="'+title+'" /></div>'); $('.slider-nav').slickAdd('<div><img src="'+thumbURL+'" class="image_thumb" alt="'+title+'" /></a></div>'); } //change background of page to an image that is displayed $("body").css("background-image", "url('"+photoURL+"')"); } }); }); }); }); }); $('.slider-for').slick({ slidesToShow: 1, slidesToScroll: 1, arrows: true, fade: true, asNavFor: '.slider-nav' }); $('.slider-nav').slick({ arrows: true, slidesToShow: 3, slidesToScroll: 1, asNavFor: '.slider-for', dots: true, centerMode: true, focusOnSelect: true, autoplay: true, autoplaySpeed: 2000 });
  3. Hello, I'm trying to send a variable that gets its text from an xml file to a markers information box, and I can't seem to get it to work. Can someone look at my code and tell me what I'm doing wrong? its the one marked "address" (line 52 and down). $(document).ready(function () { //google maps api $('#map_canvas').gmap({'zoom':3, 'center': new google.maps.LatLng(39.8282,-98.5795)}).bind('init', function(ev, map) { //last.fm api $( "#artistSearch" ).submit(function( event ) { $('#map_canvas').gmap('clear', 'markers'); //clear previous results $("#tourList h2").empty(); $("#artist").empty(); //name to send to API var artistName = $("#artistName").val(); //get API response $.get("http://ws.audioscrobbler.com/2.0/?method=artist.getevents&artist=" + artistName + "&api_key=69d935120d26cbcbaeed4fac6f59dfb6", function(xml) { var resLength = $(xml).find("venue"); if (resLength.length != 0) { //attach heading $("#tourList").prepend("<h2>Tour List</h2>"); //find venues $(xml).find("venue").each( function() { title = $(this).find("name").text(); //build a list of the venues $("#artist").append("<li>" + title + "</li>"); }); } else { $("#artist").append("<li>No Results Found</li>"); } //grab lat and long $(xml).find("location").each( function() { geolat = $(this).find("geo\\:lat").text(); geolong = $(this).find("geo\\:long").text(); address = $(this).find("city").text(); $('#map_canvas').gmap('addMarker', { 'position': new google.maps.LatLng(geolat,geolong) } ).click(function() { $('#map_canvas').gmap('openInfoWindow', { 'content': address }, this); }); //end of markers }); //end of locations }); event.preventDefault(); }); }); });
  4. well, the problem with changing append is that I need it to append so I can build a list of the events. It's only when I change the band name in the input box that I would like all of that to clear. I haven't tried onchange yet.
  5. Also, is there a way to do something like "when this API has sent back a response with xml in it, do this"?
  6. Hello, i wasn't sure of a good way to title this post but, I have this app that for right now, you type in band name and it grabs that band's concerts from last.fm API (without using a submit button). This part works, but then when i type a new band/artist in to the input box, instead of replacing the previous band's concerts, it just adds to it. Does anyone know of a way to delete the previous information once a new band name is typed in? the html: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Assignment 03 Mashup – Nicholas Barna</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="js/script.js"></script> <link href="css/styles.css" rel="stylesheet" type="text/css"> </head> <body> <div id="container" class="globalWidth"> <form name="artistSearch" id="artistSearch" method="get"> <label for="artistName">Artist or band name:<input type="text" name="artistName" id="artistName" /></label> </form> <span id="searchTitle">search for:</span><span id="searchItem"></span> <div id="artist"> </div> </div> </body> </html> the Javascript: $(document).ready(function () { $("#artistName").on("keyup change", function() { artistName = this.value; $.get("http://ws.audioscrobbler.com/2.0/?method=artist.getevents&artist=" + artistName + "&api_key=69d935120d26cbcbaeed4fac6f59dfb6", function(xml) { $(xml).find("venue").each( function() { title = $(this).find("name").text(); $("#artist").append(title); }); }); $("#searchItem").text(this.value); }); });
  7. Hello, I'm getting an XML tag node value using var dropOption = document.createTextNode(title[0].firstChild.nodeValue); and after I want to be able to split that certain places like you can with a string using split. Is this possible? I tried using split on dropOption after I get the value but it doesn't work. Maybe I'm doing something wrong though, because wouldn't the nodeValue become a string after it's assigned to the variable? Edit: nevermind, I've got it figured out, i needed to assign the nodeValue to a variable before using that to create the text node, this post can be deleted.
  8. Hello, I have an xml file that I then convert to json, and save it as a text file. What I'm trying to do is to then take this text and insert all of it into one field in a table. When I do, a record is added, but its blank, theres no data. I can add it through phpmyadmin, and i can change what I'm adding to a simple string and it gets added through php, but when I try to add the actual text it's not there. Anyone have any ideas what I'm doing wrong? I'm also getting this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't Remember To Forget You, Shakira Featuring Rihanna","link":"http:\/\/www1.billb' at line 1 (its Billboards Hot 100 rss feed) I don't even need it converted to Json, if thats simpler, I just need to save the contents of the XML into a table. my code to get and save the file: $billboardFile = "http://www1.billboard.com/rss/charts/hot-100"; $loadBillboard = simplexml_load_file($billboardFile); $loadBillboard->asXML("data/billboard.xml"); $url = 'data/billboard.xml'; $billboardLoad = file_get_contents($url); $billboardLoad = str_replace(array("\n", "\r", "\t"), '', $billboardLoad); $billboardLoad = trim(str_replace('"', "'", $billboardLoad)); $loadBB = simplexml_load_string($billboardLoad); $bbJson = json_encode($loadBB); $fileName = 'data/bbJson.txt'; if (file_exists($fileName)) { $lBillboard = file_get_contents($file); $lBillboard = $bbJson; file_put_contents($fileName, $lBillboard); } my main page: <!doctype html> <?php //include folder path $incPath = 'includes/'; include $incPath . 'getFile.php'; include $incPath . 'conn.php'; ?> <html> <head> <meta charset="utf-8"> <title>Assignment 01 AJAX – Nicholas Barna</title> </head> <body> <?php $dataBB = file_get_contents('data/bbJson.txt'); $query="INSERT INTO xmladd (id,text) VALUES (null,'$dataBB')"; $result=$mysqli->query($query) or die ($mysqli->error); ?> <div id="listings"></div> <!--<script type="text/javascript" src="js/javascript.js"></script>--> </body> </html> theres also a connection file, and then the xml and txt files. I'm attaching the txt file that it creates. bbJson.txt
  9. just out of curiousity, i tried to add unset($act) at the end of the if $action='save' statement, but this doesn't seem to work, why doesn't it? when i click save, it should unset $act, and then it would run back through and end up at the part of the main if statement that's for when $act has no value, right?
  10. thank you! That worked, but now there's a new problem. When I click save, it's supposed to go back to the main screen which shows all the records, but instead it just stays on the edit screen. I thought because the form is submitted would mean $action's value would be lost, and therefore go back to the main screen but it doesnt.
  11. Hello, I'm making a simple program that adds homework assignments to a database table and then displays them. I'm trying to add the ability to edit them, but I can't figure it out. Here's what I have right now, but after I go to the edit screen, change the value, and hit save, it doesn't update the table. Sorry for the amount of code, i didnt know what I needed to include or not. <html> <head> <title>untitled</title> <link href="css/styles.css" rel="stylesheet" type="text/css"> </head> <body> <form method='post'> <?php function showlist($mysqli,$last='') { if ($last) $myquery="SELECT * FROM homeworklist WHERE course LIKE '$last%'"; else $myquery="SELECT * FROM homeworklist"; $result=$mysqli->query($myquery) or die ($mysqli->error); $count=$result->num_rows; if($count > 0) { $output="<table><tr><th>Task Nr:</th><th>assign-date</th><th>due-date</th><th>priority</th><th>course</th><th>prof</th><th>title</th><th>description</th></tr>"; while ($row=$result->fetch_assoc()) { $tasknr=$row['tasknr']; $assigndate=$row['assigndate']; $duedate=$row['duedate']; $priority=$row['priority']; $course=$row['course']; $prof=$row['prof']; $title=$row['title']; $description=$row['description']; $output.= "<tr><td align='center'>$tasknr</td><td>$assigndate</td><td>$duedate</td><td>$priority</td><td>$course</td><td>$prof</td><td>$title</td><td>$description</td></tr>"; } $output.= "</table> <br />"; print $output; } #count else print "There are no homework items in the list.<br />"; } #showlist function drawinputs() { print "<dl>"; print "<dt><label for='assigndate'>Assign Date:</label></dt><dd><input type='text' name='assigndate'></dd> <dt><label for='duedate'>Due Date:</label></dt><dd><input type='text' name='duedate'></dd> <dt><label for='priority'>Priority:</label></dt><dd><input type='text' name='priority'></dd> <dt><label for='course'>Course:</label></dt><dd><input type='text' name='course'></dd> <dt><label for='prof'>Professor:</label></dt><dd><input type='text' name='prof'></dd> <dt><label for='title'>Title:</label></dt><dd><input type='text' name='title'></dd> <dt><label for='description'>Description:</label></dt><dd><input type='text' name='description'></dd> <input type='submit' name='action' value='Add Task'> <dt><label for='matchlast'>Filter the displayed list. Only display courses with names that begin with this string:</label></dt> <dd><input type='text' name='matchlast'></dd> <input type='submit' name='action' value='Filter List'><br /><br /> <dl> <dt><label for='delsel'>Item number to be deleted:</label></dt><dd><input type='text' name='delsel' size=2></dd> </dl> <input type='submit' name='action' value='Delete Task'><br /> <dl> <dt><label for='editsel'>Item number to be edited:</label></dt><dd><input type='text' name='editsel' size=2></dd> </dl> <input type='submit' name='action' value='Edit Record'><br /> "; print "</dl>"; } # drawinputs function addtask($mysqli) { $assigndateX=$_POST['assigndate']; $duedateX=$_POST['duedate']; $priorityX=$_POST['priority']; $courseX=$_POST['course']; $profX=$_POST['prof']; $titleX=$_POST['title']; $descriptionX=$_POST['description']; // ESSENTIAL cleaning to avoid SQL Injectin Attack $assigndate=$mysqli->real_escape_string($assigndateX); $duedate=$mysqli->real_escape_string($duedateX); $priority=$mysqli->real_escape_string($priorityX); $course=$mysqli->real_escape_string($courseX); $prof=$mysqli->real_escape_string($profX); $title=$mysqli->real_escape_string($titleX); $description=$mysqli->real_escape_string($descriptionX); // The 'null' in the VALUES list allows the auto-incrementing idnumber to work $query="INSERT INTO homeworklist VALUES (null,'$assigndate','$duedate','$priority','$course','$prof','$title','$description')"; $result=$mysqli->query($query) or die ($mysqli->error); } #addtask // STARTER item for deleterecord function function deleterecord($mysqli,$deletenumber) { $query="DELETE FROM homeworklist WHERE tasknr=$deletenumber"; $result=$mysqli->query($query) or die ($mysqli->error); } function edittask($mysqli, $editnumber) { $myquery="SELECT * FROM homeworklist WHERE tasknr=$editnumber"; $result=$mysqli->query($myquery) or die ($mysqli->error); while ($row=$result->fetch_assoc()) { $tasknr=$row['tasknr']; $assigndate=$row['assigndate']; $duedate=$row['duedate']; $priority=$row['priority']; $course=$row['course']; $prof=$row['prof']; $title=$row['title']; $description=$row['description']; } print "<h1>Edit " . $title . "</h1>"; print "<input type='text' name='editassigndate' value='$assigndate' />"; print "<input type='text' name='editduedate' value='$duedate' />"; print "<input type='text' name='editpriority' value='$priority' />"; print "<input type='text' name='editcourse' value='$course' />"; print "<input type='text' name='editprof' value='$prof' />"; print "<input type='text' name='edittitle' value='$edittitle' />"; print "<input type='text' name='editdescription' value='$description' />"; print "<input type='submit' name='action' value='cancel' />"; print "<input type='submit' name='saveTable' value='save' />"; $action = $_POST['saveTable']; if ($action == "save") { $assigndateX=$_POST['editassigndate']; $duedateX=$_POST['editduedate']; $priorityX=$_POST['editpriority']; $courseX=$_POST['editcourse']; $profX=$_POST['editprof']; $titleX=$_POST['edittitle']; $descriptionX=$_POST['editdescription']; // ESSENTIAL cleaning to avoid SQL Injectin Attack $editassigndate=$mysqli->real_escape_string($assigndateX); $editduedate=$mysqli->real_escape_string($duedateX); $editpriority=$mysqli->real_escape_string($priorityX); $editcourse=$mysqli->real_escape_string($courseX); $editprof=$mysqli->real_escape_string($profX); $edittitle=$mysqli->real_escape_string($titleX); $editdescription=$mysqli->real_escape_string($descriptionX); $query = "UPDATE homeworklist SET assigndate=$editassigndate, duedate=$editduedate, priority=$editpriority, course=$editcourse, prof=$editprof, title=$edittitle, description=$editdescription WHERE tasknr=$editnumber"; $result=$mysqli->query($query) or die ($mysqli->error); } } // MAIN PROGRAM // Create the mysqli object $mysqli = new mysqli('localhost', 'nick', 'n1ck8arna', 'homework'); // Check for any errors. $errnum=mysqli_connect_errno(); if ($errnum) { $errmsg=mysqli_connect_error(); print "Connect failed. error number=$errnum<br /> error message=$errmsg"; exit(); } // Now interact with the user print "<h2>Project 4</h2>"; $act=$_POST['action']; if ($act == 'cancel') { unset($act); } if ($act=='Add Task') { drawinputs(); addtask($mysqli); showlist($mysqli); } else if ($act=='Filter List') { drawinputs(); $matchlastX=$_POST['matchlast']; $matchlast=$mysqli->real_escape_string($matchlastX); showlist($mysqli,$matchlast); } else if ($act=='Delete Task') { $deletenumberX=$_POST['delsel']; $deletenumber=$mysqli->real_escape_string($deletenumberX); if (!$deletenumber) { print "You need to enter a task number!"; } else { deleterecord($mysqli,$deletenumber); } showlist($mysqli); drawinputs(); } else if ($act == 'Edit Record') { $editnumberX = $_POST['editsel']; $editnumber = $mysqli->real_escape_string($editnumberX); if (!$editnumber) { print "You need to enter a task number!"; showlist($mysqli); drawinputs(); } else { edittask($mysqli,$editnumber); } } else { showlist($mysqli); drawinputs(); } ?> </form> </body> </html>
  12. gah, that was it. I hate trying to find an issue for hours and than have it turn out to be something like that. It's strange though, the example page they provide that works has slashes before each path.
  13. Hello, I'm trying to use the responsive grid system (responsivegridsystem.com) to layout a webpage, but I'm running into a strange problem. The media queries used in the head section work fine for the first two sizes, but once the screen is brought below 768px, they stop working and it reverts back to the main style sheet. I cannot figure out what in the code is wrong. With the exact same style sheets, their example page works perfectly fine. When i copy the code from the body of my page to theirs, it stops working, so I figure there's something wrong in that area. Anyone have any ideas as to what could be the issue? html: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>home - Nicholas Barna</title> <link rel="shortcut icon" href="/favicon.ico"> <!-- Responsive and mobile friendly stuff --> <meta name="HandheldFriendly" content="True"> <meta name="MobileOptimized" content="320"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!--google fonts--> <link href='http://fonts.googleapis.com/css?family=Neuton' rel='stylesheet' type='text/css'> <!-- Stylesheets --> <link rel="stylesheet" href="css/html5reset.css" media="all"> <link rel="stylesheet" href="css/col.css" media="all"> <link rel="stylesheet" href="css/styles.css" media="all"> <link rel="stylesheet" href="css/12cols.css" media="all"> <!-- Responsive Stylesheets --> <link rel="stylesheet" media="only screen and (max-width: 1280px) and (min-width: 1025px)" href="css/1280.css"> <link rel="stylesheet" media="only screen and (max-width: 1024px) and (min-width: 769px)" href="css/1024.css"> <link rel="stylesheet" media="only screen and (max-width: 768px) and (min-width: 481px)" href="/css/768.css"> <link rel="stylesheet" media="only screen and (max-width: 480px)" href="/css/480.css"> </head> <body> <div id="navWrap"> <div class="globalWidth"> <div class="section group"> <nav id="mainNav" class="span_9_of_12"> <ul> <li><a href="#">home</a></li> <li><a href="#">about</a></li> <li><a href="#">stats</a></li> <li><a href="#">time</a></li> <li><a href="#">contact</a></li> </ul> </nav> <nav id="loginNav" class="span_3_of_12"> <ul> <li><a href="#">login</a></li> <li><a href="#">register</a></li> </ul> </nav> </div> </div> </div> <!--end of nav wrapper--> </body> </html> my style sheet: /* basic tags */ a { text-decoration: none; } li { font-size: 1.4em; } /* Layout */ body { background: url(../img/background.jpg) no-repeat center center fixed; font-family: "Neuton", "Times New Roman", serif; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover;background-size: cover; } .globalWidth { width: 960px; margin: 0 auto; } nav li { display: inline; } nav a { color: white; } nav a:hover { color: #bdbdbd; } #navWrap { background: rgb(42, 0, 43); background: rgba(42, 0, 43, .77); } #mainNav { background-color: #cccccc; margin: 20px 0; float: left; } #mainNav li { margin-right: 6%; } #mainNav a { font-family: 'deliciousroman', arial, helvetia, sans-serif; text-transform: uppercase; font-size: 1.6em; } #loginNav { text-align: right; background-color: #cccccc; margin: 20px 0; float: right; } #loginNav li { margin-left: 6%; } /* GLOBAL OBJECTS */ .breaker { clear: both; } .group:before, .group:after { content:""; display:table; } .group:after { clear:both; } .group { zoom:1; /* For IE 6/7 (trigger hasLayout) */ } .floatleft { float: left; } .floatright { float: right; } /* fonts */ @font-face { font-family: 'deliciousroman'; src: url('../fonts/delicious-roman-webfont.eot'); src: url('../fonts/delicious-roman-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/delicious-roman-webfont.woff') format('woff'), url('../fonts/delicious-roman-webfont.ttf') format('truetype'), url('../fonts/delicious-roman-webfont.svg#deliciousroman') format('svg'); font-weight: normal; font-style: normal; } there are a couple more style sheets used, but theyre for setting up the width of the columns in percentages (the span_3_of_12 stuff), and my 1280 style sheet which takes the .globalWidth: 960px and changes it to 80% (which should translate to all screen sizes below it, but it stops before 768px). I didnt want to include all of this in the code above for easier reading, but if I should, let me know.
  14. Hello, I have a phrase guessing game I'm working on, and I'm currently trying to add some validation to it, and have a problem. I have a for loop with an if statement inside: if (preg_match("/^[a-zA-Z]$/", $guess)) { if (in_array($guess, $wordArray)) { for ($i=0; $i < $letterCount; $i++) { if ($guess == $wordArray[$i] && $visibleArray[$i] == 0) { $visibleArray[$i] = 1; print "<span class='success'>" .$guess . " is correct! </span>"; } else if ($guess == $wordArray[$i] && $visibleArray[$i] == 1) { print "<span class='error'>You already guessed that letter!</span>"; } } my problem is, if more than one of the same letter,say, three a's, is in the phrase to be guessed, it prints out the error or success message three times. What would be the best way to approach this to have it only print it once? I was thinking I could assign the messages to a variable, and then use a conditional and strlen, substr to trim them down? I'm hoping there's something easier though.
  15. Thank you! That fixed it. I hadn't thought of separating the NEXT PHRASE action from the main if statement.
  16. I should say I'm not so much looking for a written out solution as much as what I should look into to make it do what I need it to do. Or if I'm at least on the right track, where I can go from here to make it work.
  17. Is there a better way to approach this then? I'm having other issues besides it taking two clicks, like after I click the next phrase button and it finally changes, the guess button then changes the phrase again the first time it's clicked. It doesn't do this unless the next phrase button is first clicked.
  18. I tried moving $nextPhrase++ above inputscreen($guesses); printTable($letterCount, $visibleArray, $wordArray); but it didn't change anything.
  19. Hello, I'm trying to create a simple phrase guessing game, and I have a button named Next Phrase which when clicked, I need to increment a variable, $nextPhrase by 1. I have it kind of working, but for some reason on the first time, it takes two clicks to get to start incrementing. Can anyone see what it is I'm doing wrong? <?php session_start(); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Project 2</title> <link href="css/layout.css" rel="stylesheet" type="text/css"> </head> <body> <div id="container" class="clearfix"> <?php print "<form method='post'>"; function inputscreen($guesses) { print "<span>Guess a letter!</span>"; print "<span> You have ". $guesses . " guesses left! </span>"; print "<input type='text' name='guess' />"; print "<input type='submit' name='action' value='GUESS' />"; print "<input type='submit' name='action' value='REVEAL' />"; print "<input type='submit' name='action' value='NEXT PHRASE'>"; print "</form>"; } function printTable($letterCount, $visibleArray, $wordArray) { // print table for word display print "\n \n <table> \n \n \t <tr>"; for ($i = 0; $i < $letterCount; $i++) { if ($visibleArray[$i] == 1) { print "\n \n \t \t <td>" .$wordArray[$i]. "</td> \n"; } else if ($wordArray[$i] == " ") { print "\n \n \t </tr> \n \n</table> \n \n <table> \n \n \t <tr>"; } else { print "\n \n \t \t <td> </td>"; } } print "\n \n \t </tr> \n \n </table> \n \n"; } //text loader function textLoader($whatfile) { if(!file_exists($whatfile)) { print "Sorry, can't find " . $whatfile; exit; } else { $textarray= file($whatfile); return $textarray; } } // global variables if (!isset($_SESSION['nextPhrase'])) { $_SESSION['nextPhrase'] = 0; } $nextPhrase = $_SESSION['nextPhrase']; print $nextPhrase . "<br />"; $theText = textLoader('words.txt'); $action = $_POST['action']; $team = $_SESSION['team']; $visibleArray = $_SESSION['visible']; $guesses = $_SESSION['guesses']; $word = $theText[$nextPhrase]; $wordArray = str_split($word); $letterCount = count($wordArray)-2; if (!$action) { $guesses = 5; for ($i = 0; $i < $letterCount; $i++) { $visibleArray[$i] = 0; } inputscreen($guesses); printTable($letterCount, $visibleArray, $wordArray); } else if ($action == "GUESS") { $guess = strtoupper($_POST['guess']); if (preg_match("/^[a-zA-Z]$/", $guess)) { if (in_array($guess, $wordArray)) { for ($i=0; $i < $letterCount; $i++) { if ($guess == $wordArray[$i]) { $visibleArray[$i] = 1; } } print "<span>You guessed the letter " .$guess . " and are correct! </span>"; } else { print "<span>Nope! Try Again!</span> "; $guesses -= 1; } } else { print "<span>You need to guess a letter!</span>"; } inputscreen($guesses); printTable($letterCount, $visibleArray, $wordArray); } else if ($action == "REVEAL") { for ($i =0; $i < $letterCount; $i++) { if ($wordArray[$i] != " ") { $visibleArray[$i] = 1; } } print "<div>The phrase was </div>"; printTable($letterCount, $visibleArray, $wordArray); print "<input type='submit' name='action' value='NEXT PHRASE'>"; } else if ($action == "NEXT PHRASE") { for ($i = 0; $i < $letterCount; $i++) { $visibleArray[$i] = 0; } inputscreen($guesses); printTable($letterCount, $visibleArray, $wordArray); $nextPhrase++; } $_SESSION['nextPhrase'] = $nextPhrase; $_SESSION['visible'] = $visibleArray; $_SESSION['team'] = $team; $_SESSION['guesses'] = $guesses; ?> </div> </body> </html>
  20. Hello, Thanks for the reply! This unfortunately didn't work. There are still two extra spaces on the end of the array even after trying that. I checked the text file and there doesn't seem to be any extra spaces anywhere. I can fix this by subtracting two from $letterCount but I'd really like to know what's going on and why it's doing that.
×
×
  • 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.