# Simple tag-board

**URL:** <https://forum.kirupa.com/t/simple-tag-board/203779>\
**Category:** Uncategorized\
**Created:** [October 14, 2006, 12:41am UTC](https://forum.kirupa.com/t/simple-tag-board/203779 "2006-10-14T00:41:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mak\_Valley](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Mak\_Valley](https://forum.kirupa.com/u/Mak_Valley)\
**Post date:** [October 14, 2006, 12:41am UTC](https://forum.kirupa.com/t/simple-tag-board/203779/1 "2006-10-14T00:41:21Z")

</div>

don’t know how many of these there are out there… or if there’s already one (or more) on this forum/website… but i made this for a friend and decided to distribute it, so, here’s another one…

[http://www.jahdesign.com/tag](http://www.jahdesign.com/tag) \<\< test it, see if you like it…

it’s two files…

dbconnect.php

```php
<?php
$dbuser="";
$dbpass="";
$database="";
$dbhost="localhost";
mysql_connect(localhost,$dbuser,$dbpass) or die("Could not connect!");
@mysql_select_db($database) or die ("Could not select database!");
?>

```

and index.php

```php

<!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=ISO-8859-1" />
<title>Tag Board v0.4</title>
<style type="text/css">
<!--
a:hover {
color:#000000;
border-bottom:thin;
padding-bottom:1px;
border-bottom-style:solid;
}
a {
color:#FFFFFF;
}
body {
color:#000000;
background-color:#0066AA;
color:#000000;
font-family:verdana;
font-size:11px;
}
div.tags {
padding:1px;
width:225px;
height:150px;
overflow:auto;
background-color:#0066CC;
color:#99CCFF;
}
table {
background-color:#002F8F;
color:#FFFFFF;
}
td {
background-color:#0066CC;
font-family:verdana;
font-size:11px;
padding:1px;
}
input {
background-color:#0066AA;
font-family:verdana;
color:#FFFFFF;
border:none;
}
textarea {
background-color:#0066AA;
font-family:verdana;
color:#FFFFFF;
}
p {
padding:0px;
}
//-->
</style>
<script language="javascript" type="text/javascript">
<!--
function addtagover(){
document.getElementById('addtag').style.background="#6699FF";
document.getElementById('addtag').style.color="#002F8F";
}
function addtagout(){
document.getElementById('addtag').style.background="#0066CC";
document.getElementById('addtag').style.color="#FFFFFF";
}
//-->
</script>
</head>
<body>
<?php
$action=$_GET['action'];
$tagname=$_POST['tagname'];
$tagemail=$_POST['tagemail'];
$tagmessage=$_POST['tagmessage'];

function tag_form(){
echo "<form action=\"?action=writetag\" method=\"post\">
";
echo "Name:<input type=\"text\" name=\"tagname\" value=\"\" maxlength=\"10\"><br />
";
echo "OR E-Mail:<input type=\"text\" name=\"tagemail\" value=\"http://\" maxlength=\"100\"><br />
";
echo "<input type=\"submit\" value=\"TAG>>\">
";
echo "<input type=\"text\" name=\"tagmessage\" maxlength=\"200\" value=\"Message\">
";
echo "</form><a href=\"?\">Cancel</a>";
}

include ("dbconnect.php");
?>
<?
if ($action == "tagform"){
$addtagalign="right";
$showform=true;
}else{
$addtagid="addtag";
$addtagalign="center";
$tagaction='style="cursor:pointer" onclick="document.location.href=\'?action=tagform\'"';
}
?>
<table width="225" cellspacing="1">
 <tr>
  <td>
   <div class="tags">
<?php
if ($action == "writetag"){
 if ($tagname == "Name"){
  $tagname = "Anonymous";
  }
 if ($tagmessage == "Message"){
  echo "You must type a message!";
 } else { 
 $tagmessage2=str_replace("<","&lt;","$tagmessage");
 $tagmessage3=str_replace(">","&gt;","$tagmessage2");
 
   if (substr_count($tagemail, "@")){
  $tagemail2="mailto:$tagemail";
  } else {
  $tagemail2="$tagemail";
  }
 
$inserttags=("INSERT INTO tags VALUES ('','$tagname','$tagemail2','$tagmessage3')");
 mysql_query($inserttags) or die ("Error inserting tag!");
 echo "<a href=\"?\">Tag posted!</a>";
 }
} else {
 
 / ******************** NO PAGEINATION
 $selecttags=mysql_query("SELECT * FROM tags ORDER BY id DESC");
  while ($tag = mysql_fetch_array($selecttags)){
   echo "<a href=\"".$tag['email']."\" target=\"_blank\">".$tag['name']."</a>";
   echo "&nbsp;:&nbsp;";
  echo $tag['message']."
<p></p>
";
 }
 ********************* /
 
 
// PAGEINATION

if(!isset($_GET['page'])){ 
    $page = 1; 
} else { 
    $page = $_GET['page']; 
} 
// MAX RESULTS
$max_results = 15; 
$from = (($page * $max_results) - $max_results);  

$sql = mysql_query("SELECT * FROM tags ORDER BY id DESC LIMIT $from, $max_results"); 

/ ***********DISPLAY RESULTS**************** /
while($row = mysql_fetch_array($sql)){ 
    echo "<a href=\"".$row['email']."\">".$row['name']."</a>&nbsp;:&nbsp;".$row['message']."<br />"; 
} 

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM tags"),0); 

$total_pages = ceil($total_results / $max_results); 

echo "<center>Select a Page<br />"; 

if($page > 1){ 
    $prev = ($page - 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; 
} 

for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "$i "; 
        } else { 
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; 
    } 
} 
if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; 
} 
echo "</center>"; 

} //END PAGEINATE
?>
   </div>
  </td>
 </tr>
 <tr>
  <td id="<?php echo "$addtagid"; ?>" align="<?php echo "$addtagalign"; ?>" onmouseover="addtagover();" onmouseout="addtagout();" <?php echo "$tagaction"; ?>>
<?
if ($showform == true){
tag_form();
} else {
echo "<script language=\"javascript\" type=\"text/javascript\">
";
echo "<!--
";
echo "document.write (\"Add Tag!\");
";
echo "//-->
";
echo "</script>";
echo "<noscript><a href=\"?action=tagform\">Add Tag!</a></noscript>
";
}
?>
  </td>
 </tr>
</table>

</body>
</html>

```

if you want to limit the number of results per page, leave everything as is and edit $max\_results to the maximum number of results you want per page… if you DON’T want to pageinate then uncomment where it says “NO PAGEINATION” and delete from where it says “PAGEINATION” to “END PAGEINATION”.

remarks anybody?
