![]() |
|
| Domain Name Sales | Domain Software | Calculate UK Domain Drop Dates | Domain Registration | NameDrive | Domain Parking | Subscribe to our Domains For Sale newsletter |
| | ||||||
| Home | Register | Rules | Membership Upgrade | Domains For Sale | Domain Name Escrow | Mark Forums Read | Domain Classified | Chat Room |
| Scripts and Coding PHP, MySQL, scripts |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
![]() | php array
A bit more help needed... I have a table with a column called date. Dates in this column are in the format MonthDay, examples: Jan31, Feb2, Apr9, Jul27. I need to query the table for all dates in a month to get an array that looks like this: $events = array(1,7,8,17,18,23); So far I have: $month='Feb'; (or whatever month is given to the variable) $query = "SELECT date FROM table WHERE date LIKE '$month%'"; $events = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo substr($row['date'], 3) . ','; } } This echos the results with a comma, but there is a trailing comma which is not needed, and also I am trying to force this into an array, but I think there must be a more natural way of retrieving this array. Basically the rest of my script works well if it is given an array like this: $events = array(1,7,8,17,18,23); Any help appreciated.
__________________ Connect with me @ TW:LI:FB | MyWeb | D/L domains4sale | Morecambe London Student Forums Student Books UK promotions agencies |
| |
| | #2 (permalink) |
![]() |
Check the number of rows in the result, then include a counter, and if the counter = num_rows don't include the ',' bit on there. Thats a quick way of doing it. What you call $row is already an array, your just looping through it, why not perform your array actions on that ?
__________________ Browse: |
| |
| | #3 (permalink) |
![]() |
Thanks Skinner - I got a bit of help on another forum which seems to be holding up (fingers crossed): PHP Code:
__________________ Connect with me @ TW:LI:FB | MyWeb | D/L domains4sale | Morecambe London Student Forums Student Books UK promotions agencies |
| |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Domain Name Community | Replies | Last Post |
| UK Counties list | grantw | General Board | 30 | 14-12-2008 08:56:44 PM |
| PHP include in a Smarty Template | admin | Scripts and Coding | 1 | 13-05-2008 06:37:26 AM |
| PHP variable help | purg | General Board | 4 | 04-03-2008 02:30:21 PM |