Currently I show some MySQL data by applying a User Defined Tag.
This tag is basically formatted like this:
Code: Select all
//User Defined Tag: Factbookdata
mysql_close($connectiondata);
$carrierchoice = urldecode($_GET['carrierchoice']);
// This makes a connection to the file containing the logon data//
require ('connection.php');
$connectiondata = mysql_connect($host,$user,$password, true)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connectiondata)
or die ("Couldn't select database");
// Combine carriers and country names and select desired carrier//
$query =
"SELECT * FROM tbl_carrier, tbl_country
WHERE carr_country_iso3=coun_iso3
and carr_name ='".$carrierchoice."';";
$result = mysql_query($query)
or die (mysql_error());
// Display results //
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "
<table>
.....
.....
.....
</table>
";
}
mysql_close($connectiondata);
The problem is that up till now I didn't manage to lay-out the table shown (discussed in my post http://forum.cmsmadesimple.org/index.php/topic,14935.msg73986.html#msg73986). Somehow the tag editor doesn't allow me to enter anything that is related to style sheets or even HTML lay-out things like BGCOLOR.
Now I thought it would be a good idea to move the content of the User Defined Tag to the page itself.
This seems to have solved the problem of styling the table. However...
A new problem is introduced:
After opening the page, the content area that is supposed to show the table, initially shows
//User Defined Tag: Factbookdata mysql_close($connectiondata); $carrierchoice = urldecode($_GET['carrierchoice']); // This makes a connection to the file containing the logon data// require ('connection.php'); $connectiondata = mysql_connect($host,$user,$password, true) or die ("couldn't connect to server"); $db = mysql_select_db($database,$connectiondata) or die ("Couldn't select database"); // Combine carriers and country names and select desired carrier// $query = "SELECT * FROM tbl_carrier, tbl_country WHERE carr_country_iso3=coun_iso3 and carr_name ='".$carrierchoice."';"; $result = mysql_query($query) or die (mysql_error()); // Display results // while ($row = mysql_fetch_array($result)) mysql_close($connectiondata);
In other words it shows the code in stead of the result.
After entering $carrierchoice = urldecode($_GET['carrierchoice']); by clicking on one of the options in the left column of the page (in here the links look like
http://website.com/index.php?page=fact- ... e=CompanyA) the required data is shown.
My analysis is that since there is initially no carrierchoice entered the query doesn't know what data should be shown and makes an error.
How should this be solved?
- Getting back to the User Defined Tag?
- Somehow entering an initial value for carrierchoice
- Some other thing?
Arthur
