Update

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
minds_gifts
Forum Commoner
Posts: 63
Joined: Mon Feb 10, 2003 4:23 am

Update

Post by minds_gifts »

Hello everybody,

I have a form where i can insert article heading and article text into a table.To be more precisely,
I first list all the topic names into a list box and then select one, click a button so that corresponding sub-topics are shown in the another listbox.Now, i can enter the article name and the article text.Its working fine:-)

I also want the user to update this article name or text in case if he has wrongly typed them.

How best can I do???

My table structure is something like
topic(topic_id, topic_name)
subtopic(subtopic_id,topic_id,subtopic_name)
articles(article_id,topic_id,subtopic_id,article_name,article_text)

I just want to put this update section as friendly as possible.Is that possible to put in the same form?

Could somebody explain me how can i do this one??I can show you my code also, so that you can help me out where all i can insert the update stuff.

Thanks everybody
aybra
Forum Commoner
Posts: 56
Joined: Sun Nov 24, 2002 12:52 am

Post by aybra »

I'll show you how I edit in myn and then maybe it will give you a good idea for your self....

Code: Select all

<?php
	$querya = 'SELECT * FROM `toask` ORDER BY `ID` ASC';
        $result2 = mysql_query($querya, $connection) or die('error making Result2');
echo '<select size="1" name="edit">';
echo '<option value="">:::</option>';
while ($row = mysql_fetch_assoc($result2)) { 
   $one = $row["ID"];
   $zero = $row["title"];
echo '<option value="',$one,'">',
$zero,'</option>';
}
echo '</select>';

?>
This is at the bottom of the page, then you run this query at the very way top before you run any others.

Code: Select all

<?php
if ($edit != "") {
        $query5 = "UPDATE `toask` SET `timeend` = '$timeend' WHERE `ID` = '$edit'";
	$result5 = mysql_query($query5, $connection) or die('error making query5');
	}
?>
The $timeend is nothing more then a text a box that I use to enter the string, I run them both off of the same page but under different forms so that they dont pass variables.


Hope this helps just a little bit.
Post Reply