SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Hybrid View
-
Oct 24, 2000, 05:00 #1
- Join Date
- Oct 2000
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I have put a business and shop listing (single table) together for a town which displays a simple text record for each entry. However some shops would like their own custom page which will be displayed in place of the plain text record. I have added a new field to the table called ownpage which has the path and filename of the custom page. What I want to happen is if there is a path and filename in the ownpage field then go there otherwise display the normal default text record.
The site is http://www.e-navan.com
Thank you for any direction or if you would like to see the code in question please let me know.
Aubrey Martin
-
Oct 24, 2000, 05:11 #2
- Join Date
- Jul 2000
- Posts
- 14
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Dear aubreymartin...
I don't really understand your question, but, if this is what you want...
This code is used to display companyname.custompage.txt if it exist, if not, use plain text record.
<?php
if (file_exists($cname . ".custompage.txt")){
require ($cname . ".custompage.txt");
}
elseif (file_exist($cname . ".defaultpage.txt")){
require ($cname . ".defaultpage.txt");
}
else{
require ("companydoesnotexist.html");
}
?>
Run this script by
filename.php?cname=companyname
You may make changes to the filenames if nessessary.Hope that helps
- Jeramii-chan (Jeremy)
_____________________________
a@hk : http://www.animehk.com/
-
Oct 24, 2000, 05:45 #3
- Join Date
- Oct 2000
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for a very very prompt reply and I'm really sorry to have to give you this much code to look at. Its not the most slick code ever written but ir runs well.
I put double lines in the area where I want the custom page to happen (about 12 lines from the top.
Again Many Thanks
<html>
<head>
</head>
<body text="#FF9900" bgcolor="#000000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<?php
mysql_connect("server.com",jonness,121212);
mysql_select_db(BLACK);
$table="navan";
IF ($id) {
===============================================
In here I think something like:
IF $ownpage!=" " {
GOTO OWNPAGE AND DISPLAY }(don't know the command for here)
ENDIF
===============================================
//Print page title
//printf("<p align=\"center\"><B><font size=+4>E-NAVAN RECORD DETAIL</font></font></B><br><br>");
$result=mysql_query("SELECT * FROM $table WHERE id=$id");
$myrow=mysql_fetch_array($result);
//converting the fields to variables
$Names=($myrow["Names"]);
$contact=($myrow["contact"]);
$add1=($myrow["add1"]);
$add2=($myrow["add2"]);
$add3=($myrow["add3"]);
$tel=($myrow["tel"]);
$fax=($myrow["fax"]);
$mobile=($myrow["mobile"]);
$email=($myrow["email"]);
$web=($myrow["web"]);
$ownpage=($myrow["ownpage"]};
IF ($email == "")
{
$email = "None Listed";
}
else
{
$email = "<a href=\"mailto:$email\">$email</a>\n";
}
if ($web == "")
{
$web = "None Listed";
}
else
{
$web = "<a href=\"http://$web\">$web</a>";
}
print "<p align=\"center\">_____________________________________</b></p>";
printf("<p align=\"center\"><font face=\"Arial,Helvetica\"><b><font size=+2>%s</font></font></font>\n<br></p>",$myrow["Names"]);
print "<p align=\"center\">____________________________________________________</b></p>";
echo "<center><table width=\"400\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
//echo "<tr><th ALIGN=CENTER COLSPAN=\"2\"><font size=+2>- $Names -</font></th></tr>\n";
//echo "<tr colspan=\"2\"><td width=\"400\"><p align=\"center\"><b><font size=+1>$Names</font></p><br></td></tr>\n";
//echo "<tr><td width=\"115\">Name/td><td width=\"250\">$Names</td></tr>\n";
echo "<tr><td width=\"115\">Contact/td><td width=\"250\">$contact</td></tr>\n";
echo "<tr><td width=\"115\">Address/td><td width=\"250\">$add1</td></tr>\n";
echo "<tr><td width=\"115\"> </td><td width=\"250\">$add2</td></tr>\n";
echo "<tr><td width=\"115\">Phone/td><td width=\"250\">$tel</td></tr>\n";
echo "<tr><td width=\"115\">Fax/td><td width=\"250\">$fax</td></tr>\n";
echo "<tr><td width=\"115\">Mobile/td><td width=\"250\">$mobile</td></tr>\n";
echo "<tr><td width=\"115\">Email: </td><td width=\"250\">$email</td></tr><br>\n";
echo "<tr><td width=\"115\">Website: </td><td width=\"250\">$web</td></tr></table></center>\n";
} else {
printf("<p align=\"center\"><B><font size=+2>E-NAVAN LISTING FOR $title</font></font></B><br>");
$result=mysql_query("SELECT * FROM enavan WHERE cats LIKE '%$cat%' ORDER BY Names");
IF ($myrow=mysql_fetch_array($result)) {
do {
printf("<p align=\"center\"><B><font size=+1><a href=\"%s?id=%s\">%s</a><br></font></B>\n",$PHP_SELF,$myrow[id],$myrow["Names"]);
} while ($myrow=mysql_fetch_array($result));
} else {
echo "Sorry, No Matching Records Here";
}
}
?>
</body>
</html>
Run this script by
filename.php?cname=companyname
You may make changes to the filenames if nessessary. [/B][/QUOTE]Aubrey Martin
-
Oct 24, 2000, 05:52 #4
- Join Date
- Jul 2000
- Posts
- 14
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Dear aubreymartin...
You can save the custom pages into plain text files, and use require statements to get the file
require ("asdf.txt");
require ("path/to/asdf.txt");
require ("/home/abolute/path/to/asdf.txt");
Hope that helps
- Jeramii-chan (Jeremy)
_____________________________
a@hk : http://www.animehk.com/
-
Oct 24, 2000, 06:08 #5
- Join Date
- Oct 2000
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank you once again and sorry to keep coming back to you,
Will the REQUIRE Function work for html files too as these are the format of the custom pages?
path e.g. ownpages\lorenzen.html
Originally posted by akazukin
Dear aubreymartin...
You can save the custom pages into plain text files, and use require statements to get the file
require ("asdf.txt");
require ("path/to/asdf.txt");
require ("/home/abolute/path/to/asdf.txt");
Aubrey Martin
-
Oct 24, 2000, 06:12 #6
- Join Date
- Jul 2000
- Posts
- 14
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Dear aubreymartin...
You're always welcome to ask me questions. I'm often here ^^.
Yes, it works for all ASCII text files (including HTML and PHP executable scripts)
Hope that helps
- Jeramii-chan (Jeremy)
_____________________________
a@hk : http://www.animehk.com/
Bookmarks