PHP Nubsauce Posted July 11, 2008 Share Posted July 11, 2008 Hey all, see if you can figure this one out.. $links33 = @mysql_query("SELECT * FROM ".$mysql_pretext."_customer_payments WHERE customer_id = '$customerid' ORDER BY date ASC"); I'm trying to display all customer payments from oldest to newest, and its doing that, but its breaking it up by customer! Example: 1-1-08 customer a 2-2-08 customer a 3-3-08 customer a 1-2-08 customer b 2-3-08 customer b 3-4-08 customer b Any help making it look like so: 1-1-08 customer a 1-2-08 customer b 2-2-08 customer a 2-3-08 customer b 3-3-08 customer a 3-4-08 customer b Please? Nubsauce Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 11, 2008 Share Posted July 11, 2008 Remove the part where it says to select it by customer ID. Quote Link to comment Share on other sites More sharing options...
PHP Nubsauce Posted July 11, 2008 Author Share Posted July 11, 2008 I can't do that, its handshaking with something else :'( Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 11, 2008 Share Posted July 11, 2008 Post more code. If you want a full list, you'll need to remove the customer ID. Quote Link to comment Share on other sites More sharing options...
PHP Nubsauce Posted July 11, 2008 Author Share Posted July 11, 2008 <?php $links34 = @mysql_query("SELECT * FROM ".$mysql_pretext."_customers WHERE referrer_id = '$id'"); if (!$links34) { echo("Error retrieving projects from the database!<br>Error: " . mysql_error()); exit(); } while ($link = mysql_fetch_array($links34)) { $customerid = $link["ID"]; $clientcompany = $link["company"]; ?> <?php $links33 = @mysql_query("SELECT * FROM ".$mysql_pretext."_customer_payments WHERE customer_id = '$customerid' ORDER BY date ASC"); if (!$links33) { echo("Error retrieving customer payments from the database!<br>Error: " . mysql_error()); exit(); } ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted July 11, 2008 Share Posted July 11, 2008 if the format of the date stored in db is "1-1-08" then no surprise you are having problems. Store dates in a DATE type field in ISO date format YYYY-MM-DD. Then you can sort, do date comparisons, select ranges, use Mysql datetime functions. But your format is totally useless. Store dates for function, not appearance. Format on output. Quote Link to comment Share on other sites More sharing options...
PHP Nubsauce Posted July 11, 2008 Author Share Posted July 11, 2008 I figured this one out myself, thanks for the help tho <?php $links33 = @mysql_query("SELECT * FROM ".$mysql_pretext."_customer_payments LEFT JOIN ".$mysql_pretext."_customers ON (".$mysql_pretext."_customer_payments.customer_id = ".$mysql_pretext."_customers.ID) WHERE referrer_id = '$id' ORDER BY date ASC"); if (!$links33) { echo("Error retrieving projects from the database!<br>Error: " . mysql_error()); exit(); } $rowstotal = mysql_num_rows($links); ?> Quote Link to comment Share on other sites More sharing options...
PHP Nubsauce Posted July 11, 2008 Author Share Posted July 11, 2008 But your format is totally useless. Store dates for function, not appearance. Format on output. First you ask me what my field type is, then you just throw that comment in there afterwards. Thats a big "...." Yes, my field type is date. Thanks, Nubsauce. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.