
busby
Members-
Posts
57 -
Joined
-
Last visited
Profile Information
-
Gender
Not Telling
busby's Achievements

Member (2/5)
0
Reputation
-
ok...ive spotted a flaw in all of this. even if i got this SQL to work it wouldnt give me the average sales figures for each day. because it could occurr that some days may have zero orders therefore wont appear in the database orders table. so if someone types in september 1st and september 10th...but september the 5th didnt have any orders it would only be counting 9 days and not 10...giving the wrong result. so.......back to square one....see original post lol
-
ok funster i attached it to the end of those 2 lines and i get this error now ERROR: >> Operand should contain 1 column(s) so im assuming it means the SELECT statement isnt returning any data?
-
thanks funster...changed it to your code but now i get this error Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in which also leads me to believe its something in the SQL statement??
-
i think its a problem with the SQL statement but i dont know what...when i use mysql_num_rows to see how many rows are returned it throws up an error. which usually means theres something wrong with the SQL...anybody??
-
thanks for that...so whats the correct way?
-
well...i swapped my SQL statement for the one you gave me, then I commented out everything else below that statement and just had the following. $db_orders_query_result = mysql_query($sql, $db_connection); print($db_orders_query_result['daily_avg']); i ran the page but nothing shows up...no errors or anything..just blank
-
Ive never seen an SQL statement like that before. im a rookie with this kind of stuff but i tried inserting it into my code and i couldnt get it to work. Would the method i mentioned above work? having the extra SQL statement below the main one?
-
One thing i thought of but wasnt sure if it was correct was..... Could i just do another SQL statement underneath the one i already have only selecting the DISTINCT dates within that date range? Then dividing the SUM of the nett values by the amount of dates returned from the second SQL statement? would that work? Any help is greatly appreciated.
-
The SQL is $sql = 'SELECT order_id, order_num, date, SUM(nett_price) '; $sql .= 'FROM orders '; $sql .= 'WHERE complete = "Y" AND tx_type = "PAYMENT" AND date >= "'.$_POST['start_date'].'" AND date <= "'.$_POST['finish_date'].'" '; Lets assume i test it and type in 2 dates and it returns ten results. thats 10 orders. however there is only 7 days because 3 orders were made in 1 day. so i need to add all the 10 nett_prices together and divide by the 7 days. if that makes sense. but i dont know how to do that in the code.
-
pardon my inadequate maths skills but would that get the same results as adding all the values together and dividing by the amount of distinct days there are?
-
Hi I hope this is a simple problem that i cant solve and someone here will know. I need to create an SQL report showing average sales figures for a period of time decided by the user. for example if £100 was made in 10 days the average figure would be £10 a day. Ive created a page where a user enters in 2 dates. SQL then selects the nett_value, date, order numbers etc from an orders table where the dates are between the 2 dates given. I need to find the average nett_value from all those returned. I know i have to add together all the nett prices and then divide by how many dates there are but i dont know how to do that in the code. Because if there are several purchases in 1 day all of the purchases are counted but the day only gets counted once. or miss the day completely if there were zero purchases. So i used the SELECT SUM(nett_value) function for selectin all of the figures and adding them together...now i need to know how to divide them by how many days there are between the 2 entered dates. can someone help me?
-
Hi I have been given a task to create some SQL reports. One of the reports is to display all the customers who have purchased a certain product based on user selection and then have those results able to be extracted to a mailing list. So ive got the report done. Some drop down boxes allow a user to select a product and once submitted the results are then displayed. But i dont even know where to begin with extracting those results to a mailing list. Could someone help me please? What method should I use? and where do i begin? BTW im a rookie with PHP/Mysql ive just got my first job since leaving university and this is a task ive been given at work so any quick and helpful replies are greatly appreciated Thanks in advance.
-
i went to university for 4 years bachelors degree i dont even know half the terminology that is thrown at me from employers or even some of the stuff in that list. thanks...a little uplifting but discouraged is pretty much how i feel...and a little like the university ripped me off...a problem im worried about is not being able to keep a job in development...losing grip on the industry as it advances and changes without me because the technologies change. and that without being able to keep a job ill never be good enough. edited to include the test ( imo its slightly vague...but i think they want it writen in PHP...not sure if it requires login scripts...i look at it and might as well be looking at a space shuttle engine Create the following game: You set of warriors, each warrior has the following data: ● Name ● Health ● Attack ● Defence ● Speed ● Evade Health, Attack, Defence and Speed are integer values between 0 and 100. Evade is a number between 0 and 1. There are currently 3 types of warrior: ● Ninja ○ Health (40-60) ○ Attack (60-70) ○ Defence (20-30) ○ Speed (90-100) ○ Evade (0.3-0.5) ● Samurai ○ Health (60-100) ○ Attack (75-80) ○ Defence (35-40) ○ Speed (60-80) ○ Evade (0.3-0.4) ● Brawler ○ Health (90-100) ○ Attack (65-75) ○ Defence (40-50) ○ Speed (40-65) ○ Evade (0.3-0.35) The values for each attribute are specified as a range, on creation each warrior will be assigned a random value within this range for the given attribute. Warriors can take part in a battle, a battle has only 2 combatants. Warriors take it in turn to attack each other. The warrior with the greatest speed takes the first attack (in the event of two with the same speed, player with the lower defence goes first). The damage dealt is (attack - oppositions defence) and is taken from the health. Damage may be avoided, the chance of avoiding an attack is specified by the evade attribute. The max amount of turns is 30 per player, if no player is defeated then the battle is a draw. As the battle progresses a text output should be shown. When a warrior gets to zero health the warrior is defeated. Special attributes of warriors: ● Ninja With each attack there is a 5% chance of doubling the attack strength. ● Samurai When a samurai evades an attack there is a 10% chance of regaining 10 health. ● +Brawler ○ When a brawler’s health falls to less than 20% their defence increases by 10. Allow a form to select player 1 and 2, and when submitted create a battle with the 2 players and output the result of the battle!!
-
you mean at university? they covered web database programming, PHP programming, asp programming, Flash and action script, javascript, XML SQL CSS HTML, graphics, few other things i appear to be struggling with everything given to me outside of university...if i get a job..the work is too hard and i get fired...ive just been given a test for a junior job role...but the test is too hard....its just so difficult but it wasnt this hard at university its startin to really bug me
-
hey i finished university about 2 months ago after studying web development. im just waiting for graduation now and looking for full time work in web development. during the last 2 months ive had 2 jobs...one as an ASP.net developer and the other as a PHP developer...i lost both jobs within a matter of weeks because both said they needed someone more advanced as i was struggling to get work done quickly enough. ive continued to apply but more specifically for junior and graduate roles...this morning someone i sent my CV to got back to me and said they would like to send me a small test before they decide on an interview or not...this is for a junior web developer role...i recieved the test and have been trying to do it all day i just cant do it....its far too complicated for me and i dont even know where to begin...i only have untill tomorrow morning. this has got me thinking my time at uni has been a complete waste...perhaps i didnt learn as much as i needed to even though i managed to pass all my modules and create what i think is quite a good final project (using PHP) i cant seem to hold a job down...and am struggling with a junior roles test and its getting me down...can someone give me any advice?