0

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 ;)

Edited by accountholder: n/a

3
Contributors
8
Replies
11
Views
6 Years
Discussion Span
Last Post by Stefano Mtangoo
0

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.

Edited by accountholder: n/a

0

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?

0

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
}
0

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 :)

0

;)
"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

Edited by accountholder: n/a

0

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.

0

;)
"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:

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.