Jump to content

artacus

Members
  • Posts

    737
  • Joined

  • Last visited

    Never

Everything posted by artacus

  1. Are you looking for a summary? (no individual records) I'm not sure if V/S are mutually exclusive, but try: [code] SELECT   SUM(IF(palavrachave_vip LIKE "%ab%,1,0)) AS num_v,   SUM(IF(tbE.cliente = "S",1,0)) AS num_s,   COUNT(tbE.id) AS num_records FROM... GROUP BY tbE.id [/code]
  2. Yeah, PHP's mysql client only lets you define 1 query per mysql_query call. This is a security feature. What you can do is [code] $sql  = explode(';',$sql_update); //you need to add the ; in the original statement for($i=0; $i<count($sql); $i++) {     mysql_query($sql[$i]) or die(mysql_error()); } [/code]
  3. Yeah so? Did you get anything from my post? I would put category in its own table and use category_id, if there are only 4 buff types you can use enum and attribute is a 1 to many so it would go in a separate table.
  4. You need a JOIN ON statement for every table except the first. Also, I couldn't tell from your example where form1 fit in so you'll have to use my example to work it in. [code] SELECT * FROM personal_details AS pd JOIN ra_card_1 AS card ON personal_details.member_no = ra_card_1.member_no JOIN form AS f ON pd.member_no = f.member_no JOIN form1 AS f1 ON (this should tie back to the pd or form table but I dont know how) WHERE form1.chapter_no = '$chapnum AND form1.form1 = 0' [/code] (technically, MySQL will allow you to declare multiple tables in the FROM statement but it will choke when you try to add joins on anything but the last table defined in the FROM clause)
  5. quote your strings.[code] "SELECT ... WHERE email='$email'";[/code]
  6. [code] SELECT p.* FROM photos AS p JOIN keywords AS k1 ON p.photo_id = k1.photo_id JOIN keywords AS k2 ON p.photo_id = k2.photo_id WHERE k1.keyword LIKE 'keyword1' AND k2.keyword LIKE 'keyword2' [/code] or if you wanted to  do it weighted where it could match either one or both of the keywords [code] SELECT p.*, CASE WHEN k1.id IS NOT NULL AND k2.id IS NOT NULL THEN 2     WHEN k1.id OR k2.id IS NOT NULL THEN 1     ELSE 0 END AS search_score FROM photos AS p LEFT JOIN keywords AS k1 ON p.photo_id = k1.photo_id AND  k1.keyword LIKE 'keyword1' LEFT JOIN keywords AS k2 ON p.photo_id = k2.photo_id AND k2.keyword LIKE 'keyword2' GROUP BY p.photo_id HAVING search_score > 0 ORDER BY search_score DESC [/code]
  7. Easy, you can't use MAX() because you haven't grouped anything to have a max, min, avg etc. You probably need to use a subquery here.
  8. Join the keywords table twice, once for each keyword. Just give the tables different aliases.
  9. You could use ENUM for simple things like Male/Female. But it sounds like you have a lot of branching (if its male you have one type, female another.) I wouldn't do a two table approach. The best way is to figure out how to best organize your main table (each individual piece of clothing) and work backwards from there. I'd make that table look something like this: -id (autoinc INT) <- not required btw but makes life much easier -description -garment_id -armor_id -buff_id -color_id Make a garments table: -id (autoinc INT) -description ('polo shirt') -gender (ENUM 'male','female','unisex') -type_id (use a garment_type table with entries like "pants","shirts","hats",etc) For attributes, it sounds like there is a 1 to many relationship (the same shirt could be 'warm', 'fuzzy','plaid','buttoned', who knows) So you would all of those attributes in a table then add another table to link those attributes with a specific garment_id.
  10. [code] SELECT co.* FROM CATEGORY AS cat JOIN CAT_LINK AS cl ON cat.category_id = cl.category_id JOIN COMPANIES AS co ON cl.company_id = co.company_id WHERE cat.category_name LIKE '%$search%' ORDER BY co.name [/code]
  11. I don't see the name of your date/time field. If it is all part of your "user" field, you'll need to break that apart first. Something like this should work: [code] SELECT DATE(name_of_timestamp) AS the_day, COUNT(DISTINCT(user)) AS num_users FROM table GROUP BY DATE(name_of_timestamp) [/code]
  12. You need an onchange for your select box and a span or div beside it where the results will appear <span id='myResults'></span><select onChange='recalc(this);'>... and in the head portion of your doc add this function: function recalc(selObj) {   var myVal = selObj.options[selObj.selectedIndex].value;   document.getElementById('myResults').innerHTML = myVal * 1.5;   //whatever you need to calculate here }
  13. Ok, I have a php app that can generate a pretty large table. I want: [list] [*]The user to be able to download that data as a CSV  file. [*]The CSV should be created in Javascript because its already there. [*]The file to be treated as a download by the browser. [/list] I've already written the Javascript to rip the data out of the table and make the CSV data. If I were using PHP for this I would use header content-type and disposition calls to get the browser to do what I want. How do I do that using Javascript? Thanks
  14. Have you given Quanta Plus a try? Its not specifically for PHP but it does a good job... of course theres always gvim. On the windows side, I use PHPEdit. I used to use Maguma, but it was too buggy. I'll use Dreamweaver for layout and design or when I've got to do just a little bit of coding. But I really don't like to do much coding from DW. I'm d/ling PHP Designer right now. See how that goes. Art
×
×
  • 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.