Page 1 of 1

edit posts in a php blog

Posted: Tue Jul 31, 2007 2:16 pm
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>

Posted: Tue Jul 31, 2007 6:49 pm
by feyd
What has testing your proposed solution shown?

Posted: Tue Jul 31, 2007 7:05 pm
by suthie
lol

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

sorry :oops: