Q1)  Splintercellpro.com-php-mysql-test PHP – Complete remove_nonAtoZ() below function remove_nonAtoZ($input) { // example data: $input = “BA’3Ndf$%^A&*(nN)A”; $output = “BANANA”; }

(Answer 1)-Webpage Development answers-to-php-mysql-test <html> <head> <title>Write code for the following questions</title> </head> <body> <?php function remove_nonAtoZ() { $input = “BA’3Ndee@f$%^A&*(nN)A”; $output = preg_replace(“/[^A-Z]/”, ”, $input); echo $output; } remove_nonAtoZ(); echo ‘<br />’; ?> </body> </html>

(Q2)Splintercellpro.com-php-mysql-test  PHP – Complete table_columns() below function table_columns($input, $cols) { // problem: array of values are ordered to fill an html table by *column* (ie second value should appear beneath the first etc) // task: reorder array so that the values are in the order they will be output in html, filling each *row* of table at a time // example inputs: $input = array(‘apple’, ‘orange’, ‘monkey’, ‘potato’, ‘cheese’, ‘badger’, ‘turnip’), $cols = 2 // example output: array(array(‘apple’, ‘cheese’), array(‘orange’,’badger’),…) }

( Answer 2)-Webpage Development answers-to-php-mysql-test <html> <head> <title>Question 2 Matts test</title> </head> <body> <?php $input = array(‘apple’, ‘orange’, ‘monkey’, ‘potato’, ‘cheese’, ‘badger’, ‘turnip’); function table_columns($input, $cols) { function isEven ( $num ) { return !($num % 2); } $a =0; $count = count($input) ; //numbers to count for if (!isEven($count)){ $count++; } $i = 0; // incrementor $output = “<table>”; while($i < $count) { if($i == 0 || $i == $a) { $output .= “<tr>”; $a = $a + $cols; $e = $a – 1; if ($e > $count) { $e = $count – 1; } } if (!isset($input[$i])) { $input[$i] = ‘&nbsp;’; } $output .= “<td>”.$input[$i].”</td>”; if ($i == $e) { $output .= “</tr>\n”; } $i++; } $output .= “</table>”; return $output; } echo table_columns($input, 2); ?> </body> </html>

(Q3) Splintercellpro.com-php-mysql-test PHP – Complete first_day_of_next_month() below function first_day_of_next_month($date) { // Given a string of a date in the format “dd/mm/yyyy”, return the string of the same date in the format “yyyy-mm-dd 00:00:00” // Note that dd and mm of the provided date may be either one or two digits in length, but should be two digits in the returned string. // Return false if provided date is not in the expected format or is not a valid date. yyyy-mm-dd 00:00:00

(Answer  3)-Webpage Development answers-to-php-mysql-test <html> <head> <title>Questions 3</title> </head> <body> <?php print (“<B><CENTER>If I understand  question correctly:! </CENTER></B>\n”); print (“<b> Question (3): Format with time and first day of next month</b>\n”); date(“m/l/Y”, strtotime(date(‘m’, strtotime(‘+1 month’)).’/01/’.date(‘Y’).’ 00:00:00′)); echo(strftime(“<p>%Y/%m/%d&nbsp; %X “)); ?> <?php $d = new DateTime(‘2015-03-31’); $d->modify( ‘first day of next month’ ); echo $d->format( ‘<p>F jS, Y’ ); ?> </body> </html

(Q4) Splintercellpro.com-php-mysql-test Webpage Development answers-to-php-mysql-test UNSURE ABOUT THIS QUESTION WHAT DO THEY MEAN – DO YOU REQUIRE ME TO NEST THESE QUERIES, TOGETHER AS IN 1 COMMAND FOR 1 OUTPUT -OR SUMMARISE ALL THESE TASKS INDIVIDUALLY AS I HAVE DONE SO. . , , ? -OR SEND ANOTHER TEST -OR A EXAMPLE FOR MY CLARITY Firstly we need to populate our slq Database with the following import file. From memory something like this. Save populate.sql file below to run select queries and populate database tables. I use the command prompt to do this. Create Database developers use developers; create table developers ( id int unsigned not null auto_increment primary key, name char (60) not null ); Create table tasks (id int unsigned not null auto_increment primary key’ developer_id  int unsigned not null, subject varchar(255) not null, priority enum (‘1’,”,”, status enum (‘queued’,’completed’,’approved’) not null ); INSERT INTO `developers`.`developers` (`id`, `name`) Values (NULL, ‘Kevin Greggs’), (NULL, ‘Malcolm Sims’); INSERT INTO `developers`.`tasks` (`id`, `developer_id`, `subject`, `priority`, `status`) VALUES (NULL, ‘1’, ‘PHP Variables’, ‘2’, ‘completed’); INSERT INTO `developers`.`tasks` (`id`, `developer_id`, `subject`, `priority`, `status`) VALUES (NULL, ‘3’, ‘PHP Arrays’, ‘1’, ‘queued’), (NULL, ‘4’, ‘PHP MySQL ‘, ‘3’, ‘approved’);

(Answer  4- (AMBIGUOUS QUESTION!)) Splinters dilemma. select developers.id, developers.name from developers,tasks where status = ‘queued’ and developers.id = tasks.id;

Question-Where each row represents a developer and a status.
Answer: select developers.name,status from developers, tasks where developers.id = tasks.id;

Question-Excludes those that are ‘approved
Answer: select developers.name, status from developers, tasks where status = ‘completed’ or status =’queued’;

Question-Find all developers whos status is approved
Answer:    select developers.id, developers.name from developers,tasks where status = ‘approved’ and developers.id = tasks.id;

Question+Show a count of tasks for developers
Answer:  select count(distinct status) as numberoftasks from tasks;

Question_ The  list is ordered by developer name within a status
Answer: SELECT Developers.Name, TASKS.developer_id FROM Developers INNER JOIN Tasks ON Developers.ID=Tasks.ID ORDER BY Developers.Name

Question_ The list below list developers id and there name.
Answer: SELECT Developers.Name, TASKS.Status FROM Developers INNER JOIN Tasks ON Developers.ID=Tasks.ID ORDER BY Developers.Name; Question_Tasks completed by developer Kevin Gregg select * from developers, tasks where developers.name like ‘%kevin Gregg%’; End of-Webpage Development answers-to-php-mysql-test. . .

end of: Splintercellpro.com-php-mysql-test

Leave a Reply-i don't bite

This site uses Akismet to reduce spam. Learn how your comment data is processed.