<?php
$connect = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("guest") or die(mysql_error());
function bbcode($string)
{
if ($string) {
$bbcode_array = array('[b]', '[/b]', '[u]', '[/u]', '[i]', '[/i]', '[code]',
'[/code]', '[img]http://', '[/img]');
$bbcode_array_2 = array('<b>', '</b>', '<u>', '</u>', '<i>', '</i>',
'<center><div style="width:90%;padding:3px;background-color:#000099;color:#FFFFFF;border:2px solid;">',
'</div></center>', '<img src="', '">');
$new_string_2 = str_ireplace($bbcode_array, $bbcode_array_2, $string);
return $new_string_2;
}
}
echo "<h1>Guestbook</h1><hr />";
$queryget = mysql_query("SELECT * FROM guest ORDER BY id DESC") or die(mysql_error());
$querygetrownum = mysql_num_rows($queryget);
if ($querygetrownum == 0) {
echo "No posts have been made yet! Be the first!";
}
$per_page = 5;
$start = $_GET['start'];
$record_count = mysql_num_rows(mysql_query("SELECT * FROM guest"));
$max_pages = $record_count / $per_page;
if (!$start) {
$start = 0;
$get = mysql_query("SELECT * FROM guest ORDER BY id DESC LIMIT $start, $per_page");
while ($row2 = mysql_fetch_assoc($get)) {
$name2 = $row2['name'];
$email2 = $row2['email'];
$message2 = $row2['message'];
$date2 = $row2['date'];
$time2 = $row2['time'];
echo "<table><tr><td><b>Posted by: " . $name2 . "(" . $email2 . ") on " . $date2 .
" at " . $time2 . "</b></td></tr><tr><td>" . nl2br(bbcode(strip_tags($message2))) .
"</td></tr></table>";
echo "<hr />";
}
}
//setup prev and next variables
$prev = $start - $per_page;
$next = $start + $per_page;
//show prev button
if (!($start <= 0)){
echo "<a href='index.php?start=$prev'>Prev</a> ";
}else{
echo "« Prev";
}
//show page numbers
//set variable for first page
$i = 1;
for ($x = 0; $x < $record_count; $x = $x + $per_page) {
if ($start != $x){
echo " <a href='index.php?start=$x'>$i</a> ";
}else{
echo " <a href='index.php?start=$x'><b>$i</b></a> ";
}
$i++;
}
//show next button
if (!($start >= $record_count - $per_page)){
echo " <a href='index.php?start=$next'>Next</a>";
}else{
echo "Next »";
}
if ($_POST['submit']) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$date = date("Y-m-d");
$time = date("H:i:s");
if ($name && $email && $message) {
$querypost = mysql_query("INSERT INTO guest VALUES('','" . $name . "','" . $email .
"','" . $message . "','" . $date . "','" . $time . "')");
echo "Please wait... <meta http-equiv='refresh' content='2'>";
} else {
echo "Please fill out all fields!";
}
}
echo "<hr />";
echo "
<form action='index.php' method='POST'>
<table width='100%'>
<tr>
<td width='7%' valign='top'>
Your Name:
</td>
<td valign='top'>
<input type='text' name='name' maxlength='25' />
</td>
</tr>
<tr>
<td valign='top'>
Your Email:
</td>
<td>
<input type='text' name='email' maxlength='25' />
</td>
</tr>
<tr>
<td valign='top'>
Your Message:
</td>
<td>
<textarea cols='20' rows='2' name='message' maxlength='250'></textarea>
<p><input type='submit' name='submit' value='Post' />
</td>
</tr>
</table>
</form>";
?>
<style type="text/css">
body{font-family:Arial;font-size:14px;background-image: url('./images/bg.png');color:#FFFF00;}h1{font-family:Arial;}hr{color:#FFFF00; }a{color:#FFFFFF;text-decoration:none;}a:hover{color:#FFFFFF;text-decoration:underline;}
</style>
i'm having a problem with the next row of results. They wont show...
Calculating a rating by adding number of points and dividing by number of items
I have a site that users can post links to files to download. They can rate these files on a 1-5 scale. I had someone make a Top Rated section for the site, to show the user with the highest rating
Shuffle between users ??
I have multiple $users in table. I need to send them $message.I need to send the next message available in the database to the next user who got least amount of messages.Or how could I place those
Login page problems
I developed a website a few months ago and I am now having an issue with logging into it. The place that it is hosted just did some upgrades to their servers and for some reason, now my login page
CHECK A STRING FOR ' " ' (DOUBLE QUOTES)
I am checking for delimiter (.!?) and if there is a " after a sentence then it should neglect and start from next sentenceI am splitting into two sentences"This is first sentence." This
Save data in input fields when they press "BACK BUTTON"
Hi, this is html form: And let's say they get a error "Please enter ur title must be more then 3 character" then they click the BACK BUTTON AND ALL THERE DATA IS GONE!!How i fix?Code:
asp authentication problem
Hello all,
Shuffle Array
Hi,I am writing a script for a game that needs players to randomly be assigned a target (another player) in a loop so that each player is matched with someone other than who has them. See below:Andy
RadioButtonList item spacing
I have a RadioButtonList and I can't put any spacing between the items. They are arranged vertically, and each one is right on top of the next.
Need help adding a timestamp to my filename/variable
Hello, I'm kind of stupid when it comes to php and I need a tiny bit of help. I've got a form/php setup that allows a user to upload an image to my server. The upload is working well, and the code
Problem with variable declaration in switch statement
Hello, I am having some trouble assigning a value to a variable inside a switch statement. What I am trying to do here is trip an error if the user has already added an item in the shopping cart.