FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Need Help....





k_s_baskar
Hi,
I am new to PHP. I am having a MySQL Database table with the following fields

Name,Title,Description

and this Table is having more than 50 rows. Now I need a PHP template which must create url's for each row where the Field "NAME" is having the html filename, TITLE, and DESCRIPTION field is having the content which should appear inside the body tag.

No i need a Template script which should generate 50 html files (equal to no of rows in my table) and each file should have the relvant Title and Decription.

I think i expressed my need. Thanks in Advance.

(Sorry for my English)
Smile
DanielXP
I don't understand what you mean by template script?

But instead of having a script that makes more than 50 html pages is not so great.

I would use php, you could have like.

page.php?name=name

and then you could use a mod rewite to make it look like a html page.
rvec
you know you need .php files instead of .html files if you want php in them?

And maybe it would be easier to just make one php file. Something like
index.php?p=name

Then in the php file use $_GET[p] and search for it in the database. you could make it something like this:

Code:
<?php
$page = $_GET[p];
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
   
   
if ($page != "") {
   $result = mysql_query("SELECT * FROM table WHERE name='{$page}' ");
   $row = mysql_fetch_array( $result )
   ?>
   
   <html>
      <head><title><?php echo $row[name]; ?></title></head>
      <body>
         <h1><?php echo $row[title]; ?></h1>
         <?php echo $row[description]; ?>
      </body>
   </html>
<?php
} else {
   $result = mysql_query("SELECT * FROM table");
   while ($row = mysql_fetch_array( $result )) {
      echo "<a href=\"?p={$row[name]}\">{$row[name]}</a><br />";
   }
}
?>


This way you only need one file instead of 51 (50 and one index). You should replace the username, password and database. And probably the table name which is table now. Also you could change the rest of the script a bit if you want to add more text or a different lay-out.
k_s_baskar
Thanks a lot for your immd. reply.

I need to create all my records into html bcoz all the files should be search engine friendly. Is search engine will give same priority in the above mentioned methods. plz reply.
thankyou
Smile
DanielXP
PHP will be search enging friendly

But you could use this mod rewrite.

Code:
RewriteEngine on
Options +FollowSymLinks

RewriteRule ^page-(.*).html$ index.php?p=$1 [L]


That will change rvec's code to like

page-name.html instead of index.php?p=name
rvec
and to make it complete change the last echo line to this:
Code:
echo "<a href=\"page-{$row[name]}.html\">{$row[name]}</a><br />";

That'll make it really look like you don't use php Razz.
Related topics
can i help?
help,Bonding
HELP!!
Help me with MySQL Account Maintenance and phpBB 2.0.15 :((
help, change pass my acc in cpanel
help me upgrade php to 5.
Need help adding a domain
help add admin in phpbb forum
How to solve this problem? Thanks
Help!
Help me change port for phptriad
problam Plz help
Help!!
Google Ads help fund Spyware ?
simple php problem, please help...
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.