Jump to content

0 replies......


Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/2225-0-replies/
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/2225-0-replies/#findComment-7326
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.