I have, in the same database as cmsms, created a table with a clients prize list on some books. To access the database I used a method i found, actually related to connecting to another database, and patched together a code, and put it in a user defined tag. It works exept for two thing - characters in swedish like Å Ä and Ö are replaced with some kind of question mark symbol, and new lines are not transfered.
This must have something to do with the code below since phpmyadmin shows the Å Ä and Ö characters as normal?
This is the code:
Code: Select all
global $gCms;
$conn =& $gCms->GetDb();
// Setup connection variables
$server = 'mysql.a10.levonline.com';
$userid = 'a1006001';
$password = '********';
$database = 'a1006000_db1';
// Connect to the database
$conn->PConnect($server, $userid, $password, $database);
$conn->SetFetchMode(ADODB_FETCH_ASSOC);
$conn->charSet = utf-8;
$result = $conn->Execute('SELECT * FROM litteratur');
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
} else {
$result->MoveNext();
while (!$result->EOF) {
//print $result->fields['artnr']." ".$result->fields['benamning']."<BR>";
echo '
<table width="640" border="0" cellpadding="2">
<tbody>
<tr>
<td colspan="4" bgcolor="#111111"><span style="color: #FF9900; font-weight: bold; font-family: Arial, Helvetica, sans-serif;">'.$result->fields['benamning'].'</span></td>
</tr>
<tr>
<td width="97"><span style="font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; "><span style="font-size: 14px">art nr '. $result->fields['artnr'].'</span></span></td>
<td width="419"><span style="font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; "><em>'.$result->fields['forfattare'].'</em></span></td>
<td width="52"><span style="font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; ">'.$result->fields['vikt'].'</span></td>
<td width="46"><span style="font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; ">'.$result->fields['pris'].'</span></td>
</tr>
<tr>
<td height="151"><img src="'.$result->fields['bildaddr'].'" alt="" name="" width="96" height="130" /></td>
<td><p style="font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; ">'.$result->fields['beskrivning'];
if(!($result->fields['beskrivning'])) echo $result->fields['beskrivning2'];
echo '</p>
<p style="font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; "> </p></td>
<td colspan="2"><span class="style2">'.$result->fields['prismedmoms'].'</span> <span style="font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; ">kr inkl moms</span></td>
</tr>
</tbody>
</table>';
$result->MoveNext(); // Moves to the next row
} // end while
} // end else
// Re-connect to the CMSMS database
$conn->PConnect(
$gCms->config['db_hostname'],
$gCms->config['db_username'],
$gCms->config['db_password'],
$gCms->config['db_name']
);