Jump to content

Muddy_Funster

Members
  • Posts

    3,372
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Muddy_Funster

  1. I have had to use a SELECT within a SELECT only when doing a comparison filter between MySQL and Microsoft SQL Server. As for the UPDATE loop you posted - you have a bit of a missunderstanding about how that would work.
  2. Deffinately my quote of the week!
  3. hmm, give this a shot then: $start = $_POST['start_date']; $end = $_POST['finish_date']; $sql = "SELECT order_id, order_num, date, SUM(nett_price) as total, (SUM(nett_price) / DATEDIFF('$end', '$start')) AS daily_avg FROM orders WHERE ((complete = 'Y') AND (tx_type ='PAYMENT') AND (date BETWEEN '$start' AND '$end'))"; also update youre or die() to read: or die("ERROR: >> <BR>".mysql_error()."<BR> this occured trying to run the following query: <BR> $sql");
  4. sounds likely, append or die ("ERROR: >> ".mysql_error()); to both the lines with mysql_query() and mysql_fetch_assoc() (taking out the ; that is already there) and we will get an ide of where it's all going wrong.
  5. no problem at all, glad I could help
  6. there is a method for classes where by you can basicly tell php that "if this class isn't loaded already, check this file for it - if it's there load it " have a look at http://php.net/manual/en/language.oop5.autoload.php
  7. Genius! see, if I knew what I was dooing I wouldn't look quite as stupid as I feel! That was exactly the issue and now the script is working. On to figure out how to populate the div now. Thanks again PFMaBiSmAd
  8. Just thought I would ask as I see that the AJAX help board is something of a ghost town (much like the MS SQL board). Since my post there doas also have some php in it, and I am in no way certain my problem is not in the php could anyone that knows a bit of both please have a look at it here: http://www.phpfreaks.com/forums/index.php?topic=343419.0 cheers, just hope this circumvents the double posting rule
  9. ahhh, so if I want to inject some code on your site I'll just not use a name field, got it
  10. I'm still not clear, are you trying to access a class over multiple pages or are you simply looking to make a value available to multiple pages?
  11. try changing: $db_orders_query_result = mysql_query($sql, $db_connection); print($db_orders_query_result['daily_avg']); to: $db_orders_query = mysql_query($sql, $db_connection); $db_orders_query_result = mysql_fetch_assoc($db_orders_query); print_r ($db_orders_query_result);
  12. that's all great untill someone puts in white space or a control character. incidently, why are you only running some inputs through mysql_real_escape_string() and not all of them?
  13. well if it's just a display problem and not an actual grouping issue, conditionalise the display $filter = ''; foreach($array as $key => $value){ if ($filter != $value){ echo " ".$value."<br />"; $filter = $value; } }
  14. There are different ways of doing different things depending on what the object actualy is. How about being a little more specific on what you are looking for?
  15. you could just change your SELECT statement to use WHERE (comments IS NULL AND comments != '')
  16. could you elaborate on "doesn't work"?
  17. by group together do you meen display each one only once?
  18. howas about keeping it all together?: $sql = 'SELECT order_id, order_num, date, SUM(nett_price) as total, COUNT(DISTINCT date) as num_days, (ROUND(SUM(nett_price) / COUNT(DISTINCT date)), 2) AS daily_avg '; $sql .= 'FROM orders '; $sql .= 'WHERE complete = "Y" AND tx_type = "PAYMENT" AND date >= "'.$_POST['start_date'].'" AND date <= "'.$_POST['finish_date'].'" ';
  19. OK, I have some code for you, going by what I think you are looking for. Have a look over it and replace your current while loop with the following if you think it suits: $query = "SELECT id, thumbpath, fullpath, tag, desc, adddate FROM portfolio ORDER BY adddate ASC"; $tagCheck = 'nonsenese value'; //anything that is never going to be an actual tag value $fistCheck = true; // variable to check if the output is the first because if it's not we will need to close the div before opening another one $result = mysql_query ($query); //you could realy use some error capture on your query stuff While($row = mysql_fetch_array($result)) // loop through the results from the query { if($tagCheck != $row['tag']) //check if the tag value from the database is different to what the last value was { //if it is different then if($firstCheck != true) //check if this is NOT the first record returned { //if this is not the first record returned then echo "</div>"; // close the last div }else //if this is the first record { $firstCheck = false; //update variable to show that first record has now been returned } $tagCheck = $row['tag']; // still if the tag value is different - update tag value to be the same echo "<div class='boxgrid'>"; // as this is a new tag we need a new div } // the following information will be processed every time $fPath = $row['fullPath']; $tPath = $row['thumbPath']; $desc = $row['desc']; echo "<a href=\"$fpath\" rel=\"prettyPhoto['$tagCheck']\"><img src=\"$tPath\" title=\"$desc\"/></a>"; } //end of recordset return loop echo "</div>" //now we are done close off the last div It's not tested, so will odds on have a few errors in it. Let me knopw what you think.
  20. do you want to do it in php or sql?
  21. you could just use SELECT AVG(nett_value)....
  22. include is a statement, not a function, you shouldn't use () with it. "include ('../func/config.php'); " should really be "include '../func/config.php'; "
  23. lets see your table structure then
  24. what are you planning to use to identify when a new div should be apllied?
×
×
  • 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.