Jump to content

micromachine

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

micromachine's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry- here's the PHP code. Thanks for trying to help out I have a text field called 'day' in a table 'calender. The field contains a date e.g. 28/09/2005. I want to be able to select the left 2 chars from this field and use it in a more complex query . When I run the query in the DM test window it works and outputs all the days as expected, but when I add the table/recordset to my webpage all I get is this displayed on screen:LEFT(calender.cday string If I remove the LEFT bit of this query and just do a normal SELECT command the query works fine though PHP (using Mysql) but it is producing a list of results like "02/01/2005 03/01/2005 04/01/2005" which isn't what I want - I want "02 03 04". I am using a text datatype for this field rather than a date datatype - mainly because I couldn't get the dates in British format(ie DD/MM/YYYY)- this is another problem I'll maybe ask about later! Here's the relevant PHP code DMW generated - thanks again for any help any of you can give to me - I hope I am making sense. mysql_select_db($database_dbconnect, $dbconnect); $query_ShowJanDates = "SELECT LEFT(calender.cday,2) FROM calender LEFT JOIN gigs ON calender.cday = gigs.Date WHERE (((calender.cday) Like '___01%') And ((gigs.Date) Is Null)) "; $ShowJanDates = mysql_query($query_ShowJanDates, $dbconnect) or die(mysql_error()); $row_ShowJanDates = mysql_fetch_assoc($ShowJanDates); $totalRows_ShowJanDates = mysql_num_rows($ShowJanDates); <table border="0"> <tr> <td>LEFT(calender.cday</td> <td>string</td> </tr> <?php do { ?> <tr> <td><?php echo $row_ShowJanDates['LEFT(calender.cday']; ?></td> <td><?php echo $row_ShowJanDates['string']; ?></td> </tr> <?php } while ($row_ShowJanDates = mysql_fetch_assoc($ShowJanDates)); ?> </table>
  2. Hi I posted a problem a couple of days ago ( the title with 'SELECT LEFT' in the title) and noticed no one was able to reply. Could I just ask - was the reason because the question wasn't meant to be part of this forum or is it that it was no one knew the answer ( or maybe I didn't explain it clearly)? I really appreciate all the help you all give to these forums so I don't want to sound ungrateful............. I am so perplexed by the problem I'm having - it's not down to queries and the SQL syntax as I've checked this in the MySQL manual........( i.e. how to use the 'left' SQL command ) but I can't find a jot on the web about this so if anyone knows out there I'd be very grateful for some help. Just to remind you, I write a query that works in MySQL that extracts the first 2 characters of a text string - as an example: SELECT LEFT(fieldname,2). When I preview this ( ie I test the Query in the Dreamweaver SQL test window) the query produces the correct results from the recordset. When I try to create a dynamic table (based on this recordset), I don't get the data output at all on my web page. Can anyone think why this should be? I have noticed that if I don't use SELECT LEFT everything works as expected......but when I try to use LEFT I get no data output on my webpage. THanks again anyone........if I find the answer first I will post it up.
  3. Please help! I have a query that works fine in the Dreamweaver query test SQL window but not when you run it. I am using MyqSQL ( latest ) and PHP with DWMX 2004. I have a field 'day' that holds a text values like "29/08/2004" ( yes I am using a text field when it is in fact a date field - I'll ask this in a mo if that's ok). I want to be able to print a little calender using Repeated Regions. I've written a query that does something like this: SELECT LEFT(day,2) When I test this in the Dreamweaver query window, the query runs correctly and I get e.g. 01 02 03 - so the query with the LEFT bit tests fine in the Dreamweaver query window. When I run the query on the webpage through PHP I get no table produced or data but just some text on the web page n e.g. LEFT(2). It seems when ever I try to use LEFT or SUBSTR to chop a field for display, it doesn't work. I am really stuck. If the query worked in the test window, why shouldn't it in the main web page window? I've tried using normal tables, repeated regions, all kindsa stuff. Please help Obi One you are our last hope!
×
×
  • 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.