close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

archive editable areas

Thread began 1/21/2011 10:37 am by gruant2000381341 | Last modified 1/22/2011 10:08 pm by gruant2000381341 | 1635 views | 3 replies

gruant2000381341

I figured I would post my remedy here in case anyone else needs to do something similar
I built a database named archlist with 3 fileds
id - int(11) -auto incr primary
name - varchar 255
dateTime - dateTime
that is so I can save out a path for a link to the archived area

I created a folder named archive
in that folder is a normal page with all the styles and stuff for your page and the developer notes pasted in just like normal...that will act as the template that I'm building off of. I named that page nltemplate.php

When the new static pages are created, they will reside inside that archive folder.

note that you may need to edit the path in the developer notes as this is now a subfolder.

in that archive folder is a basic connect_to_mysql.php script so you can connect to the new table we made for saving the path.

And then this file is also in the archive folder...it's named index.php
I commented it out as best I could
<pre>
<?php
//connect to the database here
include ("connect_to_mysql.php");
//this is so we can rename the new html file with a system to prevent overwriting
//this will name the html dy date...month,day,year,hour,minute,second
$m = date(M);
$d = date(j);
$y = date(y);
$h = date(G);
$min = date(i);
$sec = date(s);
$newname = $m.$d.$y.$h.$min.$sec;

?>
<?php
//seeing if someone hit the submit button on our form
if ($_POST['archiveit'] == "true"){
$archname = $_POST['archname'];
$archname = strip_tags($archname);
$archname = stripslashes($archname);
$archname = mysql_real_escape_string($archname);
//building a link to the new file
$fullpath = '<a target="_blank" href="archive/' . $newname . '.html">' . $archname . '</a>';
if (!$archname){
$msg = "Enter a name";
} else {
//inserting that link into the database
$sql_insert = mysql_query("INSERT INTO archlist (name, dateTime)
VALUES('$fullpath',now() )") or die (mysql_error());
//creating the html from php
//enter your sites url in place
$page=file_get_contents('http://www.yoursite.com/archive/nltemplate.php');
$fp=fopen($newname.'.html','w+');
fputs($fp,$page);
fclose($fp);
}
}
?>
<?php
//this is for deleting archives if you wish
if($_POST['delete']){
if (!empty($_POST['checkbox'])) {
foreach($_POST['checkbox'] as $v) {
$del_id = mysql_real_escape_string($v);
$sql = "DELETE FROM archlist WHERE id ='$del_id'";
mysql_query($sql);
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Archive Newsletter</title>
</head>
<body>
<div id="wrap">
<div id="form">
<!-- this form will post back to this page -->
<!-- this form is for the archiving process -->
<form action="index.php" method="post" >
<table width="100%" border="0">
<tr>
<td>&nbsp;</td>
<td>Choose a name for your archived newsletter.<br />
example: July 2010 Newsletter
<br />
<input name="archname" type="text" id="archname" size="50" /><br />
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="hidden" name="archiveit" id="archiveit" value="true"/>
<input type="submit" name="submit" value="Archive Newsletter" />
<?php echo $msg; ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</form>
<form id="form1" name="form1" method="post" action="index.php">
<!-- this form is for the deleting process -->
<table width="100%" border="0">
<tr>
<td width="11%" align="center">#</td>
<td width="89%"><strong>You can delete archived newsletters below.</strong></td>
</tr>
<?php
$sql="SELECT id,name FROM archlist";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $rows['id']; ?>"></td>
<td><?php echo $rows['name']; ?></td>
</tr>
<?php } ?>
<tr>
<td align="center">&nbsp;</td>
<td><input type="submit" name="delete" id="delete" value="delete" /></td>
</tr>
</table><br /><br />
</form>
</div>
</div>
</body>
</html>
</pre>


all thats left to do is echo out those links that we added to the db wherever you want them to display

<pre>
<?php include ("connect_to_mysql.php"); ?>
<h1>Newsletter Archive </h1>
<?php
$result3 = mysql_query("SELECT name,dateTime FROM archlist ORDER BY dateTime DESC");
$num_rows = mysql_num_rows($result3);
if($num_rows == 0) {
echo "No Newsletters Archived Yet.";
} else {
echo "<table border='0' cellspacing='0' cellpadding='0'>";
while($row3 = mysql_fetch_array( $result3 )) {
echo "<tr><td>";
echo $row3['name'];
echo "</td></tr>";
}
echo "</table>";
}
?>
</pre>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...