Ok, here it is.
This might not be the best way to do this, but well, it's something.
I'm just packed with jobs lately, just can't do them all.
And since I do have some previous commitments (yes, even earlier than this one), I must complete them first.
Veyr sorry, Ruth.
1. Run this query:
Code:
CREATE TABLE tip (
tipid SMALLINT(5) not null AUTO_INCREMENT,
title VARCHAR(100) not null,
tiptext MEDIUMTEXT not null,
PRIMARY KEY (tipid)
)
2. Save this as tip.php, and upload to your main folder:
PHP Code:
<?php
error_reporting(7);
require("./global.php");
$action = trim($action);
if (!isset($action)==0) {
$action = "showtip";
}
// ################################ start quick rate ###############################
if ($action=="showtip") {
$tip=$DB_site->query_first("SELECT * FROM tip ORDER BY rand()");
echo("$tip[tipid]");
eval("\$showtip = \"".gettemplate("tip_showtip")."\";");
}
3. Save this as tip.php and upload to your admin folder:
PHP Code:
<?php
error_reporting(7);
require("./global.php");
cpheader();
if (isset($action)==0) {
$action="edit";
}
// ########################### Start Doadd ##########################
if ($action=="doadd") {
for ($i=1; $i<=$numtips; $i++) {
if ($tiptext[$i]!="" and $title[$i]!="") {
$DB_site->query("INSERT INTO tip (tipid,title,tiptext) VALUES (NULL,'".addslashes($title[$i])."','".addslashes($tiptext[$i])."')");
}
}
$action="modify";
echo "<p>Record added</p>";
}
// ############################ Start Add ###########################
if ($action=="add") {
doformheader("tip","doadd");
for ($i=1; $i<=$numtips; $i++) {
maketableheader("Tip #$i");
makeinputcode("Title","title[$i]");
maketextareacode("Tip Text<br>(You may use HTML)","tiptext[$i]","","10");
}
makehiddencode("numtips","$numtips");
doformfooter("Add");
}
// ########################## Start Preadd ##########################
if ($action=="preadd") {
doformheader("tip","add");
maketableheader("Add new tips");
makeinputcode("Number of tips to add","numtips","1");
doformfooter("Start");
}
// ########################## Start Modify ##########################
if ($action=="edit") {
$tips=$DB_site->query("SELECT * FROM tip");
$i=1;
while ($curtip=$DB_site->fetch_array($tips)) {
if ($title[$curtip[tipid]]=="" or $tiptext[$curtip[tipid]]=="") {
$DB_site->query("DELETE FROM tip WHERE tipid='$curtip[tipid]'");
echo "Deleting tip #$i ...<br>";
} else {
$DB_site->query("UPDATE tip SET title='".addslashes($title[$curtip[tipid]])."',tiptext='".addslashes($tiptext[$curtip[tipid]])."' WHERE tipid='$curtip[tipid]'");
echo "Saving tip #$i ...<br>";
}
$i++;
}
$action="modify";
echo "<p>Done</p>";
}
cpfooter();
?>
4. Save this as tip_main template:
Code:
{htmldoctype}
<html>
<head><title>Tip of the moment!</title>
$headinclude
</head>
<body>
$showtip
</body>
</html>