Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. http://phpjs.org/functions/number_format:481
  2. Fenway's comment was neither unfair nor unwarranted IMO. The fact is that many people who post questions on this forum do not search before they post a question, and when prompted with a response like Fenway's they might be more inclined to attempt to find the solution on their own.
  3. There are PHP compilers available. Two I know of offhand that you can look into are PriadoBlender and Roadsend.
  4. Prepared statement parameters can't be column names.
  5. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=308855.0
  6. SELECT restaurants.id, restaurants.name, restaurants.category, restaurants.ratePoints, restaurants.rateTimes, restaurants.smoking, restaurants.alcahol, avg(menu_items.price) as average_price FROM restaurants JOIN ON (restaurants.id = menu_items.restaurant) WHERE id = '$id' LIMIT 1 By the way, you have a typo in one of your column names, alcahol. And depending upon if that typo exists in the actual table or not you'll need to adjust that in the query.
  7. You'll also have to convert the string to an integer using parseInt(): var amount1 = '1,200'; var amount2 = 25.00; var total = parseInt(amount1.replace(',', '')) + amount2;
  8. It is something stupid: You're using a Mac.
  9. $compare = array(); $i = 0; while(isset($_GET['compare' . $i])) { $compare[] = $_GET['compare' . $i]; } print_r($compare);
  10. What I think you're referring to is the fact that you can't send any headers after there is any output.
  11. You can use setInterval() and store the last time the function was called in a cookie to transfer the time between pages.
  12. You can't do it like that. Instead you can create the string for header() beforehand and then simply pass it to header() afterwards.
  13. In PHP you use . to concatenate strings, not +.
  14. For that you would need to use a MySQL JOIN. Something like this should work: SELECT restaurants.name, AVG(menu_items.price) as average_price FROM restaurants JOIN ON (restaurants.id = menu_items.restaurant) [ot]Statistically speaking the mean of a set of data isn't usually important for this type of thing. More often the median is much more important.[/ot]
  15. Well, then what you're looking for isn't another way to handle star ratings (In fact, any other way would be pretty misleading). Instead, you're looking for a way to rank different entries overall. One such way, as you mentioned in the Bayesian rating system, of which the average star rating is one factor. Here's an example MySQL implementation of the weighted Bayesian rating system using your current setup: SELECT * FROM table ORDER BY (number_of_votes / (number_of_votes + 0) * (total_vote / number_of_votes) + (0 / (number_of_votes + 0)) * (SELECT AVG(total_vote / number_of_votes) FROM table) DESC LIMIT 10 That should work, but with your current setup I can't think of any way to do it without a subquery. If your database structure was nicer it would be easier. Note that if you want to require a minimum number of votes for it to be selected in the query (and displayed on the top X rated) you'll need to change the 0s in that query to whatever requirement you want.
  16. I don't see anything wrong with your current method. That is generally how all star voting systems work. People vote 1-5 and you display the average of those votes. So what if the first vote is 5 and that boosts it to 5 automatically? That's why you also display the number of votes so people don't get the wrong idea.
  17. PHP function names are case-insensitive, so it doesn't matter. Find the line where the error is occurring, find the result that the call to mysql_num_rows on that line is using and print out the query that was used to create that result.
  18. That's happening because the previous mysql_query is returning false. Print out the query and see what the problem is.
  19. No it's not working. That along with this: if ($_POST['newBidder']) { Will cause problems when the $_POST['deleteBidder'] and $_POST['newBidder'] variables are not set, as you're seeing.
  20. Yeah, cags is right. I was confusing PCRE regular expressions with Ruby regular expressions where the m modifier makes newlines be treated as regular characters (and thus be matched by the period).
  21. Nothing doesn't just not work for no reason. Look at this line: if ($_POST['deleteBidder']) Should be: if(isset($_POST['deleteBidder']))
  22. The reason the URL can be like that because the index for that directory can be excluded. In most cases the directory is index.php, so a URL like www.site.com/?r=referral is the same as www.site.com/index.php?r=referral. In the same way that if you want to visit the index of a website you don't need to include /index.php (assuming the index is index.php).
  23. Because even though you're not submitting that form the code is getting a point where it's using a variable that is not defined (obviously). Just make sure that before you use a variable from an outside source that might not be set you make sure that it is using isset. You must've edited that code because the errors you posted can't be happening on those lines in the code provided.
  24. Can you post your full code as it stands now? (Both HTML and PHP)
×
×
  • 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.