Jump to content
Larry Ullman's Book Forums

Sergiu

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Sergiu

  1. Thanks for the example, very useful.. I guess that one can say that overriding is a mean to achieve polymorphism
  2. Hi, i have a question regarding the relationship between polymorphism and overriding. I found this definition on page 151: Are those two terms synonyms? Thanks,
  3. Thanks for your quick reply. Maybe i do something wrong, but if we take a look at the result, the query does not select the right values. For example, instead of selecting "mysql-friedman-debugging-2012-01-22 14:07", it selects "mysql-troutster-joins- 2012-01-22 14:07", so the username and subject do not match the last posting for each forum section. The max() does the trick in selecting data of the latest post, but i think a similar function is needed for the other columns username and subject. I tried to include a snapshot with the results from mysql client, but i wasn't able to do that, so I just list the query: SELECT f.name, u.username, m.subject, m.date_entered FROM forums AS f LEFT JOIN messages AS m USING ( forum_id ) LEFT JOIN users AS u USING ( user_id ); name username subject date_entered CSS NULL NULL NULL HTML friedman help 2012-01-22 13:47:38 HTML js advice 2012-01-22 14:09:58 MySQL troutster joins 2012-01-22 13:43:33 MySQL friedman aggregate 2012-01-22 13:44:25 MySQL ron_paul aggregate 2012-01-22 13:45:39 MySQL rothbard connect 2012-01-22 13:46:22 MySQL friedman debugging 2012-01-22 14:07:59 PHP friedman GET-POST 2012-01-22 13:46:58 PHP mises forms 2012-01-22 13:49:18 PHP rothbard error 2012-01-22 14:09:01 SELECT f.name, u.username, m.subject, COALESCE( MAX( m.date_entered ) , 'N/A' ) AS last_post FROM forums AS f LEFT JOIN messages AS m USING ( forum_id ) LEFT JOIN users AS u USING ( user_id ) GROUP BY (m.forum_id); name username subject last_post HTML friedman help 2012-01-22 14:09:58 PHP friedman GET-POST 2012-01-22 14:09:01 MySQL troutster joins 2012-01-22 14:07:59 CSS NULL NULL N/A
  4. Hi, i have a question regarding an example from ch7, page 220: in order to get the date of the most recent forum, the following query was presented: SELECT f.name, COLESCE (MAX(m.date_entered),'N/A') AS last_post FROM forums AS f LEFT JOIN messages AS m USING (forum_id) GROUP BY (m.forum_id) ORDER BY m.date_entered DESC; The problem is that I can't figure out how this query could be changed in order to find as well the username and subject of the last post, so in the end it will find for each forum: name(of forum)-last_post-username-subject. Any ideas? In short, the structure of the tables is: forums [forum_id, name]; messages [message_id, forum_id, user_id, subject, body, date_entered]; users[user_id, username, pass, first_name, last_name, email].
  5. I can relate to Lou's story, because i'm considering a career change to IT, too (coincidently, i'm an accountant myself, but growing increasingly tired of this field). Leaving aside differences of IT jobs market in US vs East-Europe (where i live), is it (theoretically) possible to land a job in web development, with no CS-university background? I believe in self-study and self-improvement, but i would like an onest opinion from the more experienced members of the forum (or even Larry), about this topic (ok, you may err on the side of optimism ). Thanks
  6. Thanks Larry for your suggestion! I made the select menu part of an another form that retrieves the chosen year and prints it to the same page, using the $_GET method. The affected part of the script is: if ($_SERVER['REQUEST_METHOD']=='POST') { if (is_numeric($_POST['start_year']) && is_numeric($_POST['years'])) { if ($_POST['start_year']>0 && $_POST['years']>0) { print '<form action="menus.php" method="get">'; //MAKE THE OTHER FORM FOR THE SELECT-MENU! make_date_menus ($_POST['start_year'], $_POST['years']); print '<input type="submit" name="submit" value="Select the Year" /></form>'; } else { //Negative numbers entered print "<p><em> Please enter positive numbers!</em></p>"; } } else { //Incorrect values entered print '<p><em> Please enter a valid starting year and number of years!</em></p>'; } } elseif ($_SERVER['REQUEST_METHOD']=='GET' && is_numeric($_GET['year_list'])) { //PRINTS THE SELECTED YEAR! print '<p>Selected year is: '.$_GET['year_list'].'</p>'; }
  7. Thanks Paul for your suggestion! The thing is, that exercise being at the end of chapter about cookies (chapter 9), i was thinking that the author had in mind a solution involving cookies, but that's not necessarily being the case, i guess.
  8. Hi, there is an exercise from page 286, chapter 10, "make the function in menus.php take arguments to indicate the starting year and the number of years to generate. [...] rewrite the function body so that it uses these values in the year for loop". So, we may have two fields for entering the starting year (for ex. 1990) and the numbers of years (for ex. 15), in order to create a pull-down menu by a user-defined function (1990, 1991, 1992 etc). The thing is, how on earth can i retrieve the chosen year from the select-list, in order to print a message like "you have chosen year X"? The code as far as i was able to write it, is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/xml; charset=utf-8" /> <title>Menu</title> </head> <body> <?php //Define function that makes pull-down menus for the years: function make_date_menus ($start_year, $years) { print '<select name="year_list">'; for($y=$start_year; $y<=($start_year+$years); $y++) { print "\n<option value=\"$y\">$y</option>"; } print "</select>\n"; } // End of make_date_menus //Check for a form submission: if ($_SERVER['REQUEST_METHOD']=='POST') { if (is_numeric($_POST['start_year']) && is_numeric($_POST['years'])) { if ($_POST['start_year']>0 && $_POST['years']>0) { make_date_menus ($_POST['start_year'], $_POST['years']); } else { //Negative numbers entered print "<p><em> Please enter positive numbers!</em></p>"; } } else { //Incorrect values entered print '<p><em> Please enter a valid starting year and number of years!</em></p>'; } } ?> <form action="menus.php" method="post"> <p>Enter the starting year: <input type="text" name="start_year" /></p> <p>Enter the number of years to generate: <input type="text" name="years" /></p> <input type="submit" name="submit" value="Make the menu!" /> </form> </body> </html> Thanks!
  9. Hi everyone, i wonder if anyone has managed solving the exercise from chapter 9, page 256, "make the form in customize.php sticky, so that reflects the user's current choices". It's about making a sticky form for a pull-down menu. I've thought about this version: "<select name="font_size"> <option value="">Font Size</option> <option value="xx-small" <?php if ($_POST['font_size']=="xx-small") {print "selected=selected";} ?> >XX-Small</option> <option value="x-small" <?php if ($_POST['font_size']=="x-small") {print "selected=selected";} ?> >X-Small</option>...etc." but it's not correct. Any suggestion would be greatly appreciated, thanks
×
×
  • Create New...