Jump to content
Larry Ullman's Book Forums

Josee

Members
  • Posts

    111
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Josee

  1. Hello, I have three tables in my database: ingredients , categories, and an intermediary table: ingredients_categories. Let's say I inserted id_ingredient 100 to 150 into ingredients. Right now, if I want to populate the intermediary table I use two queries: INSERT INTO ingredients_categories (id_ingredient) SELECT id_ingredient FROM ingredients WHERE id_ingredient BETWEEN 100 AND 150; UPDATE ingredients_categories SET id_categorie=11 WHERE id_ingredient BETWEEN 100 AND 150; Is there a smarter way of doing this, with just one query? With thanks for your help,
  2. @romumu77: si vous avez d'autres questions à poser ici, postez-les en français, et j'essaierai de les traduire. @Larry: I'm just suggesting to romumu77 he posts his questions in French, and I'll try and translate them into English.
  3. Hello, Sonal, When I look at the source code for your website, the path to the css file (with added spaces) is href = " /home/myreadin/includes/default.css " Is this the right URI, or should it start with "includes"? Remember that the path is from the file that calls your css file (for instance, from "index.php") to "default.css". This topic from the forum helped me to get the paths to my files right: http://www.larryullm...actly-is-a-uri/ I hope it may help you too.
  4. Hello, Sonal, Could you show the code you have in your header file regarding the link to the CSS file? It depends on how much CSS you have, but if it's not too much you can have all the CSS in one file. Since you say you don't know CSS yet, the basics are that you create different formatting styles for all the different HTML elements. So one and the same file can/will have styles for introductory texts, headings, input fields in forms, tables and all the other elements you are using in your website. If you want the text in one paragraph to be blue, instead of black as the default text-color, you just use a "class" in your html (something like: < p class = "blue_text" >), and create a special CSS rule for this class of paragraphs. In your example, all the different styles for your introductory text and your forms can be in one and the same CSS file. Or you can decide it will be easier to maintain your files if they are smaller, and you can split the CSS into two files, for instance: one called css_main.css, and another called css_forms.css, for instance. But you will probably still need links to both files in your header, because your registration page will probably use rules from both. So your header file would have two lines like these: <link rel="stylesheet" type="text/css" href="css/css_main.css" media="all" /> <link rel="stylesheet" type="text/css" href="css/css_forms.css" media="all" /> In this example, I'm considering that all files needing the css files will be in the same directory as a sub-directory called "css", where I keep the different css files. Which means my file hierarchy is like this: project_directory index.php some_other_page.php includes header.php footer.php css css_main.css css_forms.css And the path in the < link > element is from "index.php" to "css_main.css", not from "header.php" to "css_main.css". I hope this helps,
  5. Would the problem be "was removed"? I suppose it was meant to be a comment? I hope this helps,
  6. Yes; nothing to do with the view. As to clogging up the server, I'll let someone knowing more than I do answer you!
  7. I'm using BBEdit, TextWrangler's "big brother". Mac only, and not free, but I like it. Braces and parentheses balancing. Syntax coloring. You can hide inner loops or conditionals when you have several imbricated conditionals (if (…) { if (…) { foreach (…)}}}), which makes it easy to check your code. As many clippings (also called snippets in other software) as you want. Templates. Multi-file search and replace, including searching with regular expressions. And many more features. In fact, too many when you really are a beginner, but great once you are familiar with another text editor. There are still many I need to explore!
  8. I just wanted to say thanks to Antonio Conte for his explanations about views. I hadn't understood their real use until then, and now I couldn't do without them! @Max: have you tried views? When you have a query with lots of JOINs, a view is magic, because, once you've created it, you no longer have to refer to multiple tables but just to one. You just work hard once on your JOINs, and then you no longer have to think about them (except for saving the original query in a separate file, as Antonio Conte mentioned, just in case you have to recreate it one day).
  9. Hello, Larry, Please don't apologize. There's no reason why you should do the research if you don't know the answer off the top of your head. Best wishes,
  10. I've just been looking at the MySQL 5.1 Manual, and I found the explanation here: http://dev.mysql.com.../en/regexp.html In the MySQL version of regular expressions, \b means a backspace. And word-boundaries are instead shown like this: REGEXP '[[:<:]]word[[:>:]]' So, rewriting my previous regular expression like this: REGEXP '[[:<:]](\')?((eau){1}|(eaux){1})[[:>:]]' returned just the results I wanted.
  11. Kudos for figuring out how to use the make_form_input() function. But just for now, let's forget about this function and create the form the usual traditional way, so as to keep things simple for the make_date_menus() function. As it stands now, the make_date_menus() is great if you always want your calendar to start with the current year and to generate 10 years. But if you want web-users to be able to create their own calendar, you need to get the values they want to use for the first year and for the year count. That's why you provide them with a form like this: <form action="" method="post"> <p> <label for="first_year">Choose the first year in the menu</label> <input type="text" name="first_year" size="6" /> </p> <p> <label for="year_count">How many years would you like it to generate?</label> <input type="text" name="year_count" size="6" /> </p> <p> <input type="submit" name="submit" value="Submit!" /> </p> </form> Once the form has been submitted, you get an array of values, $_POST, containing: $_POST['first_year'] $_POST['year_count'] Their values will be the data entered by your web-user, for instance "2005" for $_POST['first_year'] and "5" for $_POST['year_count']. In a real-world situation, you would need to validate this data, but for now we'll just check that the user entered data and assign these values to new variables with shorter names: if (isset($_POST['first_year'])) { $first_year = $_POST['first_year']; } if (isset($_POST['year_count'])) { $year_count = $_POST['year_count']; } Now, these are the two variables you want to use as arguments for your make_date_menus() function, so that the calendar starts with the value assigned to $first_year, and it generates the number of years assigned to $year_count. That means you will no longer use date('Y') for the first year, since you want to use the data provided by the web-user; and you will no longer use "10" in the for loop, since here too you want to use the data provided by the web-user. You just have to reconcile this with what Larry explains on page 265 and following: I hope this helps,
  12. Don't worry, Deb, you shouldn't have to worry about Apache to start with the book, and I don't think using the QuickStart Guide will make any difference on that subject. How did you install your local server? Did you use a package such as XAMPP or MAMP? Also, you should read the forum rules and add the requisite information to your signature: every time you ask a question on this forum, people will need to have precise information about the different versions you are using in order to help you. I hope this helps,
  13. Hello, April, I didn't write "change the arguments". I wrote: "rewrite the function so that it takes arguments". Right now, if you use this function in your website, what the website-user sees is this: He/She has no way of choosing when the calendar starts. Now, imagine you want to allow the website-users to create their own calendar, starting in 1675 and running for 20 years, or just as well starting in 2005 and displaying 5 years only. You have to create a form to allow them to state the first year and the number of years for the menu, register these values in your script, and use them as arguments for your make_date_menus() function: So you have to ADD arguments to the function; rewrite it so that it takes arguments: you will no longer hard-code the values in the for loop you are using for years, but use the values provided by the web-user. And, since that's part of the "Pursue" requirements, you'll also provide your function with a default value for the second argument (the number of years). I hope this helps,
  14. Thank you for answering, Larry. No, apparently it isn't a collation or character set issue (for once!). It's apparently a problem with word-boundaries since this query returns no result: SELECT id_syntagme, syntagme_c FROM syntagmes WHERE syntagme_c REGEXP '\b(\')?((eau){1}|(eaux){1})\b' whereas this query works… except that it returns all the entries containing "eau" or "eaux", including "carreaux" or "beaucoup" (which I need to exclude): SELECT id_syntagme, syntagme_c FROM syntagmes WHERE syntagme_c REGEXP '(\')?((eau){1}|(eaux){1})' Is there another way of specifying word-boundaries in a MySQL query? With thanks for your help,
  15. Hello, April, I think I can try and help you here. In the function as it is written on page 262, the year menu starts with the current year: $start_year = date('Y'); So, instead of that, you'll rewrite the function so that it takes a first argument allowing the user to choose the starting year (any year). Then, still on page 262, the number of years to generate is hard-coded within the function: it's 10 years: for ($y = $start_year; $y <= ($start_year + 10); $y++) So your new function will have a second argument allowing the user to choose the number of years the function must generate. And you will include a default value for this second argument. I hope this helps,
  16. Hello, Could someone help me with a regular expression in MySQL? If I test the following pattern in PHP: \b(\')?((eau){1}|(eaux){1})\b the results are fine since I get a match for but no match for Yet if I try the very same pattern in the database, using phpMyAdmin, I get no results at all although all the above examples are in the database. Could someone explain why this is happening, and what I need to do in MySQL? In case you wonder why I'm not using a FULLTEXT search, I plan to use regular expressions for words that are 1, 2 or 3 characters long, and a FULLTEXT search for longer words or expressions. With thanks for your help,
  17. I'm not Larry, but as a fellow PHP-learner I would say that it's much easier to forget a parenthesis or a comma with nested arrays. So, even if it would seem quicker to write it all in one statement, we may just as well waste time looking for a missing comma.
  18. Have you had a look at the second example? It uses Authorize.net, a payment gateway, instead of Paypal (see page 15 for the differences between the two). I hope this helps,
  19. Hello, Cofa, Developing websites is only a leisure-time activity for me, so I learn very slowly. I waited ages before summoning the courage to add MySQL to what I was already trying to learn… only to discover that I had really been making things more difficult for me by avoiding MySQL at all costs! I'm quite sure you'll enjoy databases once you start working with them. They make many things much easier, and one of the really nice aspects of databases is that you can use them on your own computer as well as on the web, just for your own use.
  20. Sorry, Cofa. I'm afraid I was too engrossed in my own project and misread your question!
  21. This is really a question, rather than a suggestion, because I haven't tested it with files: could you maybe use the sprintf() function? http://us2.php.net/manual/en/function.sprintf.php I hope this helps,
  22. Apart from the PHP manual, what I find very useful is creating test files using the different functions or conditionals I'm trying to better understand. For instance, I created a test file with a simple form, and conditionals printing the results when using isset(), empty(), if ($var), is_numeric(), and so on. This way, when I wonder which function/conditional I should use in a script, or why a script is not doing what I want it to do, I just have to use the test file to remind me of the differences between isset(), empty() and so on.
  23. Have you tried SUBSTRING_INDEX instead? For instance, this: SUBSTRING_INDEX(column_name,' ',-1) would return anything to the left of the first space, starting from the right. I hope this helps,
×
×
  • Create New...