PHP - Php Forms Editing .txt Within Site | Events 'puzzle'
I am very new to PHP and very eager to just understand all of the stuff i have been desperately trying to get to work for the last week. I decided to give up on copy pasting and actually find help.
My main project right now is this: I want to have a website that I can edit from within a logged in section of the site (I've got the login part figured out - that is I have some code that at least has a pass and usrnm). I have a events page with 4 events, each event consisting of date, header and text: Code: [Select] <div id="event"> <p class="date"> <? include_once('date.txt')?> </p> <h3> <? include_once('header.txt')?> </h3> <p class="eventinfo"> <? include_once('text.txt')?> </p> </div> I use .txt includes so that I can edit the actual texts inside of a form. My first attempt was to edit each file inside of one page. Failed due to Code: [Select] <?php echo $_SERVER["PHP_SELF"] ?>. Second attempt was to have the page get edit.php file: Code: [Select] <?php $fn1 = 'date.txt'; if (isset($_POST['content'])) { $content = stripslashes($_POST['content']); $fp1 = fopen($fn1,"w") or die ("Error opening file in write mode!"); fputs($fp1,$content); fclose($fp1) echo("Date has been saved") or die ("Error closing file!"); } ?> <form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post"> <textarea rows="5" cols="40" name="content"><?php readfile($fn1); ?></textarea> <input type="submit" value="Save"/> </form> And have the page reload and get edit header section, then reload again for the text. But didn't see how to do this without making three pages. What I want is that I can within at least tow pages do all the following: Login, choose which event to edit, then adit all three parts and save. My brains are fried from the combination of learning PHP and being over excited about having a working system. Hopefull for some answers! Thanks!! PS: my events page http://naturalhorse.me/sites/testing/events.php Thanks, Isa. Similar TutorialsI am a little confused with the difference between Symfony Events and Event Listners and Doctrine Events. The Doctrine events look pretty straight forward and are primary used for entity persistence, and I have outlined my understanding below: Doctrine Lifecycle Callbacks. Single entity and single Doctrine event. Method in class. Good performance. Don't have access to Symfony services (all others do) Doctrine Lifecycle Listeners. All entities and single Doctrine event. Separate class and configured in config.service.yaml. Doctrine Entity Listeners. Single entities and single Doctrine event. Separate class and configured in config.service.yaml. Doctrine Lifecycle Subscribers. All entities and multiple Doctrine event. Must implement EventSubscriber (or probably EventSubscriberInterface) Separate class and configured in config.service.yaml.I am more confused with the Symfony events and my interpretation as listed below is likely incorrect. Symfony Event Listeners. Single Symfony event. Separate class and configured in config.service.yaml. More flexible because bundles can enable or disable each of them conditionally depending on some configuration value. Symfony Event Subscribers. All specified Symfony events. Must implement EventSubscriberInterface Separate class but NOT configured in config.service.yaml but in class. Easier to reuse because the knowledge of the events is kept in the class rather than in the service definition.Are they used for totally different purposes or can one use Symfony events to also deal with entities? Where would one want to use these Symfony events? Is there a reason why Doctrine Lifecycle Subscribers are located in src/EventListener and not src/EventSubscriber Are Doctrine Lifecycle and Entity Listeners really only for a single event as I interpret the documentation states, or is it one method per Doctrine event such as the following? App\EventListener\SearchIndexer: tags: - name: 'doctrine.event_listener' event: 'postPersist' - name: 'doctrine.event_listener' event: 'postUpdate'
So i have this CMS that is used by lots of users and generally they do have rights to edit each others article. So now i'm thinking how can i at least warn them that somebody else is already editing it. Just that. maybe with sessions? but what happens when a user just closes the windows, will it destroy it. i taught about storing the value to mySQL but again what if the user closes the windows and so on. i never did this and i could use a boost. thanks guys Hello dear friends, My mind no longer able to think about it so please help me let say we have 2 database tables Table_one (id,user,code) example user can post many codes (1,user1,code1) (2,user1,code2) (3,user2,code3) (4,user3,code4) Table_Two (id,code,hits) example (1,code1,100) (2,code2,50) (3,code3,40) (4,code4,80) the common between both is the code but i wanna say Get me the sum of hits - of - all codes that is only for user1 i did tried this but didn't works logically maybe by saying Code: [Select] $sql = "SELECT COUNT(hits) AS totalhits FROM table1,table2 Where table2.code=table1.code and table1.code=?????????"; $cus= mysql_query($sql) or die($sql); $count = mysql_fetch_array($cus); if we know how to say instead of ???????? the following; and table1.code added by user1 maybe we can get it right can we really get it thanks results should be totalhist = 150 I am trying to write a script for a puzzle based on the user's IP address, but I just can't wrap my head around how to do it. Essentially, when the visitor loads the page two things happen: (1) a PHP application returns an image to serve as a background for the formula, (2) implement the algorithm of generating the formula based on IP, that is displayed on the image.
The puzzle itself would be in the form of ABC.DEF.GHI.JKL where each letter would be associated with the corresponding digit in their IP addy. The user is trying to solve for partial map coordinates. So, let's say the correct answer is N 35 54.374 W 084 01.829 and the user's IP is 075.036.025.058. The formula returned and placed on the image would be N 35 54. (E) (B) (F - H) W 084 01. (L) (H) (B + H) Whatever I use as the final correct answer will not change and be the same for all users; only the puzzle formula would differ for each user as it would be based on their IP at the moment. Any help here would be greatly appreciated. Thanks! Gary Good Evening, I have a working knowledge or HTML/CSS and right now I am learning/reading about PHP. Currently I am looking to build a website around an events calendar, let me explain more. A user would log onto the site, submit a form (with an event), this would then be added to a calendar as well a new page for the event details. The calendar would be fully visible to an visitor to the site. I would also like the ability to add a ticker on the homepage with the latest events added. How complicated is this to implement? And what are the basic requirements? I hope this makes sense. Thanks, Cain i have an events script that displays upcoming events, and i just add the event in a simple form, stores in database and shows on my control panel, and the clients control panel ( only clients events ) firstly what is the best way to sort by date? i enter the date into a text field like 12-04-11 but this when sorted doesnt appear in upcoming first? then secondly how cani have it so, past events no longer show up so, if date = > today do not show? I am working on a small project, creating a calendar based booking system which includes the following features: 1) A color coded key for Booked days, Available, Partly Booked, Off Days 2) Clickable days which open up a form with available time slots 3) When time slots selected another form which allows the user to enter details about the event and then book the day
I am using php, sql to complete the project. I am aware that there are scripts available online but i want to do this from scratch.
Stuck On The code below is for a php calendar, above is what i need to achieve. Please can someone help me on how to complete this. <?php $monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); ?> <?php if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n"); if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y"); ?> <?php $cMonth = $_REQUEST["month"]; $cYear = $_REQUEST["year"]; $prev_year = $cYear; $next_year = $cYear; $prev_month = $cMonth-1; $next_month = $cMonth+1; if ($prev_month == 0 ) { $prev_month = 12; $prev_year = $cYear - 1; } if ($next_month == 13 ) { $next_month = 1; $next_year = $cYear + 1; } ?> <table width="400" border="5" align="center"> <tr align="center"> <td bgcolor="#999999" style="color:#FFFFFF"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="50%" align="left"> <a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF">Previous</a></td> <td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF">Next</a> </td> </tr> </table> </td> </tr> <tr> <td align="center"> <table width="100%" border="2" cellpadding="2" cellspacing="2"> <tr align="center"> <td colspan="7" bgcolor="#999999" style="color:#FFFFFF"> <strong> <?php echo $monthNames[$cMonth-1].' '.$cYear; ?> </strong> </td> </tr> <tr> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>M</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>W</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>F</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td> </tr> <?php $timestamp = mktime(0,0,0,$cMonth,1,$cYear); $maxday = date("t",$timestamp); $thismonth = getdate ($timestamp); $startday = $thismonth['wday']; for ($i=0; $i<($maxday+$startday); $i++) { if(($i % 7) == 0 ) echo "<tr> "; if($i < $startday) echo "<td></td> "; else echo "<td align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td> "; if(($i % 7) == 6 ) echo "</tr> "; } ?> </table> </td> </tr> </table> It's working great, but at some points after one of the random events goes through, I reload the page and it either gives me or takes away some starpoints without showing the message.. but it shows the message all the other times. Could someone help me debug this and see why it's doing that? Code: [Select] <?php include("config.php"); //To change the odds, change the second number in the rand() function. $rand = rand(1,3); if($rand == 1) { $sql = "SELECT * FROM randomevents WHERE rarity <= '10'"; $result = mysqli_query($cxn, $sql); //Write the events in here with the opener: $event[] = "#your event#"; while ($row = mysqli_fetch_assoc($result)) { $event[] = $row['phrase']; } //This will pick a random event and show it $renum = rand(0,count($event)); $display = $event[$renum]; if ($display == "") { $eventdisplay = ""; } else { $eventdisplay = "<table cellspacing=\"0\" class=\"events\" align=\"center\"><br> <tr><br> <td><center><b><h1>Random Event</h1></b></center></td><br> </tr><br> <tr><br> <td><img src=\"".$_SERVER['SCRIPT_NAME']."\"> <p><center>".$display."</center></p><br> </td><br> </table><br>"; $sql = "SELECT type FROM randomevents WHERE phrase='".$display."'"; $result = mysqli_query($cxn, $sql); $row = mysqli_fetch_assoc($result); if ($row['type'] == "gainsp") { $rand = rand(200,500); $sql = "UPDATE members SET starpoints = starpoints+$rand WHERE userid='".$_SESSION['userid']."'"; mysqli_query($cxn, $sql) or die("Query died: updating starpoints"); } elseif ($row['type'] == "losesp") { $rand = rand(50,100); $sql = "UPDATE members SET starpoints = starpoints-$rand WHERE userid='".$_SESSION['userid']."'"; mysqli_query($cxn, $sql) or die("Query died: updating starpoints"); } else {} } } else { $eventdisplay = ""; } ?> Does anybody know of a calendar script that can handle reoccurring events ? I want to make a calendar that shows the schedule of a teacher in a school. most classes are weekly but some are only once a month or held irregular. classes are 50 minuter or sometimes 30 minutes. Preferably I would like to set the start time and end time of a class with a precision of 10 minutes. The output should be a html page that shows the weekly schedule with the days as columns and the hours as rows. Anybody knows of something similar or something I could use as a starting point ? thanks anatak I am trying to populate my even calendar with, well, events that are stored in a mysql table. I came across the following code and modified the query to work in my case. The code used mysql_query(), but I am using mysqli_query(), and for some reason it gets to that point and dies, but mysqli_error() doesn't even run; I just get "Error1:" If I take out the query part and only build the calendar it work perfectly. Does mysqli_query() not work inside a for loop? This hit my database for every day of the month, is there a better way? I also thought about running a query to pull all results then doing array_filter() inside the for loop for each day. Does this even work? I can't seem to figure it out. Code: [Select] ..... for($list_day = '1'; $list_day <= $days_in_month; $list_day++) { if($list_day == $today && $month == $nowmonth && $year == $nowyear) { $calendar.= '<td class="calendar-day-today">'; } else { $calendar.= '<td class="calendar-day">'; } /* add in the day number */ $todaydate = $year.'-'.$month.'-'.$list_day; $calendar.= '<div class="day-number" onclick=window.location.href="viewday.php?name='.$_SESSION['username'].'&id='.$todaydate.'">'.$list_day.'</div>'; $y = 0; if(strlen($x) == '1') {$x = $y.$x; } /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/ $todaydate = $year.'-'.$month.'-'.$list_day; $query = "SELECT * FROM health WHERE '$todaydate' >= event_start AND '$todaydate' <= event_end"; $results = mysqli_query($dbc, $query) or die ('Error1: '.mysqli_error($dbc)); if (mysqli_num_rows($results) > '0') { while($row = mysqli_fetch_array($results)){ extract($row); ...... I am open to any other suggestions also. Thanks for the help! Hi peps, I am trying to write a script that allows for events to be executed at any given time that user gives it like if the user wants it at 2 am the event will execute at that given time i read some answer they say use cron but im using windows how to do it ?? I want to only show Events that occur in October. I'm a little unsure how to modify this code... Code: [Select] // Build query. $q = 'SELECT name, location, dateandtime FROM topic WHERE dateandtime=?'; // Prepare statement. $stmt = mysqli_prepare($dbc, $q); // Bind variable. mysqli_stmt_bind_param($stmt, 'i', $id); Is there a PHP function that I should use? Or do I just use a conditional? And not sure if I even need a bound variable here. Debbie Ok, so I have made 12 columns in mysql for each month.........I will have an event manager page that you can select each month that the event will take place in 0 is false 1 is true.........so I need to know how I can edit this code so that if the current month equals whatever month is checked, it will display..........is there a way to do this????????or would I need to use a date format instead of varchar and use a format such as yyyy-mm-dd and value = 0000/mm/00 so that only the month will display and then it could equal current month? Code: [Select] <?php // if no id is specified, list the available articles if(!isset($_GET['eventid'])) { $query = "SELECT eventid, event, startdate, enddate FROM Registration ORDER BY eventid"; $result = mysql_query($query) or die('Error : ' . mysql_error()); // create the article list while($row = mysql_fetch_array($result, MYSQL_NUM)) { list($eventid, $event, $startdate, $enddate) = $row; $as .= "<p><a href=\"viewevent.php?eventid=$eventid\">$startdate - $enddate --- $event</a></p>\r\n"; } $Events = 'Events'; } else { // get the article info from database $query = "SELECT event, description, startdate, enddate, location, subevent1, subevent2, subevent3, subevent4, subevent5, subevent6, subevent7, subevent8, price1, price2, price3, price4, price5, price6, price7, price8 FROM Registration WHERE eventid=".$_GET['eventid']; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $startdate = $row['startdate']; $enddate = $row['enddate']; $location = $row['location']; $description = $row['description']; $event= $row["event"]; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; $title1 = $row['title1']; $title2 = $row['title2']; $title3 = $row['title3']; $title4 = $row['title4']; $title5 = $row['title5']; $title6 = $row['title6']; $title7 = $row['title7']; $title8 = $row['title8']; $price1 = $row['price1']; $price2 = $row['price2']; $price3 = $row['price3']; $price4 = $row['price4']; $price5 = $row['price5']; $price6 = $row['price6']; $price7 = $row['price7']; $price8 = $row['price8']; $date1 = $row['date1']; $date2 = $row['date2']; $date3 = $row['date3']; $date4 = $row['date4']; $date5 = $row['date5']; $date6 = $row['date6']; $date7 = $row['date7']; $date8 = $row['date8']; } ?> Code: [Select] <table width="410" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="339" bgcolor="#999999" scope="col">EVENTS</td> </tr> <tr> <td class="afasd"><?php echo date("F",strtotime("-0 month")); ?></td> </tr> <tr> <td><?php echo $as; ?></td> </tr> <tr> <td class="adfaf"><?php echo date("F",strtotime("+1 month")); ?></td> </tr> <tr> <td><?php echo $as; ?></td> </tr> <tr> <td class="jasdfjs"><?php echo date("F",strtotime("+2 month")); ?></td> </tr> <tr> <td><?php echo $as; ?></td> </tr> </table> does this make sense? I'm not sure how to put in a tab when editing php with php $fh = fopen(MYBB_ROOT.'/member.php', "r") or cperror("Could not open file!"); //OPEN FILE $data = fread($fh, filesize(MYBB_ROOT.'/member.php')) or cperror("Could not read file!"); //MAKE TEMPORARY STRING fclose($fh); //CLOSE FILE AGAIN $newdata = preg_replace('#'.preg_quote('eval("\$online_status = \"".$templates->get("member_profile_online")."\";"); if(is_super_admin($memprofile[\'uid\'])){ eval("\$online_status = \"".$templates->get("unknownlocation")."\";"); }').'#','\t\teval("\\\\$online_status = \"".$templates->get("member_profile_online")."\";");',$data); //REPLACE IN STRING $fw = fopen(MYBB_ROOT.'/member.php', "w") or cperror('Could not open file!'); //OPEN FILE AGAIN $fb = fwrite($fw, $newdata) or cperror('Could not write to file'); //WRITE STRING TO FILE fclose($fw); //CLOSE FILE AGAIN } I need to tab that line twice so it lines up in the file, i've tried putting \t in twice but that doesn't work and just gives this error Fatal error: Call to undefined function teval() in /Applications/XAMPP/xamppfiles/htdocs/member.php on line 1621 So, how to you put tabs in? Thanks Hi, I want to post a simple comments box at the bottom of one of my web pages that will send the data from 4 different inputs, named "email," "name," "comments," and "telephone," to my email. Can someone look at my php code and see what is wrong? The website code box works great if I enter in all the fields, however if the email box is not filled out and you click the submit button, it displays "Invalid email address enteredThank you for your message, we will be in touch shortly" How do I get rid of "Thank you for your message, we will be in touch shortly" Also, it sends the email even if the ['Name'] tag is not filled out, I not sure how to make it required. By the way, I'm new to php, so sorry if this is a little hard to understand. Link to website: http://www.raysmasonryconcrete.com/contact.html Code: [Select] <!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 content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Send Data Form</title> </head> <body> <?php if(!$_POST) exit; $email = $_POST['Email']; $name = $_POST['Name']; $telephone = $_POST['Telephone']; $comments = $_POST['Comments']; //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS'; if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){ $error.="Invalid email address entered"; $errors=1; } if($errors==1) echo $error; else{ $values = array ('Name','Email','Telephone','Comments'); $required = array('Name','Email','Telephone','Comments'); $your_email = "*****"; $email_subject = "Message From the HDS Builders Website:"; foreach($values as $key => $value){ if(in_array($value,$required)){ if ($key != 'Name' && $key != 'Comments' && $key != 'Telephone') { if( empty($_POST[$value]) ) { echo 'Please go back and complete all fields, thank you.'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } } $headers = "From: $email\r\n"."Reply-To: $email\r\n".'X-Mailer: PHP/' . phpversion(); if(@mail($your_email, $email_subject, $email_content, $headers)) { echo 'Thank you for your message, we will be in touch shortly'; } else { echo 'ERROR!'; } ?> </body> </html> Not sure if I posted this in the right board: As I'm setting up a plugin to parse Google Calendar events, when they are set as All Day events, they "end" at midnight, which pushes them into the next day. So if an event is to run All Day Friday, Saturday, and Sunday, it actually shows the end date as Monday, since it's midnight. Any thoughts? i want to share my problem in my website For the better understandng of my website, I want to tell all the details. 1. I have a database and i has a 2 tables 1 for the tbllogin which consist of Username and Department, and the second table is caltbl which i use for the calendar events. 2.When my website run the first webpage is the login form. If the Username and Department is correct she can browse the other webpages, like the calendar event. 3. In the calendar event you can see the calendar and when you click the date theirs a link "new event" appear and if theirs no existing event theres a text saying "No Events", when you click the link you can add events. I want that theirs a specific person that can only add events for the restriction of adding events. I want to happen that if the user is xxx and her department is yyy the link shoud appear and she can add events. i want that only to her the link should be appear.. here is my code: <?php $host = "localhost"; $username = ""; $password = ""; $dbCnx = @mysql_connect($host, $username, $password) or die('Could not Connect to the database'); $dbName = 'dspi'; mysql_select_db($dbName); ?> <script> function goLastMonth(month, year){ // If the month is January, decrement the year if(month == 1){ --year; month = 13; } document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year; } //next function function goNextMonth(month, year){ // If the month is December, increment the year if(month == 12){ ++year; month = 0; } document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year; } function remChars(txtControl, txtCount, intMaxLength) { if(txtControl.value.length > intMaxLength) txtControl.value = txtControl.value.substring(0, (intMaxLength-1)); else txtCount.value = intMaxLength - txtControl.value.length; } function checkFilled() { var filled = 0 var x = document.form1.calName.value; //x = x.replace(/^\s+/,""); // strip leading spaces if (x.length > 0) {filled ++} var y = document.form1.calDesc.value; //y = y.replace(/^s+/,""); // strip leading spaces if (y.length > 0) {filled ++} if (filled == 2) { document.getElementById("Submit").disabled = false; } else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased } </script> <html> <body> <?php //$todaysDate = date("n/j/Y"); //echo $todaysDate; // Get values from query string $day = (isset($_GET["day"])) ? $_GET['day'] : ""; $month = (isset($_GET["month"])) ? $_GET['month'] : ""; $year = (isset($_GET["year"])) ? $_GET['year'] : ""; //comparaters for today's date //$todaysDate = date("n/j/Y"); //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : ""; //$what = (isset($_GET["what"])) ? $_GET['what'] : ""; //$day = (!isset($day)) ? $day = date("j") : $day = ""; if(empty($day)){ $day = date("j"); } if(empty($month)){ $month = date("n"); } if(empty($year)){ $year = date("Y"); } //set up vars for calendar etc $currentTimeStamp = strtotime("$year-$month-$day"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); $counter = 0; //$numEventsThisMonth = 0; //$hasEvent = false; //$todaysEvents = ""; //run a selec statement to hi-light the days function hiLightEvt($eMonth,$eDay,$eYear){ //$tDayName = date("l"); $todaysDate = date("n/j/Y"); $dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; if($todaysDate == $dateToCompare){ //$aClass = '<span>' . $tDayName . '</span>'; $aClass='class="today"'; }else{ //$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; //echo $todaysDate; //return; $sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'"; //echo $sql; //return; $result = mysql_query($sql); while($row= mysql_fetch_array($result)){ if($row['eCount'] >=1){ $aClass = 'class="event"'; }elseif($row['eCount'] ==0){ $aClass ='class="normal"'; } } } return $aClass; } ?> <div id="Calendar_Event"> <table width="350" cellpadding="0" cellspacing="0"> <tr> <td width="50" colspan="1"> <input type="button" value=" < " onClick="goLastMonth(<?php echo $month . ", " . $year; ?>);"> </td> <td width="250" colspan="5"> <span class="title" style="color:#FFFFFF"><?php echo $monthName . " " . $year; ?></span><br> </td> <td width="50" colspan="1" align="right"> <input type="button" value=" > " onClick="goNextMonth(<?php echo $month . ", " . $year; ?>);"> </td> </tr> <tr> <th>M</td> <th>T</td> <th>W</td> <th>T</td> <th>F</td> <th>S</td> <th>S</td> </tr> <tr> <?php for($i = 1; $i < $numDays+1; $i++, $counter++){ $dateToCompare = $month . '/' . $i . '/' . $year; $timeStamp = strtotime("$year-$month-$i"); //echo $timeStamp . '<br/>'; if($i == 1){ // Workout when the first day of the month is $firstDay = date("N", $timeStamp); for($j = 1; $j < $firstDay; $j++, $counter++){ echo "<td> </td>"; } } if($counter % 7 == 0 ){ ?> </tr><tr> <?php } ?> <!--right here--><td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a></td> <?php } ?> </table> </div> <div id="New_Event"> <?php if(isset($_GET['v'])){ if(isset($_POST['Submit'])){ $sql="insert into calTbl(calName,calDesc,calDate,calStamp) values('" . $_POST['calName'] ."','" . $_POST['calDesc'] . "','" . $_POST['calDate'] . "',now())"; mysql_query($sql); } $sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; //echo $sql; //return; $result = mysql_query($sql); $numRows = mysql_num_rows($result); $check=mysql_query("SELECT * FROM tbllogin WHERE Username='rhoda.barrera@dunlop.ph' AND Department='MIS'"); if (mysql_num_rows($check)>0){ ?> <a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">Add Even</a><a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">t</a><?php }else{ echo 'You cannot Add New Event'; }?> </div> <div id="Cal_Event"> <?php if(isset($_GET['f'])){ include 'calForm.php'; } if($numRows == 0 ){ echo ''; }else{ //echo '<ul>'; echo '<h3>Event Listed</h3>'; while($row = mysql_fetch_array($result)){ ?> <h5><?=$row['calName'];?></h5> <?=$row['calDesc'];?><br/> Listed On: <?=$row['calStamp'];?> <?php } } } ?> </div> </body> </html> I'm trying to show the progress of executing a python script in PHP with a progress bar. I found a link (https://www.htmlgoodies.com/beyond/php/show-progress-report-for-long-running-php-scripts.html) that uses SSE to send progress updates to the client. In the original code, a loop is used to simulate a long script but in my case I'm trying to execute a python script that takes roughly 50 seconds. index.php
<!DOCTYPE html> process.php
<?php
function send_message($id, $message, $progress) {
echo "id: $id" . PHP_EOL;
ob_flush();
send_message('CLOSE', 'Process complete'); Problem: As you can see in process.php I commented the original code and placed a simple python execution in php. I just want to diplay the progress of the script but it is not doing so. What do I have to do to show the progress of the script? Note: I don't think is relavent but the python script just opens up a batch file. Are there other methods to display the progress bar of a script in php? Hi guys, Im having problem on how to achieved this one.. I would like to get the all event of this month (April ) Starting todays date.. Code: (php) [Select] $now = gmdate("Y-m-d", mktime(gmdate("H")+8, gmdate("i"), gmdate("s"), gmdate("m"), gmdate("d")+8, gmdate("Y"))); $week = gmdate("Y-m-d", mktime(gmdate("H")+8, gmdate("i"), gmdate("s"), gmdate("m"), gmdate("d")+30, gmdate("Y"))); if ($result = mysql_query("SELECT * FROM fiesta WHERE sta_date BETWEEN '$now' AND '$week' ORDER BY sta_date LIMIT 10")){ if (mysql_num_rows($result)) { $return = ''; while ($row = mysql_fetch_array( $result )) { $date = date("D",strtotime($row["sta_date"])); $return .= "<a href='sta.php' style='font-size:11px;' title='" . $row['fiesta_brgy'] . " " . $row['fiesta_town'] . "'>" . $row['fiesta_brgy'] . " " . $row['fiesta_town'] . "</a> ($date), "; } echo rtrim($return, ', '); } } The result of this query will include the events on May.. How can i display only the event on this month(April)? starting todays date. Thank you |