PHP - Help With The Third Year Project
So I have decided to do research as my project and gain something from this. But also I will have to include programming which i prefer PHP. and will be testing these for my research. Does this sound like a good project and also If it is good sound.. Where do I start?... need a starting point and then I could go on to doing it.. Similar TutorialsHi everyone, this is my first time in this forum and I really need to seek some help from much more experienced PHP coders. My Final Year Project requires me to create a questionnaire to collect Profiling Data from the students. However with only half a year's experience with PHP coding, we find our knowledge rather insufficient at this point. Currently we have created a simple questionnaire with a simple search engine [attached] However now we have been requested to create a questionnaire where it is able to edit, add, remove questions from the questionnaire online itself without the need to go backend. Looking at some tutorials and other posts on this forum, I realised that the "hardcoding" we did, by putting all the questions/answers in to the HTML code itself instead of pulling it out from the database in SQL will cause difficulties. Thus I have decided to build the whole survey from scratch where the questions and answers are all stored in the SQL database itself. Help needed : > How should I actually create my database? What is in my mind now is to create a database with tables as such: Questionslist (Storing questions) id, questionid, question Answerslist (Storing options for questions male,female etc.) id, questionid, option > I currently have no clue how to start creating a page where I can add/edit/remove the questions in the questionnaire. Any example on how to start? > I roughly have an idea on how to edit or remove the questions the questions, but how do I add a question with the choice of making it a TEXT option, or a RADIO BUTTON option or a LIST option and have it add that question into my table of questionlist and answerlist as well? Currently using Adobe Dreamweaver CS5 and HeidiSQL for this project. We have requested a webspace from the school itself to host this questionnaire as well. If anyone needs more infomation to be able to assist me, I would gladly provide. With Thanks, Shawn [attachment deleted by admin] Hello, i have two fields. a beginning year and an ending year. How can i make new fields out of the years in between the beginning and ending years. i hope that makes sense. Why does this work: $dateAllowedSelect = date('Y') -18; But this doesn't: $dateAllowedSelect = date('Y') +5; I nee to get the current year plus 2010 - 2015 in a select box. Thank you. I need help with a query.
I've got a table that stores references to calls that come in to our office. It has a datetime field, and for the purposes of the query, it's the only thing in this table that is important.
I've got another table that stores appointment information. The appointment start time is also a datetime field. For this query, this start time is the only thing in this table that is important.
I need to know how many times in the last year there was a day when we had at least 150 calls come in and made at least 1 appointment.
SELECT COUNT(*) FROM appointments a LEFT JOIN ( SELECT DATE(time) FROM calls WHERE <there are at least 150 calls on a day> ) c ON DATE(a.start_time) = c.time WHERE a.start_time >= CURDATE() - INTERVAL 1 YEARTo make things difficult, I guess the time would have to be converted to a day, because I'm looking for all days where there was an appointment, and the datetime field is too specific. I've been looking online for 30 mins or so, and was hoping somebody here could point me in the right direction. I'm not making much progress by myself. Edited by sKunKbad, 06 October 2014 - 01:17 PM. Hello, I seem to be having a problem. I am trying to extract the year from a date Code: [Select] 2012-03-01 echo "2012"; I have tried this and it only displays 1969 $dateorig = "2012-03-01"; $new_year = date("Y", strtotime($dateorig)); echo $new_year; I am using the following code to sort by Year. It displays the current year fine and current year also displays in selection but does give the option for the previous years selection. Code: [Select] <form action="archivednews.php" method="post"> <select name="year" id="year"> <?PHP for($i=date("Y"); $i<=date("Y"); $i++) if($year == $i) echo "<option value='$i' selected>$i</option>"; else echo "<option value='$i'>$i</option>"; ?> </select> <input type="submit" value="GO"> </form> Gud Pm! Im trying to display a list of years (last year, current year and next year) with these simple code i made.. It displays the current and next year correctly except last year, which gives me "1970". I don't get why it gives me that since may next year works properly.. Code: [Select] $currentyear = date('Y'); $subtract_year = strtotime(date('Y', strtotime($currentyear)) . '-1 year'); $lastyear = date('Y', $subtract_year); $addyear = strtotime(date('Y', strtotime($currentyear)) . '+1 year'); $newyear = date('Y', $addyear); $year_array = array($lastyear, $currentyear, $newyear); foreach($year_array as $year) { echo "<option value='{$year}'>"; echo $year; echo "</option>"; } I'm not familiar with dates yet.. so i'm gonna read the manual while w8ting for your kind replies. Okay I am trying to list out years in a dropdown box. It should show say how many years old. I want to start from 16 though and stop at 100. So the year has to be 1995 for 16 but then I would have to change the code every year. so I was wondering how do I modify this code to do what I explained? Code: [Select] <?php $start_year = ($start_year) ? $start_year - 1 : date('Y') - 100; $end_year = ($end_year) ? $end_year : date('Y'); for ($i = $end_year; $i > $start_year; $i -= 1) { $date=date(Y); $age = $i - $date; echo '<option value="'.$i.'">'.$age.'</option>'; } ?> Thanks in advanced Hello there, I stuck in a silly logic ... I will really appreciate if someone helps me... My Fiscal year starts from 01st April of current year through 31st March of next year, for ex. (01 Apr 2011 to 31st March 2012). I want to put a latefee of 6.25% on total amount, if the payment date is not done on the current fiscal year. Everything depends on the payment date. For example, A bill of $8000 was generated on 01st Apr. 2009 then its 6.25% will be $500 and the customer is paying the same on 30th August 2011, then total years passed is 3. So, the late fee will be 500 * 2 = $1000. i.e. Any bill generated and paid in the current fiscal year (stated above) is free of late fee and after that the above calculation is applicable. Please help, how to do the calculation. A function is really appreciated. Thanks to aleX_hill and RussellReal for the help so far. I'm trying to utilise the code before to find the next month. However, it needs to be used with the current year. So I altered the below <?php $nextMonth = date("m") + 1; $daysInNextMonth = date("t",mktime(0,0,0,$nextMonth)); echo $daysInNextMonth;?> to #NEXT MONTH $nextMonth = date("m") + 1; echo $nextMonth; $daysInNextMonth = date("t",mktime(0,0,0,$nextMonth)); echo $daysInNextMonth ; $year = date("o"); echo $year; I can then pass it into my url query like so: <a href="<?php echo $url_path; ?>after=<?php echo $year; ?>-<?php echo $nextMonth; ?>-01&before=<?php echo $year; ?>-<?php echo $nextMonth; ?>-<?php echo $daysInNextMonth; ?>">Next Month</a> Brilliant I thought, until it comes to December 2010, the next month needs to be January 2011. Now I'm bamboozled. How do I get around this one? Many thanks, your help is always appreciated! I'm using this code to get me the variables to a select box on a register page: $vars['user-birthdate-years'] = array(_VARS_USER_CHOOSE_ => "Please choose", _VARS_USER_NONE_ => _VARS_USER_UNDEF_); for ($i = date('Y') - 18; $i > date('Y') - 75; --$i) { $vars['user-birthdate-years'][$i] = "$i"; } This gives me this result in the page source: <select name="birthyear" class="date"><option value="-2" selected="selected">Please choose</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option><option value="1959">1959</option><option value="1958">1958</option><option value="1957">1957</option><option value="1956">1956</option><option value="1955">1955</option><option value="1954">1954</option><option value="1953">1953</option><option value="1952">1952</option><option value="1951">1951</option><option value="1950">1950</option><option value="1949">1949</option><option value="1948">1948</option><option value="1947">1947</option><option value="1946">1946</option><option value="1945">1945</option><option value="1944">1944</option><option value="1943">1943</option><option value="1942">1942</option><option value="1941">1941</option></select> Problem: When running the php code at the top it miss two years in the span as you see in the page source below, the year 1983 and 1984 is completely missing in the page source. Why is this happening, could the php code be corrected or is there a workaround in php for the missing years bug I seem to have found? I really appreciate any help on this! Edited by Drezzzer, 12 January 2015 - 05:16 AM.
I have a given date on a webpage, that I'm scraping to insert into a DB. The date is in this format: $date = 'Sun, Feb 9<br />3:00 PM ET': $healthy = array("<br />", " ET", "Sun.", "Mon.", "Tue.", "Wed.", "Thu", "Fri.", "Sat.", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $yummy = array(" ", "2020", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $date = str_replace($healthy, $yummy, $date1); $start = date('Y-m-d H:i:s', strtotime("$date -120 minutes"));
Hello this code is supposed to sort by year and month, but it doesn't. It sort by year and months are random. Any suggestions? Many thanks, $sortdata =[]; $namecolumn = array_column($data, '0'); foreach($data as $datecolumn){ $dateexplode = explode('/', $datecolumn[3]); $sortdata[] = (isset($dateexplode[1])) ? $dateexplode[1] : ((isset($dateexplode[0])) ? $dateexplode[0] : ''); } array_multisort($namecolumn, (($sorttype=='DESC') ? SORT_DESC : SORT_ASC), $sortdata, (($sorttype=='DESC') ? SORT_DESC : SORT_ASC), $data); Edited May 13 by Barand code tags added How to acheive it friends? i want my current codes to show results accouding to current month followed by year, the precious month goes to the page two.
would really appreciate if someone could help me acheive it
$tableName="records"; Edited by lovephp, 02 December 2014 - 11:50 AM. Hi Guys, Been a while since I've been on here, but I'm currently bashing my head against a wall trying to figure this one out. Basically I have a calendar that outputs Monday through Sunday, and the user clicks on a date and outputs it to the URL.... ie. ?day=$day&month=$month&year=$year. Now the next part I need to find out what day (0-6) say the 25th Feb 2011 will be wday 5... now how can I do this in code? And before anyone says why not output it to url, I cannot as the first week and last weeks use different code Cheers James Hello, not sure if lack of sleep or just staring at code too long. This is what I have: Code: [Select] while($rowy = mysql_fetch_array( $resulty )) { mpdate = YYYY-MM-DD $date = $rowy['mpdate']; $year = explode('-', $date); $month = date("F", mktime(0, 0, 0, $year[1])); ?> <?php echo $year[0]; ?> <br> <?php echo $month; ?> <br> <?php echo $rowy['mptitle']; } ?> I figure if I use: if ($year[0] == date('Y"){ echo month and entry stuff } but I keep getting errors. What I am trying to do is sort everything out into year month and day ie: 2012 March Entry 1 Entry 2 February Entry 1 Entry 2 Entry 3 etc... This is what I am getting 2012 March Entry 1 2012 March Entry 2 2012 February Entry 1 etc... Is there a way to fix this? I have PHP code that generates a long list of Birth Years in a Drop-down list, and I want to make the control "sticky". I know how to make something like this sticky - thanks to help from you guys... Code: [Select] <!-- Gender --> <label for="gender">Gender:</label> <select id="gender" name="gender"> <option value="">--</option> <option value="F"<?php echo (isset($gender) && $gender == "F") ? 'selected="selected"' : ''; ?>>Female</option> <option value="M"<?php echo (isset($gender) && $gender == "M") ? 'selected="selected"' : ''; ?>>Male</option> </select> But my Birth Year code is a little more complex and I'm racking me brain how to do it... Code: [Select] <!-- Birth Year --> <label for="birthYear">Year Born:</label> <select id="birthYear" name="birthYear"> <option value="">--</option> <?php // Display dates for Users between 18 and 100. for($i = $newestYear; $i >= $oldestYear; $i--){ echo '<option value="' . $i . '">' . $i . '</option>'; } ?> </select> How do I make this second set of code "sticky"?? Thanks, Debbie I have two text fields in a form. Both accepts dates. I'd like to check whether the second date provided is exactly one year in the future from the first provided date.
I can easily do this in PHP but since I need to do the check once the user leaves the second field, I have to resort to JavaScript, using onblur or something.
There are two issues I have.
1. Make sure that the strings provided are indeed dates (I would use strtodate() in PHP for this)
2. Regardless of month provided, making sure that the second date is exactly a year in the future of the already provided year
I've only captured the values and passed them to Date(). However, it can only handle european style, and if I enter 1981-06-16, the value returned is Jun 15 1981 17:00:00 which is obviously wrong.
Here is the simple broken code I have
var text1 = document.getElementById("text1"); var start_date = new Date(text1.value); var text2 = document.getElementById("text2"); var end_date = new Date(text2.value); alert(start_date);I need some guidance. right now i have my date system to say "X amount of seconds ago, X hours ago, X days ago, X years ago, How could i turn mktime() (1290874161) into a mm/dd/yyyy format? so it would say like, "Nov 27, 2010 at Hour:Minute" (whatever the hour/minute is) I must admit that dates and timestamps really confuse me! I have a query that gets a field named "date_purchased" and returns it like this "2010-09-05 09:58:12" What I need to do is add one year to the date, and display it like this "September 5, 2011" Basically, it's displaying the end date of a one year subscription. The database captures the purchase date with the order, so I want to grab that, add a year, and display it to the customer. Any help would be most appreciated! |