mikosiko
Members-
Posts
1,327 -
Joined
-
Last visited
-
Days Won
1
Everything posted by mikosiko
-
@fenway: Yes your query works... but in Reply#7 the OP said: .. for that case the OP will have to modify your query adding another (or as many) CROSS JOIN, and the necessary adjustments also in the WHERE clause.... I wonder if anyone did test the solution that somebody gave to the OP in Reply #8... which cover exactly what the OP was asking for... and in case that the OP also want to get all the information from the "Products" table (he was not asking for according to his example) modify the provided working query is simple: SELECT a.*, GROUP_CONCAT(b.attribute ORDER BY b.attribute) AS gp FROM Products a JOIN ProdAts b ON a.id = b.product GROUP BY a.id HAVING gp = CONCAT_WS(',',23,45); // or replace here for the attributes that you want ordered asc. well.. and having in mind the the OP never came back... maybe Reply# 8 just worked for him.
-
I just read the previous topic, and there, in Reply #7 PFMABismad gave you a good advice.... just follow it.... try the suggested modified select with Group by and SUM in phpmyadmin or whatever tool you use to validate your select and work from there
-
I use $doesnotmatteratall ... is just a variable name...
-
Change Field Name to Current Date in MySQL DB
mikosiko replied to anonymoose's topic in PHP Coding Help
. and you can see tons dying everyday in the vicinity .... poor kittens "Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe" A.Einstein -
I will like to see your tables schema (structure) for better advice.... for now... just a few thoughts: - I don't see the reason behind your array of quotes... if well designed, your quote model should hold the supporting information (the $mod date per example). - Don't see either the necessity for your foreach loop when you just can make 1 single select to recover all the information for all the quotes (again with a well designed model...) - Not clear to which table the column "price" belong, but most likely it should be in a "product-price-validdate" kind of table instead of in the quote (or quote details) itself. - I have also the impression that the "quotes" table should be included in the SELECT that you shown (probably adding the field quote_id and mod_date to the list of selected field, eliminating completely the quote array usage), and allowing you to GROUP BY the quote_id only knowing your complete relevant model and the supporting code will allow the forum members to give you better advice.. but imho go forward with that arrays structure doesn't make too much sense (at least to me).
-
mysql_result() is an alternative pay attention to the "Description" notes
-
in your product.php file try replacing this line: ->join('products', 'categories.id = products.cat_id') for this ->join('products', 'categories.id', 'products.cat_id')
-
seems that you are using the negation operator incorrectly in this line: elseif (!($fileType =="image/jpg" OR $fileType=="image/gif" OR $fileType=="image/png")) test it assuming that your $fileType IS a "image/gif" per example
-
@Maq... that has the potential to return more than one row anyways.... LEFT JOIN doesn't solve the problem. I see a couple issues here: - First, apparently the OP is capturing transactions associated to one (or several) accounts identified by an account_number, however he is not using the POST'ed account number (if any) for his first select which should allow him to get just one record in the first select. - Secondly, in the Transaction INSERT again he is not using the account_number, therefore is inserting orphan transactions not associated to any account. my suggestions are - Check for the proper POST'ed account_number usage in all the sentences. - and finally, due to the fact that the objectives are: UPDATE the account balance and also register (INSERT) the associated supporting transaction(s) is necessary to ensure that BOTH actions succeed; a TRANSACTION should be used in this case where you can COMMIT if both actions (INSERT/UPDATE) are successful or ROLLBACK everything is any of them fail. for TRANSACTION usage here is an example that can be useful: http://www.techrepublic.com/article/implement-mysql-based-transactions-with-a-new-set-of-php-extensions/6085922
-
could you post the data that you have in your postcodes table? (a few rows should be fine)
-
You can't "trust" the order when ORDER BY is not specified, you must specify the ORDER BY if you want a specific order. depending on the DB storage engine used to store the table you can get completely different results... in Innodb per example the order could be the PRIMARY KEY. In MyIsam the order could be the Insertion order if the table never have had updates/deletes/replaces... otherwise order will be anything. Is not setup available to define the default order in any storage engine AFAIK. if you updated your db recently and you are seeing different order than before probably the storage engine is now Myisam instead of Innodb for the affected tables. the rule of thumb: Never trust in "default order" because there is not such reliable thing... always use and ORDER BY if you want a specific order. just forgot to mention that in MyIsam an option exist (but I personally never use/trust on) which is: ALTER TABLE ORDER BY <column name> but it is used only for creation... order is not maintained after updates/deletes/refresh
-
and did you notice that sqlsrv_query() syntax has 4 parameters, been the last 2 inclusively optionals? sqlsrv_query( resource $conn, string $tsql [, array $params [, array $options]]) in other words... your statement: $lapsed = sqlsrv_query($db,$sql,array( "Scrollable" => 'keyset' )); seems that need to be written in this way: $lapsed = sqlsrv_query($db,$sql,array(), array( "Scrollable" => 'keyset' ));
-
don't post duplicated threads.... I did answer this in your first one.
-
read the description for the first option showed here... specifically the note regarding what sqlsrv_num_rows return. http://msdn.microsoft.com/en-us/library/ee376927.aspx
-
if you check your php log file (if logging is enabled) you will see the parsing error.
-
try this : exec("C:\\pstools\\psexec.exe -d C:\\folder\\application.exe arg1 arg2 arg3"); // Note the double \ usage other option: $thecmd = `C:\\pstools\\psexec.exe -d C:\\folder\\application.exe arg1 arg2 arg3`; // Note the backticks usage (shell_exec equivalent) echo "<pre>$thecmd</pre>";
-
don't know if this could be the only culprit... (syntax error by the end of this function) function forces($a,$b,&$force,&$direction) { //break up arrays $lat1=$a[0]; $lat2=$b[0]; $lon1=$a[1]; $lon2=$b[1]; //compute distance between points $distance=acos(sin($lat1)*sin($lat2) + cos($lat1)*cos($lat2) * cos($lon2-$lon1)); //compute force direction if ($distance==0) { $direction=rand(0,2*pi()); //pick random direction $distance=0.1; } else { $y=sin($lon2-$lon1) * cos($lat2); $x=cos($lat1)*sin($lat2)-sin($lat1)*cos($lat2)*cos($lon2-$lon1); //invert direction $direction=atan2($y,$x)+pi(); } $force=1/($distance*$distance) // MISSING ; IN THIS LINE }
-
Problem Uploading Image Files to Windows Server, permission denied
mikosiko replied to TecTao's topic in PHP Coding Help
In windows? -
you probably want to use TRANSACTIONS and COMMIT or ROLLBACK all if something is wrong (obviously you must code the necessary validations).... Stored Procedures or Functions and probably EVENTS could be useful for you too.... everything well documented in the Mysql Manual
-
what I was suggesting to you is echo just your query like: $query = "Select movie_name, movie_type" . "from movie" . "where movie_year>1990 " . "order by movie_type"; // ECHO YOUR QUERY AND VALIDATE IF IT IS WHAT YOU WERE EXPECTING echo "Query : " . $query; //$results = mysql_query ($query) //comment this line for now... uncomment it when you are satisfied with the echo results.
-
echo your query and check if is that what you are expecting
-
[OT] .... your nickname make me laugh... hopefully it doesn't represent you
-
'Enter' Key doesn't work but 'submit' does
mikosiko replied to Acute Chaos's topic in PHP Coding Help
here is an explanation and a couple solutions: http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/4908e026-088f-470a-9c57-d6bcde8882d0/ -
here is your fish: .... replace any wrong column name with your own, and with the proper dates that you want (or variables) select a.name, COUNT(b.job_done) AS job_done, COUNT(c.job_failed) AS job_failed, COUNT(b.job_done) + COUNT(c.job_failed) AS job_handled, (COUNT(b.job_done) * 100) / (COUNT(b.job_done) + COUNT(c.job_failed)) AS success_rate FROM employee AS a LEFT JOIN job_done AS b ON b.emp_id = a.emp_id AND b.fecha between '2011-06-21' AND '2011-06-26' LEFT JOIN job_failed AS c ON c.emp_id = a.emp_id AND c.fecha between '2011-06-21' AND '2011-06-26' GROUP BY a.name HAVING job_handled > 0; anything else is for you to work on.
-
well... a couple LEFT JOIN and using COUNT() (or SUM) will give you the results... with exception of the "score" column because it will lose meaning at the aggregation time... work on some code and came back if you still have doubts.