Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. ORDER BY points, goals, for, against, name All in ascending order
  2. It makes no sense to include the comment remove it. This is also why you get the same record twice your result is DISTINCT
  3. You misunderstood this table maps products to shops Remove the tbl_subcategories and add the field parent_id to the tbl_categories table. It won't, it would show up as NULL not all customers like to login/register prior to shopping. Use session_id() while the customer has not yet logged in. Then (probably) on checkout ask all required information (shipping address and such) register the account, get the id (mysql_last_insert_id()), update the customer cart with UPDATE tbl_carts SET customer_id = $cid WHERE session_id = $sid
  4. Use salathe's method I misread your post
  5. If both arrays have different key indexes, you could alternatively use: while (next($array1) && next($array2)) {
  6. Nope. $basket_count = sizeof($_SESSION['basket']);
  7. You are correct DISTINCT doesn't work on fields it's not a FUNCTION My code should work as it: 1. Selects all matching records from pictures with books (one book, multiple images) 2. Orders these records according to the pictures date in reverse order (latest first) Still one book, many images 3. Applies DISTINCT for each book one image Post your SQL code and an image of the result
  8. SELECT first_name, last_name How do you know for sure? Just deny the student from college/university?
  9. http://rent-a-dba.net/
  10. It's days not Day plus DELETE * FROM $table WHERE date_created < date_add(CURRENT_DATE, $numdays Day) Is the same as: DELETE * FROM $table
  11. SELECT dt.* FROM documents_table dt LEFT JOIN comments_table ct ON dt.id = ct.document_id WHERE (dt.description LIKE '%$search_term%' OR dt.subject LIKE '%$search_term%' OR ct.comment LIKE '%$search_term%')
  12. Do you want to remove Read More but keep Edit & Delete?
  13. while (list($email) = mysql_fetch_array($result, MYSQL_NUM)) { mail($email, ..) } This sends n-emails, where n equals mysql_num_rows($result)
  14. There is no version that logs in this specific manner as SQL can not know the name (nor username) of the active user only the active account used by MySQL and this is either root or the account assigned to you by your hosting company
  15. tbl_customers (id) tbl_categories (id) tbl_subcategories (id, category_id) tbl_products (id, subcategory_id, price) tbl_products_sizes (id) tbl_products_has_sizes (id, product_id, size_id, quantity) tbl_shops (id) tbl_shops_has_products (shop_id, product_id) tbl_carts (id, session_id, customer_id, product_has_size_id, quantity) Questions that arise: * Do products only show up under a subcategory or also under a category * Do products only show up under one subcategory or under multiple? I assumed they only showed up under one subcategory * Do shops share products? I assumed they did * Note tbl_carts.session_id this refers to session_id() and is used to allow shopping while not logged in, once they login update their cart Note that I based myself on a common approach if your application differs, then this DB will provide trouble along the way as-well. In order for me to create a DB design that will match your application I will need to understand your application's domain (I would be able to answer the above questions myself) one way this can be achieved is through use-cases (or wireframes) but I doubt you have any planning in place
  16. 1. Properly indent your code 2. Learn PHP, you had many meaningless statements if(isset($_POST['submit'])) { $tag_id=$_POST['tag_id']; $color=$_POST['color']; $born=$_POST['born']; $age=$_POST['age']; $sex=$_POST['sex']; $hatch=$_POST['hatch']; $pmom=$_POST['pmom']; $pdad=$_POST['pdad']; $errs = array(); //looking for multiple error possiblities on just the first field // first get rid of whitespace if($tag_id) trim($tag_id); // making sure field not empty if (empty($tag_id)) $errs[] = "You must have a collar tag entry"; //tried strtoupper but that didnt work so went with this if(!preg_match("/[^A-Z0-9]$/s",$tag_id)) $errs[] = "Please use only uppercase A-Z and 0-9 for Collar ID"; //see if enough characters to make entry valid if (($strlen = strlen($tag_id)) < 2 || $strlen > 4) $errs[]=" Collar has to be at least 2 charaters and less than 4 characters"; if (count($errs) == 0) { include("myConnection.php"); mysql_connect("$server", "$username", "$password") or die ('screwed up'); mysql_select_db("$database") or die ("Unable to select database!"); // probably dont need all of these if validation works but // wanted to make sure missing wouldnt throw error $tag_id=mysql_real_escape_string($tag_id); $color=mysql_real_escape_string($color); $born=mysql_real_escape_string($born); $age=mysql_real_escape_string($age); $sex=mysql_real_escape_string($sex); $hatch=mysql_real_escape_string($hatch); $pmom=mysql_real_escape_string($pmom); $pdad=mysql_real_escape_string($pdad); $result = "INSERT INTO myTable (tag_i, color, born, age, sex, hatch, pmom, pdad) VALUES ('$tag_id','$color','$born','$age','$sex','$hatch','$pmom','$pdad')"; mysql_query($result) or die(mysql_error()); echo '<h2>New Entry</h2>', ' <b>Collar Number:</b> $tag_id <br/>', ' Collar Color: $color <br/>', ' <b>Born:</b> $born - $hatch <br/>', ' <b>Age:</b> $age <b>Sex:</b> $sex <br/>', '<br>', 'Parent mother: $pmom <br/>', 'Parent father: $pdad '; } else { $i = 0; $fix = ''; $count = sizeof($errs); while ($i < $count) { $fix .= $errs[$i] . '<br>';//??? ++$i; } echo $fix; } }
  17. Follow these instructions: 1. Start > cmd > ipconfig (probably something like 192.168.x.x) 2. Surf to your router interface (probably 192.168.0.1) 3. Forward your ports so that all incoming traffic on port 80 is routed to your computer (see #1) 4. WampServer > Put Online
  18. SELECT DISTINCT b.name, p.uri FROM books b, pictures p WHERE p.book_id = b.id ORDER BY p.timestamp DESC
  19. Nope they are equal (in results) PROPERTIES.COMMUNITY in (select COMMUNITY from LOCATION_BRIDGE where LOCATION={$location}) Is the same as saying: JOIN properties p ON .. JOIN location_bridge lb ON p.community = lb.community WHERE lb.location = $lid My method is preferred as there is no need to use sub-queries they only make it more complex to understand.
  20. What code do you have on blog? I assume somewhere in that code you invalidate the auth session
  21. If you only need the e-mail you better change: SELECT fname, sname, username, email FROM users where is_guard=1 to: SELECT email FROM users where is_guard=1 now you can: $emails = array(); while (list($email) = mysql_fetch_array($result, MYSQL_NUM)) { $emails[] = $email; } $email_list = implode(',', $emails); // avoids the trailing ,
  22. SET GLOBAL time_zone = <timezone>; -- if something different from SYSTEM or if you SQL server is not hosted on the same server as your PHP SELECT * FROM table WHERE date BETWEEN date_y AND date_x SELECT * FROM table WHERE month(date) = 3 -- March
  23. if($path)) set_include_path($path); if (is_file($filename)) { //or if (is_file(rtrim($path, '/\\') . DIRECTORY_SEPARATOR . $filename))
  24. Bare in mind that donating will by no means get you help any quicker. The chances are that nobody who is likely to help you will even know you donated. Don't you get a flashy banner under your name saying donator or something? I thought you did.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.