Jump to content


0 replies......

  • Please log in to reply
2 replies to this topic

#1 micromachine

  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 March 2005 - 11:23 AM

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.

#2 pecos

  • Members
  • PipPip
  • Member
  • 15 posts
  • Locationamsterdam, nl

Posted 28 March 2005 - 01:12 PM

Show us the PHP code! Otherwise there's not much we can tell you.
"Shunning object orientation is like refusing to use a car on grounds that you can build your own wheel." Harry Fuecks

#3 micromachine

  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 29 March 2005 - 12:28 PM

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">
<?php do { ?>
<td><?php echo $row_ShowJanDates['LEFT(calender.cday']; ?></td>
<td><?php echo $row_ShowJanDates['string']; ?></td>
<?php } while ($row_ShowJanDates = mysql_fetch_assoc($ShowJanDates)); ?>

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users