edit posts in a php blog

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
suthie
Forum Commoner
Posts: 68
Joined: Sat Jun 09, 2007 10:46 am

edit posts in a php blog

Post by suthie »

I have a php blog made. You can post and you can read your posts. I want to make it so when you are reading the posts there is an edit button that takes you to a page that lets you edit the post. This is the code I have so far that just lets you read posts:

Code: Select all

<?php 
include 'session.php';
include 'dbconnect_silent.php';
$username = $user; 
?><center>
<table width=350 cellpadding=3 style="border-collapse: collapse; border: solid; border-width: 1; border-color: black;">
<tr><td background="images/pbody.png">
<div align="top"><b><u>DIG: reflect</u></b></td></tr><tr>
<td background="images/pbody_notop.png">
<?php 
$sql = "SELECT * from dailyvibe WHERE userlink='$username' ORDER BY postid DESC";
$result = mysql_query($sql) or print ("Can't select entry from table php_blog.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)){     
$date = stripslashes($row['timestamp']);    
$title = stripslashes($row['title']);    
$entry = stripslashes($row['entry']);
$postid = stripslashes($row['postid']);       
?>
<b>
<?php
echo $date;
?> - <?php 
echo $title; 
?>
</b><br>
<textarea rows=7 cols=40>
<?php 
echo $entry; 
?>
</textarea>
<br><div align="right"><font size=1>


//this is where I want to have an edit button


</font></div><br>
<?php
} 
?>
<?php
if (!mysql_num_rows($result)){
?>
You have not made any DIG posts yet.
<?php
}
?>
I need to have each post have a button that transmits post data so the next page knows which post you are trying to edit. how can i do this?
would something like this work maybe?

Code: Select all

<a href="digedit.php?postnum=<?php
echo $postid;
?>
">edit</a>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What has testing your proposed solution shown?
suthie
Forum Commoner
Posts: 68
Joined: Sat Jun 09, 2007 10:46 am

Post by suthie »

lol

my proposed solution actually works. i did not expect that.

sorry :oops:
Post Reply