Jump to content

SF23103

Members
  • Posts

    100
  • Joined

  • Last visited

Everything posted by SF23103

  1. fixed the last issue: Changed $('input[name="class_start_time"]').attr('value' , response.class_start_time); to $('input[name="class_start_time"]').val(response.class_start_time);
  2. You'll want to use a "cron job". http://forums.phpfreaks.com/topic/293523-how-i-can-make-a-script-of-my-php-code-to-work-even-if-my-website-is-not-running/?hl=%2Bcron+%2Bjob&do=findComment&comment=1501194
  3. I got this working great, and when I set it up to send the data, it only sends the form field in the select dropdown. It is not sending any of the values that are filled by AJAX. Is it not truly changing the value of the text box? Is there any way to truly fill that text box with the value for the form submission?
  4. EDIT: Got it working! Just changed all the class_number to course_number throughout the whole thing instead of trying to move it to class_number after all the MySQL stuff was done. That way I did't miss any. Still leaving out the below header line, as it throws an error. Its working great, and you are my hero! Thanks!
  5. Wow Ch0cu3r that is way more than I expected, thank you so much. That looks great, and I am working on implementing it. I got my class names to populate, but right now for some reason the get_class_details.php isn't running, as I am getting a server 500 error. I'm trying to turn on error reporting at it doesn't seem to give me any information. Thinking it is not running the script at all due to a syntax error I tried taking out the first line header('Content-type', 'text/json'); and it actually ran the script, of course giving an invalid request error because there is nothing set in POST, but it actually ran. I went back to the html page, and tried it out without the header info and expectedly it gave me a "Unable to perform this action at this time due to a server error" pop up message. I know we need to return the request in JSON, but it doesn't seem to like that way of doing it. Still working on finding a solution but I thought I would post this in case you had any ideas! Thanks again for your help... more than appreciated.
  6. The dropdown is going to be static based on the return from the MySQL query. So you're proposing I will use that to dynamically change the rest of the form? Alex
  7. I am stumped. I have a database similar to this: | Class Number | Class Name | Class Date | 0001 MATH 1/1/2016 0002 SCIENCE 2/1/2016 0003 HISTORY 3/1/2016 I am calling all classes where the date is > current date. All matching classes are then put into a html dropdown box. I would now like to populate two additional fields with the class number and class date based on the selection of the dropdown. I know I'll need to use AJAX, but I am a little stumped on how to get started. My first problem is that I have the beginning of the html select tag before: while($row = $result->fetch_assoc()){ and the end select tag after the }, so I can't put the two additional form fields in the loop. Any tips on where to go from here? Here's what I have so far: <?php // Get required login info include "/secret/path/to/login.php"; $db = new mysqli('localhost', $username, $password, $database); // Connect to DB using required login info if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); } unset($username);// put these variables back to null unset($password);// put these variables back to null unset($database);// put these variables back to null date_default_timezone_set('America/Los_Angeles'); // set default time zone PST $sql = "SELECT * FROM ft_form_7 WHERE class_full != 'Class Full' AND class_start_date > CURRENT_DATE()"; $result = $db->query($sql); if(!$result = $db->query($sql)){ die('There was an error running the query [' . $db->error . ']';} // show error if necessary if(mysqli_num_rows($result) < 1) { (include "/path/to/get-classes-for-registration-no-classes.php"); } echo '<select name="class_drop_down">'; // opens the dropdown box while($row = $result->fetch_assoc()){ echo '<option value="'.$row['class_name'].'">'.$row['class_name'].'</option>'; } echo '</select>'; $db->close(); $result->free(); ?>
  8. Hello, I created a page that gets some information from a MySQL database and displays it on a page. The information is selected based on the ID of the row in the database. So, if ...script.php?id=55 it will display the information from submission ID #55. All of that works great, but I am having difficulty sending it to an error page if someone manually enters an ID number that does not exist. For instance script.php?id=7777 Right now I am using if (mysql_num_rows($result)==0) { die (include "/path/to/public_html/errors/no_classes_selected.php"); } Unfortunately it ALWAYS includes that error page, as it seems $result is always equal to 0 even if the ID number is a real entry. For instance, if I take that line out, and an ID that exists is entered, it displays the data fine. If I leave that code in and I use the same ID, it displays the error page. Am I doing this right? <?php // Get required login info include "/path/to/login_info.php"; $db = new mysqli('localhost', $username, $password, $database); // Connect to DB using required login info if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); } unset($username);// put these variables back to null unset($password);// put these variables back to null unset($database);// put these variables back to null date_default_timezone_set('America/Los_Angeles'); // set default time zone PST // ************GET ID FROM URL*********************** $id = (int)$_GET['id']; // this gets the id from the url if($id != '' && $id > 0) { // this checks to make sure that the ID is an integer // ************************************************** $sql = <<<SQL SELECT ft_form_8.*,ft_form_7.* FROM ft_form_7 LEFT JOIN ft_form_8 ON ft_form_8.Instructor=ft_form_7.Instructor WHERE ft_form_7.submission_id=$id SQL; if(!$result = $db->query($sql)){ // if there is an error in running the query, show error message. die('There was an error running the query [' . $db->error . ']'); } if (mysql_num_rows($result)==0) { die (include "/path/to/public_html/apps/errors/no_classes_selected.php"); } while($row = $result->fetch_assoc()){ // Get start date information $start_date = $row['class_start_date']; // Get event_start_date for conversion and call it $start_date $start_date_formatted = date("l M d, Y", strtotime($start_date)); // Convert start_date $end_date = $row['class_end_date']; // Get event_end_date for conversion and call it $start_date $end_date_formatted = date("M d, Y", strtotime($end_date)); // Convert start_date // Do above for start and end date two for multiple day classes (ex. jan 1-2 and feb 2-3) $start_date_2 = $row['class_start_date_2']; $start_date_2_formatted = date("l M d, Y", strtotime($start_date_2)); $end_date_2 = $row['class_end_date_2']; $end_date_2_formatted = date("M d, Y", strtotime($end_date_2)); // Get time information. $start_time = $row['class_start_time']; // Get event_start_time for conversion and call it $start_time $start_time_formatted = date("h:i A", strtotime($start_time)); // Convert start_time $end_time = $row['class_end_time']; // Get event_end_time for conversion and call it $end_time $end_time_formatted = date("h:i A", strtotime($end_time)); // Convert end_time // echo information... echo "<h2>" , $row['class_name'],"</h2>" ; // echo event name echo "<p><strong>",$start_date_formatted; // echo the start date if (empty($end_date) or $end_date = $start_date) { echo '<br/>'; } else { echo " - ","", $end_date_formatted , "<br />"; } // echo end date if (empty($start_date_2)) {echo '';} else { echo $start_date_2_formatted; } // echo the start date if (empty($end_date_2) or $end_date_2 = $start_date_2) { echo ''; } else { echo " - ","", $end_date_2_formatted , "<br />"; } // echo end date if (empty($start_time)) { echo ''; } else { echo $start_time; } // echo start time if (empty($end_time)) { echo ')'; } else { echo " - ", $end_time; } // echo end time // if there is no start time, echo nothing. (otherwise it seems to echo 4pm). If it does contain a time, echo the time. echo "</strong>"; $chef_full_name = $row['Instructor']; $chef_id = $row['submission_id']; $full_bio = $row['full_bio']; echo "<div class=\"showbio\">" , "<div class=\"underline\">" , $chef_full_name , "</div>"; echo "<div class=\"bio\" style=\"display: none;\">"; echo $full_bio , "</div></div><br />"; echo $row['class_description'], "<br />"; echo "<strong>" , $row['type'], " - Cost: $",$row['cost'] , " - #" , $row['course_number'] , " - <a href=\"registration.php\" target=\"_blank\"> (Register Online)</a> </strong><br />" , "</p>"; // echo class type and cost } $db->close(); $result->free(); } else { die (include "/path/to/public_html/apps/errors/no_id.php"); //display error if ID is not an integer } ?>
  9. There's a whole section to the forum for this: http://forums.phpfreaks.com/forum/77-job-offerings/ There are also lots of freelance websites out there that match people needing work to freelancers. Just google "hire a php programmer". Hope that helps
  10. I have some data that I am displaying: var formatted_marker_data = "<div class=\"map_header\">" + data.formatted_address + "</div> The data.formatted_address is some MySQL data which is formatted like this: 123 Main Street, San Francisco, CA A few of the entries have the lat/lon added to the address: 123 Main Street, San Francisco, CA | 37.7917618,-122.3943405 I do not want to display anything after the | Is there a way to truncate all data after the | ? The only problem I see with that is that it WILL show the |, however I suppose since they are all CA addresses, I could truncate everything after the CA. Then again, if there is an address with a CA in it, then I'm screwed. Any ideas?
  11. Dang it! Ok. Each info window.setContent() is going to have some html with specific variables corresponding to the marker. Maybe I can just insert the php variables in there in the html. I'll play around with it. Thanks!
  12. On the below line of code, I am getting the output for the first item only (data.title). If I put data.url first, I only get that output, etc. I'm new to javascript and may be missing something. Should I not be separating them with ,'s, or is there another way to do this? infowindow.setContent(data.title , data.url , "this is a test"); This is part of a larger google maps app that plots points on a map. Using markers, the line above opens an info window displaying some data about the point. It's working great, except its not displaying all the data as described above. <script type="text/javascript"> $(document).ready(function() { $.getJSON("database-to-json.php", function(json1) { $.each(json1, function(key, data) { var latLng = new google.maps.LatLng(data.lat, data.lng); var marker = new google.maps.Marker({ position: latLng, title: data.title, url: data.url }); marker.setMap(map); google.maps.event.addListener(marker, 'click', function() { infowindow.setContent(data.test , data.title); infowindow.open(map,marker); }); }); }); }); </script>
  13. Most survey applications that require limiting responses to one per person use a token. You will generate a token, or unique set of characters for every user. When the invitation is sent, it will include the token in the URL. When the user completes the survey or vote, the application will mark that token in the database as used. If the user tries to access the survey again, it will not allow it because their token has been used.
  14. I have an application that loads several xml files, and then outputs some of the data from the file. The problem is that every once in a while, the service that provides the xml file does maintenance (or has an error in the file), and my application gives a "Fatal error: Call to a member function children() on a non-object in..." I would like to handle the error differently, by displaying "unavailable" instead of the error. I know that this is usually not the appropriate way of handling errors, because there is a reason for a fatal error. Any ideas on how to appropriately handle this error? // Node 217 (GGB) $xml = simplexml_load_file("http://services.my511.org/traffic/API_KEY_REMOVED_FOR_EXAMPLE"); foreach($xml->children() as $traveltime) { $ggb = "$traveltime->currentTravelTime"; } ​echo "GGB:" , $ggb , " Minutes";
  15. I have data similar to below. I am doing a MySQL query and doing a JOIN based on instructor name. I am echoing classes and linking the instructor name to another page with their BIO. All is working great, however I want to use the ID's for something else. How do I differentiate the ID between the Instructors table and the Classes Table without changing the column name in the database? For instance, I want to echo the Instructor ID and then echo the Classes ID, but they are both the same column name in the database and since they are joined, how will that work? Instructors: ID | Instructor | Title | Bio | 1 | Bob Smith | Chef | bob smith is a chef with... | 2 | Jane Doe | Professor | Jane doe is an instructor that... | Classes: ID | Instructor | Class Title | Class Description | 4 | Bob Smith | Baking | this is a baking class where you learn.... | 5 | Jane Doe | Food Safety | Food safety is very important... |
  16. Worked like a charm, thanks!! And yes, that was my bad with the ID instead of class ;-)
  17. I have a script that runs a MySQL query and loops through a bunch of results. For each person's name, I have a short bio that I want to show/hide by clicking on the person's name. I have a basic start, but I can't figure out how to show/hide them individually. When I click on someone's name, it shows/hides all of the bio's. I do have an individual ID for each person, and could use that somehow, but I'm scratching my head trying to figure out how to accomplish that. Any ideas? http://jsfiddle.net/APA2S/3644/
  18. Thank you both very much. I definitely want to do this the right way. I did some reading on using JOIN, and that seems like the way to go. I am a little stuck on building that query, but I will keep working to get it right! Thanks again!
  19. Main script gets class information from a database and prints them so long as the class start date or end date is after today (actually includes today). Main script calls "instructors.php". It queries another database based on the instructor name ($chef) and then prints the bio information for that instructor. "instructors.php" works fine on it's own, when I add "$chef = "Chef Name" ("Chef Name" is in the Instructors database). When it's called from the main script, nothing shows up in that area - even though "Chef Name" is in the database. All of the other data is printed fine, just not anything from instructors.php. I verified that it's actually including the file, as I can add "echo "test";" to the top of instructors.php and it prints fine in the main script. Any ideas of what I'm missing? Main Script <?php // Get required login info include "/path/to/login/info/file.php"; // Get required login info - changed for this post. $db = new mysqli('localhost', $username, $password, $database); // Connect to DB using required login info if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); } unset($username);// put these variables back to null unset($password);// put these variables back to null unset($database);// put these variables back to null //query db $sql = <<<SQL SELECT * FROM `ft_form_7` WHERE DATE(class_start_date) >= CURDATE() OR DATE(class_end_date) >= CURDATE() ORDER BY class_start_date ASC SQL; if(!$result = $db->query($sql)){ // if there is an error in running the query, show error message. die('There was an error running the query [' . $db->error . ']'); } while($row = $result->fetch_assoc()){ // Get start date information $start_date = $row['class_start_date']; // Get event_start_date for conversion and call it $start_date $start_date_formatted = date("l M d, Y", strtotime($start_date)); // Convert start_date $end_date = $row['class_end_date']; // Get event_end_date for conversion and call it $start_date $end_date_formatted = date("M d, Y", strtotime($end_date)); // Convert start_date // Get time information. $start_time = $row['class_start_time']; // Get event_start_time for conversion and call it $start_time $start_time_formatted = date("h:i A", strtotime($start_time)); // Convert start_time $end_time = $row['class_end_time']; // Get event_end_time for conversion and call it $end_time $end_time_formatted = date("h:i A", strtotime($end_time)); // Convert end_time // echo information... echo "<h2>" , $row['class_name'],"</h2>" ; // echo event name echo "<p><strong>",$start_date_formatted; // echo the start date if (empty($start_time)) { echo ''; } else { echo " (", $start_time; } // echo start time if (empty($end_date)) { echo ''; } else { echo " -","<br />", $end_date_formatted; } // echo end date if (empty($end_time)) { echo ')'; } else { echo " - ", $end_time, ")"; } // echo end time // if there is no start time, echo nothing. (otherwise it seems to echo 4pm). If it does contain a time, echo the time. echo "</strong><br />"; $chef = $row['Instructor']; global $chef; if ($chef != NULL) { require ('instructors.php'); } echo $row['class_description'], "<br />"; echo "<strong>" , $row['type'], " - Cost: $",$row['cost'] , " - #" , $row['course_number'] , "</strong><br />" , "</p>"; // echo class type and cost } $db->close(); $result->free(); ?> instructors.php <?php include "/path/to/login/info/file.php"; // Get required login info - changed for this post. $db_instructors = new mysqli('localhost', $username, $password, $database); // Connect to DB using required login info if($db_instructors->connect_errno > 0){ die('Unable to connect to database [' . $db_instructors->connect_error . ']'); } unset($username);// put these variables back to null unset($password);// put these variables back to null unset($database);// put these variables back to null //query db $sql_instructors = <<<SQL SELECT * FROM ft_form_8 WHERE chef_name = '$chef' SQL; if(!$result_instructors = $db_instructors->query($sql_instructors)) { // if there is an error in running the query, show error message. die('There was an error running the query [' . $db_instructors->error . ']'); } while($row_instructors = $result_instructors->fetch_assoc()) { $chef_full_name = $row_instructors['chef_name']; $chef_id = $row_instructors['submission_id']; $full_bio = $row_instructors['full_bio']; echo "<a href=\"#\" class=\"clickme\">" , $chef_full_name , "</a>"; echo "<div class=\"box\">"; echo $full_bio , "</div>"; } $db_instructors->close(); $result_instructors->free(); ?>
  20. I am using php require to input a page of code. I am including (require) that file several times within the page. I am guessing that it executes the file every time, and does not save any page loading time, and in fact probably slowing it down because it has to make the request every time. Just wanted an expert to confirm or deny my educated guess. Would it be the same if it were including an html file instead of a php file? <?php require ("$base_path/main_page_rotation/content4.php"); ?>
  21. Code: http://jsfiddle.net/3yN8a/126/ I am looking to keep the div including the text ("testing") static, so it does not fade with the background image. Any ideas of where to start? Thanks! Alex
  22. Perfect. As long as I remember to check against lower case ;-) You saved the day again...
  23. Is there a way to change the statement below so that it ignores case sensitivity of the variable? for instance, the statement would be true if $category == 'Admissions', 'ADMISSIONS', 'admissions', etc. For some reason I'm having the worst time finding this via google search and know y'all will be able to help! if ($category == 'Admissions') { echo ' <a href="#">-Forms</a><br /> <a href="#">-Tuition</a><br />'; } ?> Thanks!
×
×
  • 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.