0

I have created two database tables, One which holds all of the users information, and another which holds the name of the videos they uploaded and who uploaded it. How do I get information from both tables?

2
Contributors
4
Replies
6
Views
4 Years
Discussion Span
Last Post by garyjohnson
0

Okay so I have altered the code you gave me and I want it to join the other database with the email of the current user logged on,

session_start();
$email = $_SESSION['email_of_user'};

SELECT * FROM db_name, table_name WHERE table_name.email = $email

I want it to display a different field in the row that has the same email as the user. So I uploaded a video and named it Funny, that video name was saved into a database table that aslo saved my email. I want the code to display the video name, not the email once it is joined.

Edited by garyjohnson: forgot code

0

The SELECT * shows all columns, including the video name (if you have done it properly). It is hard to guide you without your database structure.

0

okay hopefully this helps,

    $con = mysql_connect("hostname","username","password");
    if (!$con){
      die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("radhalfs", $con);
    $name = mysql_real_escape_string($_FILES["file"]["name"]);
    $user = $_SESSION['email_of_user'];
    $videoname = mysql_real_escape_string($_POST['videoname']);
    $r = mysql_query("INSERT INTO `videos` SET `videoname` = '$videoname', 'email` = '$user', `name`= '$name'");
    if(mysql_affected_rows()){
        echo "1 record added";
    }else{
        echo "problem";
    }
}else{
    echo "Invalid file";
}

This is the code that inserts my information into the dataabase, called radhalfs, and it stores this information into a table named videos. It saves the videoname created by the user, user email and the real video file name.

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.