Jump to content

[SOLVED] edit row without creating new id


madcrazy1

Recommended Posts

I have a script that produces a text field with contents of say row8 based on a user columnid when i edit the row contents and click submit, it produces another columnid

 

example: what user sees after clicking submit in quotes

userid300 row8 column id28: "This is the text content of column28 in row8"

userid300 row8 column id29: "This is the edited text content of column28 in row8"

 

see the column id29? i dont want it, i want the edited info to appear in column id28

to replace it in other words

 

((I just want row8id28 edited without creating a new rowid))

 

this is what i am working with:

<u>This is the code that produces a user friendly text box to edit the row</u>

 

$RunThisQuery = "SELECT id, title, comments FROM frm_blog_posts WHERE userid=".$_SESSION['logid']." order by id limit 100";
$results = $connector->query($RunThisQuery);
while ($row = $connector->fetchArray($results)){
$Blog1= $row['title'];
$Blog1a= $row['comments']; 
$Blog4= $row['id'];
<form method="post" action="getindex.php" >
  <input type="hidden" name="do" value="posts2">	 

<td><strong>Title</strong><br><input name="p1a" type="text" id="p1a" value="<? if(isset($Blog1)){print $Blog1;} ?>" style="width:85%"></td></tr><tr>
<td><strong>Entry</strong><br><input name="p2a" type="text" id="p2a" value="<? if(isset($Blog1)){print $Blog1a;} ?>" style="width:100%"><br></strong><input type="submit" name="Submit" value="Submit" class="button"></form></td>
    </tr>
    <? } ?>

 

<u>This is the function that works on the user submitted data</u>

 

$query_add="INSERT INTO `frm_blog_posts` ( `userid` , `title` , `comments` , `date` , `time` ) 
VALUES ('".$_SESSION['logid']."', '$p1a', '$p2a', '$today_date', '$today_time')";
$result=mysql_query($query_add);
$_REQUEST['page'] = "posts2";
$ErrorMessage = "posts updated successfully";		 

 

 

I tried using:

REPLACE INTO

and

UPDATE `frm_blog_posts` SET

 

But could not get these to work for me.

Please help. Thanks

Link to comment
Share on other sites

i tried that,  but it updated all the columns with the same title.

i need it to just update one column for the user not all the users columns in that same row

 

i already tried this:

###############################################################################################################################################

$query_add="UPDATE `frm_blog_posts` SET title='".$_POST['p1a']."' WHERE `userid` =".$_SESSION['logid'];

#####################################################################################################################################

i tried substituting session id with column id also with no luck

Link to comment
Share on other sites

$query_add="UPDATE `frm_blog_posts` SET fOrder='".$_POST['p3a']."' WHERE `id`=". $row['id']." and userid =".$_SESSION['logid'];

 

THIS IS WHAT I DID BEFORE I SAW YOUR LAST POST.

can you rewrite this with primary key in the where clause.

i am not sure how to do it. i just put $row['id'] in it.

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.