This is my first post here, so I'm hoping I posted in the right section. Thanks!
Here is the first block that lists the posted blogs:
Code: Select all
<?php require ('sql_connect.php4');
sql_connect('nut_blog');
$query = "select * from blog ORDER BY id DESC";
?>
<html>
<head>
</head>
<style type="text/css">
BODY { background: url(http://www.pickellnutrition.com/pics/mainback.jpg); background-repeat: no-repeat; overflow:hidden}
.style1 {font-family: Georgia, "Times New Roman", Times, serif}
</style>
<?php
If ($results = mysql_query ($query)) {
?>
<table align="center" border="1" width="80%">
<tr>
<td colspan="2">
<b><center>
Blog Edit Page
</center></b>
</td>
</tr>
<?php
While ($row = mysql_fetch_array($results)) {
$title = $row['title'];
$author = $row['author'];
$id = $row['id'];
$date = $row['date'];
$entry = $row['entry'];
?>
<tr>
<td colspan="2">
<table align="center" border="0" width="100%">
<tr>
<td>
<b><?php echo $title ?></b> - Posted by: <b><?php echo $author; ?></b>
</td>
<td>
<div align="right"><?php echo $date; ?></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"><?php echo $entry; ?></td>
</tr>
<tr>
<td>
<table align="center" width="200" border="0">
<tr>
<td>
<form action="SimpleEdit.php" method="POST">
<input type="hidden" name="id" value="<?= $id ?>">
<input type="submit" name="submit" value="Edit">
</form>
</td>
<td>
<form action="delete.php" method="POST">
<input type="hidden" name="id" value="<?= $id ?>">
<input type="submit" name="submit" value="Delete">
</form>
</td>
</tr>
</table>
</td>
</tr>
<?php
}
?>
</table>
<div align="center">
<p>
<?php
} else {
die ("<p>Could not run query because: <b>" . mysql_error() . "</b></p>\n");
}
mysql_close();
?>
</div>
</html>
Code: Select all
<?php require ('sql_connect.php4');
sql_connect('nut_blog');
$id = $_POST['id']
$query = "select * FROM blog WHERE id='$id'";
if ($results = mysql_query($query)) {
$row = mysql_fetch_array ($results){;
$title = $row['title'];
$author = $row['author'];
$id = $row['id'];
$date = $row['date'];
$entry = $row['entry'];
?>
<html>
<head>
</head>
<style type="text/css">
BODY { background: url(http://www.pickellnutrition.com/pics/mainback.jpg); background-repeat: no-repeat; overflow:hidden}
.style1 {font-family: Georgia, "Times New Roman", Times, serif}
</style>
<center>
<form action="SimpleEditSave.php" method="POST">
<table>
<tr>
<td>
Entry Title:
</td>
<td>
<input type="text" name="title" size="40" maxsize="100" value="<?= echo $title ?>" />
</td>
<td>
User:
</td>
<td>
<input type="text" name="title" size="20" maxsize="50" value="<?= echo $user ?>" />
</td>
</tr>
<?php
}
?>
<tr>
<td colspan=2>
<p> </p>
<p>Entry Text:
</p></td>
</tr>
<tr>
<td>
<textarea name="entry" cols="100" rows="15"><?= echo $entry ?></textarea>
</td>
</tr>
<tr>
<td>
<form action="SimpleEditSave.php" method="post">
<input type="hidden" name="id" value="<?php echo $id ; ?>" />
<input type="submit" name="submit" value="Edit" />
</form>
</td>
<td>
<form action="SimpleEditList.php" method="post">
<input type="submit" name="submit" value="Cancel" />
</form>
</td>
</tr>
</center>
</html>
Code: Select all
<?php require ('sql_connect.php4');
sql_connect('nut_blog');
$query = "select * from blog ORDER BY id DESC";
?>
<html>
<head>
</head>
<style type="text/css">
BODY { background: url(http://www.pickellnutrition.com/pics/mainback.jpg); background-repeat: no-repeat; overflow:hidden}
.style1 {font-family: Georgia, "Times New Roman", Times, serif}
</style>
<?php
$title = $_POST['title'];
$entry = $_POST['entry'];
$author = $_POST['author'];
$id = $_POST['id'];
trim ($title);
trim ($entry);
trim ($author);
$title = addslashes ($title);
$entry = addslashes ($entry);
$author = addslashes ($author);
$query = "UPDATE blog SET title='$title', entry='$entry', author='$author' WHERE id='$id'";
$results = mysql_query ($query);
?>
<table>
<?php
if (mysql_affected_rows() == 1) {
?>
<table>
<tr>
<td>
Update Saved Successful
</td>
</tr>
<?php
} else {
?>
<tr>
<td>
Update Failed
</td>
</tr>
<?php
}
?>
<tr>
<td>
<form action="simpleadmin.php" method="post">
<input type="submit" name="submit" value="Ok" />
</form>
</td>
</tr>
</table>
<?php
mysql_close(); //Closes our SQL session
?>