Jump to content

auto generated pages in php


rahulvicky00

Recommended Posts

Hi Mates,

 

I want to know how to create auto generated pages in submit button with the existing templates...Wordpress users may easily understand what actually i mean...i am using the code that is creating a page but not getting the desired page name and giving a blank page that is without any formatting...

 

<?php
$content = <<<EOL
<head>
</head>
<body>
New page
EOL;

include ('config.php');
mysql_select_db("$db_name");
$result = mysql_query("SELECT * FROM text ORDER BY ID")
or die(mysql_error());

while($row = mysql_fetch_array( $result )) {
echo $row['title'];
echo "<br />";
}

$content .= <<<EOL
</body>
</html>
EOL;
$file = '$result' . '.php'; 
$open = fopen($file, "w");
fwrite($open, $content);
fclose($open);
?> 

Link to comment
Share on other sites

Is $row['title'] what you want?

 

The result resource is not the data fetched by the query. You have to use mysql_fetch_array (or a similar function) to access the data. It is giving you "Resource id #3.php" because it has made a successful execution and is returning data.

 

I see you are looping through the results and printing each title, so I wonder what you are using to derive the name of the file you are making?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.