[PHP-DB] Re: Character encoding issues: Pound- sign £ becomes a ú - why?

2005-12-14 Thread El Bekko

Alex Gemmell wrote:

Hello,

I'm experiencing some odd character encoding issues.  My PHP webpage is 
displaying test from a MySQL database.  What happens is that I export 
data from an SQL Server database to a MySQL (4.0) database.  Somewhere 
along the line the British currency pound-sign £ becomes a ú (u with 
somesort of accent on it!).  I cannot figure out why this is happening 
and what to do about it.


I could use a PHP routine to find-and-replace the chars but surely there 
 is a way to tackle the root problem?


Any ideas gang?

Alex


Try using the pound; charachter.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Date Formatting Question

2005-12-14 Thread Bomgardner, Mark A
I am trying to format the month portion of a date that I am trying to
pull from MySQL to be placed into a drop down menu to modify the date.
I have tried several ways and none seem to be working.  

I am pulling the date out of MySQL with: 
$sDate = explode(-, $row_events['Sdate']);

And then attempting to insert each portion of the array into a drop down
menu with:
echo select name=Smonth;
echo option selected$sDate[1]/option;
which is where I am running into the problem.  I pull out the month as 2
digit numeric 01, 02, 03 etc., but I want it displayed as January,
February, March, etc.,

I have tried the following with no success:
Date(F,strtotime($sDate));  
Strftime(%B:,$sDate);
Date(F,$sDate);


I would use MySQL to format the date, but I have three date fields to
modify and it would be easier to do it in PHP

Any pointers would be appreciated.


Mark Bomgardner
Technology Specialist
KLETC

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: Date Formatting Question

2005-12-14 Thread El Bekko

Bomgardner, Mark A wrote:

I am trying to format the month portion of a date that I am trying to
pull from MySQL to be placed into a drop down menu to modify the date.
I have tried several ways and none seem to be working.  

I am pulling the date out of MySQL with: 
$sDate = explode(-, $row_events['Sdate']);


And then attempting to insert each portion of the array into a drop down
menu with:
echo select name=Smonth;
echo option selected$sDate[1]/option;
which is where I am running into the problem.  I pull out the month as 2
digit numeric 01, 02, 03 etc., but I want it displayed as January,
February, March, etc.,

I have tried the following with no success:
Date(F,strtotime($sDate));  
Strftime(%B:,$sDate);

Date(F,$sDate);


I would use MySQL to format the date, but I have three date fields to
modify and it would be easier to do it in PHP

Any pointers would be appreciated.


Mark Bomgardner
Technology Specialist
KLETC


make a function like this:

function datenum2str($date)
{
$newdate = str_replace(01,Jan,$date);
$newdate = str_replace(02,Feb,$date);
$newdate = str_replace(03,Mar,$date);
$newdate = str_replace(04,Apr,$date);
$newdate = str_replace(05,May,$date);
$newdate = str_replace(06,Jun,$date);
$newdate = str_replace(07,Jul,$date);
$newdate = str_replace(08,Aug,$date);
$newdate = str_replace(09,Sep,$date);
$newdate = str_replace(10,Oct,$date);
$newdate = str_replace(11,Nov,$date);
$newdate = str_replace(12,Dec,$date);

return $newdate;
}

And then use this:

echo select name=Smonth;
echo option selected value=\$sDate[1]\$newdate/option;


Hope it helps,

El Bekko

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date Formatting Question

2005-12-14 Thread tg-php
You got the right idea, but you're making it more complicated than it needs to 
be.

your $sDate after using explode() is going to contain an array.  strtotime 
doesn't take an array, it takes a string.

$monthName = date(F, strtotime($row_events['Sdate']));
$monthNumber = date(m,  strtotime($row_events['Sdate']));
// or n if you want 1 instead of 01 for January

echo select name='sMonth'\n;
for ($i = 1; $i = 12; $i++) 

  // using date() below to get month name, day and year irrelevant
  $selectMonthText = date(F, mktime(0, 0, 0, $i, 1, 2000));

  if ($i == $monthNumber) 
$selected =  SELECTED;
   else 
$selected = ;
  
  echo option value='$i'$selected$selectMonthText/option\n;

echo /select\n;


-TG


= = = Original message = = =

I am trying to format the month portion of a date that I am trying to
pull from MySQL to be placed into a drop down menu to modify the date.
I have tried several ways and none seem to be working.  

I am pulling the date out of MySQL with: 
$sDate = explode(-, $row_events['Sdate']);

And then attempting to insert each portion of the array into a drop down
menu with:
echo select name=Smonth;
echo option selected$sDate[1]/option;
which is where I am running into the problem.  I pull out the month as 2
digit numeric 01, 02, 03 etc., but I want it displayed as January,
February, March, etc.,

I have tried the following with no success:
Date(F,strtotime($sDate));  
Strftime(%B:,$sDate);
Date(F,$sDate);


I would use MySQL to format the date, but I have three date fields to
modify and it would be easier to do it in PHP

Any pointers would be appreciated.


Mark Bomgardner
Technology Specialist
KLETC


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: Date Formatting Question

2005-12-14 Thread Neil Smith [MVP, Digital media]
Apart from anything, you need to supply an option value for each of 
those options, not just rely on the browser which will  default to 
passing the option *text* back from the form, if you specify no 
value. So your option elements should read


option value=1January/option

Notwithstanding that, RE below - you guys are all nuts, this is a 
ridiculous way to do it.

Let MySQL do the work, it has perfectly good functions to do this :

SELECT  DATE_FORMAT(date_field_name, '%c') AS intDate,
DATE_FORMAT(date_field_name, '%M'') AS strMonth
FROM yadda etc etc

Then you use (assuming your're using  $result = mysql_fetch_assoc() 
as your looped result variable name)


$optionlist='';
$selected_month = (integer) $_GET[Smonth];

while ($result = mysql_fetch_assoc($link)) {
$optionlist.=option;
if ($selected_month==$result['intDate']) {
$optionlist.=' selected=selected';
}

$optionlist.=''.$result['intDate'].''.$result['strMonth']./option'\r\n\t;
}   //  End while

print($optionlist);

HTH
Cheers, Neil




To: php-db@lists.php.net
Date: Wed, 14 Dec 2005 15:52:31 +0100
From: El Bekko [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
Subject: Re: Date Formatting Question

Bomgardner, Mark A wrote:
I am trying to format the month portion of a date that I am trying to
pull from MySQL to be placed into a drop down menu to modify the date.
...snip...
modify and it would be easier to do it in PHP
Any pointers would be appreciated.

Mark Bomgardner
Technology Specialist
KLETC

make a function like this:

function datenum2str($date)
{
$newdate = str_replace(01,Jan,$date);
$newdate = str_replace(02,Feb,$date);
$newdate = str_replace(03,Mar,$date);
$newdate = str_replace(04,Apr,$date);
$newdate = str_replace(05,May,$date);
$newdate = str_replace(06,Jun,$date);
$newdate = str_replace(07,Jul,$date);
$newdate = str_replace(08,Aug,$date);
$newdate = str_replace(09,Sep,$date);
$newdate = str_replace(10,Oct,$date);
$newdate = str_replace(11,Nov,$date);
$newdate = str_replace(12,Dec,$date);

return $newdate;
}

And then use this:

echo select name=Smonth;
echo option selected value=\$sDate[1]\$newdate/option;


Hope it helps,

El Bekko





CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php