Jump to content

busby

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by busby

  1. 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
  2. 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?
  3. 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??
  4. 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??
  5. thanks for that...so whats the correct way?
  6. 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
  7. 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?
  8. 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.
  9. 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.
  10. 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?
  11. 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?
  12. 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.
  13. 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!!
  14. 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
  15. 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?
  16. is it right that ive only got untill tomorrow morning to do this? is that possible? also...do you need a logon? cant you just go on the game and choose which one of the 3 chars to use? is this turn based thing automatic? or do you attack at the push of a button? is your opponent another person? or computer player? the task is very vague and my knowledge on anything that can be used to do this is very basic its just out of my league
  17. hey all...ive been given a task to do using PHP...my knowledge of PHP isnt great but i know how to create websites and connect to a database etc and i think the people who gave me the task thought Id find this task easier than i really will......anyway...been pondering over this for couple of hours now and i cant figure out where to start....could someone please explain a method of doing this? at least help with where to begin? here is the task Mobile Fun Coding Challenge 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!!
  18. ive already tried that...it just produces the same error. ive just stumbled upon something very strange. i have 1 record in my database with the data in the username field as "kevin" and the data in the password field as "busby". when i try to login by typing a bunch of randum letters...those values go to login.php and i can echo them out. but if i type in the correct username and password...it doesnt post through to login.php any suggestions?
  19. ok..ive done this a million times..i have a working example here and i copied it and amended it for this new project but for some reason i cant get a form to post data to another page. this is the error message i get Notice: Undefined index: username in C:\wamp\www\uni\fyp\site\mobile\login.php on line 16 Notice: Undefined index: password in C:\wamp\www\uni\fyp\site\mobile\login.php on line 17 here is my form code: <form method="post" action="login.php"> <table align="center" cellpadding="0" cellspacing="0"> <tr> <td style="vertical-align:top;">Username: </td><td><input type="text" name="username" value="" /></td> </tr> <tr> <td style="vertical-align:top;">Password: </td><td><input type="password" name="password" value="" /><br /><input type="submit" id="submit" value="Login" /></td> </tr> </table> </form> and here is the code within the login.php where the form should post to $username = $_POST['username']; $password = $_POST['password']; // Help protect against MySQL injection $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); // Selecting data from database where correct username and password are found $sql="SELECT * FROM customer WHERE username='$username' and password='$password'"; $result=mysql_query($sql) or die(mysql_error()); i cant see anything wrong..been looking for hours...please please help me
  20. hello im creating a vehicle insurance website for a university project. its going to be an online profile site similar to http://www.swiftcover.com where users create a profile which stores their personal and vehicle data and they can view and edit their policy at any time and submit claims and view certificate etc. my only question is...what tables would i need for the database? would i have a customer table storing all their personal info and their username and password. then a vehicle table storing all vehicle info connected to the customer table via the C_ID would the customer table be connected to the vehicle table via the V_ID? what other tables would i need? i dont know why but i just cant picture the database in my head and i think once i know the tables i can continue on my own
  21. excellent! thankyou exactly what i was looking for and such a simple solution.
  22. here is some simple code for getting and displaying fata from a database $sql="SELECT * FROM messages WHERE m_id = '".$id."'"; $result = mysql_query($sql); <table border='0' cellspacing="4"> while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<th>Message</th>"; echo "</tr>"; echo "<tr>"; echo "<td>" . $row['message'] . "</td>"; echo "</tr>"; } now ive used that while loop to display those results how can i do that again without having a new SQL statement. i cant do 2 while loops because the first one has already got to the end of the amount of rows basically how can i have another while loop displaying those same results again?
  23. ok i made that change...it didnt make any difference though...when i select a title from the drop down it displays the number "1" instead of the message i want...because 1 is the value of the option tag if you look at the html code for the form and select tag you'l see what i mean...but i dont really understand why its displaying 1 this is so confusing coding really isnt my strong point..i urgently need this for an assignment though
  24. could you explain that a little more? i can see what url? do you want me to open the php file in a browser? if that is what your saying then ive just tried that and i do get this error: Notice: Undefined index: id in C:\wamp\www\uni\oswp\assignment\bank\showmessage.php on line 14 line 14 is: $id=$_GET["id"]; now i know that error means the variable id doesnt exist...but it should...take a look at the javascript section of the code in my original post. i took this code from w3schools and amended it to suit my needs..i just cant fix this
  25. i think its something to do with the variable its trying to GET on the php page to use in the SQL statement...but i really cant see whats wrong or how to solve it...not good enough at this to spot the problem
×
×
  • 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.