hi, please help me nice guys ;)

mysql column:

`userid` contains: donny
`friends_userid` contains: cherry linda jackson michael mika // each word means one different person

then...

how to:
-----------------
add more friends
delete a friend
edit a friend
------------------
in the `friends_userid` using php without breaking another "friends"??
thanx for helping this badboy ;)

Recommended Answers

All 8 Replies

bad answer :(
what do you think about daniweb "discussion forum"?
i ask here, you said I should learn php & mysql :((

better you give the links for this case if you have no answer.

looks like you have not read my case carefully.

i do not ask basic edit/insert/delete.

thanx for helping this badboy ;)

Really you are bad boy :)
So where is your effort? What have you done so far? Where did you state your knowledge level?
And who am I to know those?

I guessing you already know how to add edit and delete in php and mysql, you just want to know how you can do it all in the same page, did I get it right?

Here's my logic, there are a few ways to do this, one way is using the $_GET method.

while retrieving data from the database do something like this

//inside your loop
while($row=mysql_mysql_fetch_array($result, MYSQL_BOTH)) {
     //add the add, edit and delete links 
     echo "<a href='this_page.php?q='add''> add </a>"; //this_page.php is your main page
     echo "<a href='this_page.php?q='edit'> edit friend </a>"; 
     echo "<a href='delete_friend.php?id=".$row['friends_userid']."'> delete friend </a>";
}

create delete_friend.php and on that page start entering your code for deleting friends based on the $_GET and add the header() function to redirect you back to your main page after it has been deleted.

next you should do something like this on the main page.

//this should allow you to check if the add or edit like is clicked
if($_GET['q']=='add'){
     //echo a field or something to allow you to add
}else if($_GET['q']=='edit'){
     //echo a field or something to allow you to edit
}else{
     //show page normally
}

I guessing you already know how to add edit and delete in php and mysql, you just want to know how you can do it all in the same page, did I get it right?

You see bad boy? Many wants to help here but your vague question will receive....answer :)

;)
"bad boy" nice ;) i like it.
you realy don't understand what I mean on my CLEAR question is.
actualy i'm very2 know how to update / insert / delete mysql records but this case, i don't.

learn SQL and PHP

is not the answer, mr. good guy... > :D

Is the subject of this topic not clear for you?
------------------------------------------------------------
please stop here, it's not important for you and for me
------------------------------------------------------------
@qazplm114477, thanx for helping.
But I mean:

this is a mysql table

tablename: friends
---------+---------+
memberid | friends |
---------+---------+
donny    | jack michel | 
         | mike lisa   |
------------------------

# 1 (one) word on friends column are 1 (one) another user
# and i want to update column "friends" only

how if "donny" get a new friend e.g. "paijo", or lisa outs from his friend list?
Rules: do not create another same row contains memberid='donny'.
Should I receive all friends column data first, distribute them as array, then deleting/adding more data?

$sql("UPDATE friends SET friends=friends".$newfriend." WHERE memberid='donny'"); // this does not work

thanx

if the query isn't working, trying running it through mysql to verify.
Echo your query...

echo "UPDATE friends SET friends=friends".$newfriend." WHERE memberid='donny'";

then, get the output and run that through MySql.

it looks like you want a one to many relationship between a member and their friends, but you want them on the same table and you don't want multiple memberid. in this case, you probably have to update the entire list.

so, Get all the friends, in somewhere editable like a textarea or several text boxes, then save the entire list.

;)
"bad boy" nice ;) i like it.
you realy don't understand what I mean on my CLEAR question is.
actualy i'm very2 know how to update / insert / delete mysql records but this case, i don't.

is not the answer, mr. good guy... > :D

Is the subject of this topic not clear for you?
------------------------------------------------------------
please stop here, it's not important for you and for me
------------------------------------------------------------
@qazplm114477, thanx for helping.
But I mean:

this is a mysql table

tablename: friends
---------+---------+
memberid | friends |
---------+---------+
donny    | jack michel | 
         | mike lisa   |
------------------------

# 1 (one) word on friends column are 1 (one) another user
# and i want to update column "friends" only

how if "donny" get a new friend e.g. "paijo", or lisa outs from his friend list?
Rules: do not create another same row contains memberid='donny'.
Should I receive all friends column data first, distribute them as array, then deleting/adding more data?

$sql("UPDATE friends SET friends=friends".$newfriend." WHERE memberid='donny'"); // this does not work

thanx

Now you are becoming clearer, Mr. Bad boy :)
You want to update the list of friend in a Column Donny without overwriting existing friend right? If so then, query all friends of donny, concatenate the list with new friend and then perform update using this new string.

And don't use chat words like i luv go 4 fishing 'n' I don wannab bad boy :zzz:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.