Jump to content

Maq

Administrators
  • Posts

    9,363
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Maq

  1. You don't absolutely need it. It's just an alias to reference the column easier for brevity purposes. I see. Kind of like storing it in a variable instead of having to type SUM['$var'] just like when you store $var = $_GET['name'] You could think of it that way
  2. You don't absolutely need it. It's just an alias to reference the column easier for brevity purposes.
  3. Missing the AS total: $query2 = "SELECT SUM($type2) AS total FROM customers WHERE sched=1";
  4. Change these lines to (I think your $row line wasn't correct): $query2 = "SELECT SUM($type2) AS total FROM customers WHERE sched=1"; and echo "Total ". " = $". $row['total'];
  5. Are you sure you have values in your db WHERE sched=1? The only time SUM returns null is when the result set is empty.
  6. Take out the periods: $query2 = "SELECT SUM('$type2') as total FROM customers WHERE sched=1"; $type2 will interpolate because the primary string is in double quotes.
  7. Echo $query2 out and see exactly what the query is.
  8. You're assigning here NOT comparing: if ($cartype = 1 ) Besides, you have elseif statements, only one block will get executed.
  9. Maq

    PHP or JS

    just checked this thread for the first time today..wondering how cars and gloves are involved...lol I think you answered your own question.
  10. roseman5544, DO NOT double post, I delete your other thread. Also don't mark as urgent, please look at the rules: http://www.phpfreaks.com/page/rules-and-terms-of-service
  11. - First of all, your code does not populate a form field as far as I can see. Does your print statement output anything? - You should be sanitizing any input to the database with mysql_real_escape_query to prevent sql injections. - You have an extra terminating '}' here, but no starting one (fatal error): // Show data print($row[plunum]); } - Your query looks valid, although I can't guarantee that it's correct. If you are seeing a blank screen it's because you have the fatal error I mentioned above. Fix it and put these 2 lines directly under your opening <?php tag to detect further errors: ini_set ("display_errors", "1"); error_reporting(E_ALL);
  12. Maq

    Arrays

    You don't need that huge array, you can simply use rand. I revamped your code a bit: ini_set ("display_errors", "1"); error_reporting(E_ALL); class Game { function __construct() { //Constructor } function display($max) { $results = null; $i = 0; while($i { $results[] = rand(1,$max); echo " "; $i++; } print_r($results); return $results; } } $max = 35; $object1 = new Game(); $object1->display($max); ?>
  13. The date functions are a bit slow but for only displaying 7 days of the week and the benefit of having the flexibility of changing/adding to the format, I think it's worth it.
  14. AFAIK, it doesn't matter. Why, do they act differently in your code?
  15. In the future you can temporarily use or die(mysql_error()) to display mysql errors. But you should eventually fix/handle them properly.
  16. Comments in the code (check out date for date formatting, the "l"): //Gets the current day (Thursday) $cDay = strtotime(date("d")); //Loop through 1-7, to increment each day of the week for($i=1; $i{ //"l" is just the format for date (A full textual representation of the day of the week) //strtotime takes the current day ($cDay) and adds +1 ($i) each loop, adding a day echo '' . date("l", strtotime('+'.$i.'day', $cDay)) . ' $i -> +' . $i . 'day '; } ?> Output: Thursday $i-> +1day Friday $i-> +2day Saturday $i-> +3day Sunday $i-> +4day Monday $i-> +5day Tuesday $i-> +6day Wednesday $i-> +7day Hope that makes sense.
  17. Maq

    Math on mysql

    FYI, in your first code, which I don't really get, you would change the last bit to (comments in the code): $zmienna=mysql_fetch_array($result2); //need to fetch the result2, not query2 if($zmienna){echo " Command z is successful ";} else {echo " Command z is not successful ";} echo " Result: ".$zmienna['value2']; //need to use zmienna, because it holds the result set (array data), not query2 which is just a string
  18. Crashes it or shows a blank page? It works for me (ff3). Output (of course I don't have your CSS class): If it's blank, try turning on error reporting: ini_set ("display_errors", "1"); error_reporting(E_ALL);
  19. Try something like: $cDay = strtotime(date("d")); for($i=1; $i{ echo '' . date("l", strtotime('+'.$i.'day', $cDay)) . ''; } ?>
  20. date and strtotime are probably what you're going to need here. Do you have any code for us to work off of?
  21. Maq

    Newbie Help

    Sure. AJAX is an easy concept to grasp but sometimes a pain to implement. If you have more questions, don't hesitate.
  22. Yes, how else would your program know the BD to use? mysql_query is what actually executes your query. Read the documentation...
  23. CSV fields are a horrible idea, don't do that. You need to use the IN() function.
  24. Read the documentation: http://www.apachefriends.org/en/xampp-windows.html
×
×
  • 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.