Jump to content

Need help inserting data


bytesize

Recommended Posts

Can someone please help me figure out how to insert "image" from table users, that contains the .jpg data associated with "screen_name", into table friends "friendimg"

 

Here are the tables:

friends: id, member, friendwith, friendimg

users: id, screen_name, image

 

$_GET["id"] only contains "screen_name" and"image" is not included

 

add.php

<?php
if(isset($_GET["id"]))
{
echo "<br/><a href=\"member?add=".$_GET["id"]."\">Add ".$_GET["id"]." to your list of friends</a>";
}
?>

member.php

<?php
if(isset($_GET["add"]))
{
$username = $_SESSION["screen_name"];
$friend = $_GET["add"];

$query = "SELECT * FROM friends WHERE member='$username' AND friendwith='$friend'";
$result = mysql_query($query);
$exist = mysql_num_rows($result); 
if($exist=='0')
{
	$query = "INSERT INTO friends(member,friendwith) VALUES('$username','$friend')";
	mysql_query($query);
	echo "<br/>You are now friends with $friend";
}
else 
{
	echo "<br/>$friend is already in your list of friends!";
}
}
?>

Link to comment
Share on other sites

I was going to say the same, also the way this is doing it, you would have to also include an insert, or else update because the original user could change their image then the other friends image would be incorrect.

 

Just call to the friends users table by their name and get the image to display, because going by id for for tables they are different, but the names should remain the same.

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.