Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. well... if the field that hold those numbers that you are referring to is not a Primary Key (PK) or part of a relation with other table (Foreign Key) then ... yes... you could renumber as you wish.
  2. the famous question again.... we should have an Sticky post for this... short answer: Don't do it!!. for long answers/explanations just do a search in this forum using "renumber"
  3. here you go: SELECT username, password, email, title, first_name, last_name, phone, street, city, state, zip, country, payment_method FROM users JOIN payment_info ON payment_info.username = users.username WHERE id = '$id'; Note: Pay attention in case you have same fields names in both tables, in such case you can prefix the fields names either with the table name or aliases. and this is better that google
  4. assuming that your "customer" table is the Master and "contacts" hold the Details then the "non connection" (orphan records) between Contacts and Customer should never happens (the contrary of course is possible), because that will constitute a violation of the DB Referential Integrity (here is an article that can help you to dig a little more into the concept) http://www.databasejournal.com/features/mysql/article.php/2248101/Referential-Integrity-in-MySQL.htm The Referencial Integrity must be controlled either by your code or (best solution) for the definition of an explicit CONSTRAINT in the DB (Foreign Key), the definition/usage of integrity constraints depend of which Storage Engine your choose.. MyIsam or InnoDb Integrity Constraints are only enforced automatically on InnoDb S.E (if you define its of course) In your case a FK (Foreign Key) should be defined on your contacts table using the field "account_id" (if you SE is Innodb) here are examples and concepts details : http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-foreign-keys.html and in case that you don't want to go in that route, a simple SELECTS using JOIN's or Sub-Queries will answers your questions, like SELECT DISTINCT account_id FROM contacts WHERE NOT EXISTS (SELECT 1 FROM customers WHERE customers.account_id = contacts.account_id); and more to read into : http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html
  5. If I understand your objectives correctly simple SELECT's using the proper aggregate functions should answer those queries. and for the temporary table you always can use VIEWS ... in other words: - Create your VIEW with the SELECT aggregating the records in the way you want - Use the VIEW to SELECT from it any further group of records.
  6. what are you after?.... a better explanation of your objectives could lead to a better answer. short answer... yes... in triggers and/or functions... how to use them is going to depend on your objectives.
  7. if you do this test: echo "Value : " . intval('01234 56789'); what do you get?
  8. and what about a simple JOIN between the tables?
  9. that is not what you said before
  10. the undefined constant....
  11. Here is the $sql1 that you have... (just formated for clarity... no changes made) $sql1 = "UPDATE inventory SET itemNumber='$data[0]', itemDesc='$data[1]', quantityHand='$data[2]', category='$data[3]', Whse='$data[4]' WHERE itemNumber='$data[0]' AND itemDesc='$data[1]' AND quantityHand='$data[2]' AND category='$data[3]' AND Whse='$data[4]'"; just to help you to debug your code... add this line below the $sql1 definition and check if the final sentence looks right or not echo "Sql to execute : " . $sql1; also, analyze all those AND's in the WHERE clause... are those AND's making any sense or you need to eliminate them and just match the record using the itemNumber field?... now you have something to work with.
  12. adding a total field to the table?.... Don't do that!!!.... really bad idea... you can always calculate the sum when you get the records that you need.
  13. echo the values of $date1 and $date2 (do not format them) and check what are you getting... after that read the strtotime() definition http://php.net/manual/en/function.strtotime.php
  14. if you replace this line: $query = mysql_query($query) or die("error : " . mysql_error()); with this: $query = mysql_query($query) or die("error : " . mysql_error()); $num_rows = mysql_num_rows($query); echo "Rows Returned by the Query : " . $num_rows; what do you get?
  15. I did post ONLY your relevant code ... the one that is supposed to "display" your data.... and I still seeing only ONE echo there... if that piece of (incomplete) code is not displaying anything means that your query is not returning anything or is failing... or you are not connected to the DB... try this simple changes (very dirty... just to help you to start) : $query = "SELECT products.name, products.price, addtionalCategories.productID FROM products, addtionalCategories WHERE products.category='1' AND products.id = addtionalCategories.productID"; $query = mysql_query($query) or die("error : " . mysql_error()); while( $fetch = mysql_fetch_object($query)){ echo "Product Name : " . $fetch->name; echo "<br />Product Price : " . $fetch->price; // etc... etc...etc... } see what you get from this
  16. <body> <?php $query("SELECT products.name AS name, products.price AS price, addtionalCategories.productID AS productID FROM products, addtionalCategories WHERE category='$cat' AND products.id = addtionalCategories.productID"); while($fetch=mysql_fetch_object($query)){ echo"$fetch->name"; } ?> this is your full code? .... and what else have you tried?... what results are you expecting? according to one of your posts: I don't see anything like that in your code... only one echo"$fetch->name" ??
  17. seems that you are missing a couple of }'s here (The error message is giving you good information) } else { $TPL_err=1; $TPL_errmsg=$ERR_112; elseif(($_POST['action'] != "update" || $TPL_errmsg !=1)) {
  18. if you post your complete code and explain clearly your objectives sure someone will chime.
  19. have you tried one of the MYSQL functions LOWER() or UPPER() ? (in your case since that you are storing fields as VARBINARY you should combine them with CONVERT() ) http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_lower
  20. PFM... I haven't found a clear explanation in the documentation, but this 2 pieces of code are equivalents: $mysqli = new mysqli(.....); $stmt = $mysqli->stmt_init(); //Initializes a statement and returns an object for use with mysqli_stmt_prepare $stmt->prepare($sql_query); // $sql_query a valid prepared sql sentence etc..etc // No using ->stmt_init() explicitly $mysqli = new mysqli(.....); $stmt = $mysqli->prepare($sql_query); // Prepare the statement to execute ($stmt initialization implicit... doesn't seems to be clearly documented) $stmt->prepare($sql_query); etc..etc I have been using both method for some time without any problem... my tendency is to use the 2nd just for simplicity, but maybe is a better practice to use the method 1.
  21. part of your code: $query("SELECT products.name AS name, products.price AS price, addtionalCategories.productID AS productID FROM products, addtionalCategories WHERE category='$cat' AND products.id = addtionalCategories.productID"); while($fetch=mysql_fetch_object($query)){ read... and compare your code to the examples http://php.net/manual/en/function.mysql-query.php
  22. we don't know exactly how are you modeling the business and the reasons behind your decisions, therefore it can be right... but doesn't "smell good"... anyways... what you can try to do is something along this lines (code fired from the hip... non tested in your real case... you must adjust it to your reality) SELECT t.num1, t.admonth, count(approved) /// replace whatever you need here.... the count(ad_date) doesn't look good in your queries FROM ( select count(ad_date) as num1, monthname(ad_date) as admonth, count(approved) as approved from ads where approved='1' UNION ALL select count(ad_date) as num1, monthname(ad_date) as admonth, count(approved) as approved from ads_announce where approved='1' UNION ALL select count(ad_date) as num1, monthname(ad_date) as admonth, count(approved) as approved from ads_jobs where approved='1' ) AS t GROUP BY t.num1, t.admonth /// replace with whatever you want here
  23. . fenway question still valid... why 2 (or 3) different tables to hold the same information?... according to Labrat "all 3 tables have the same 3 column names (ad_id, ad_date and approved)"
  24. post more code
  25. I didn't read all your code, therefore I don't know if it has more issues... but regarding to the error that you posted I see a "," that should not be there: SET rankClass='10', hschool='Avon HS', WHERE id='172'
×
×
  • 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.