user1466971
user1466971

Reputation: 111

How to display data according to the user information

I have two sql tables for user login, store and retrieve data according to the user ID.

$result = mysql_query("SELECT *FROM users u JOIN requests r ON (r.uid = u.id) WHERE r.request_id = ?");

Upvotes: 1

Views: 345

Answers (2)

timod
timod

Reputation: 595

if you don't wanna use PDO or prepare statement, please prepare & filter the SQL statements and the variables. Never trust any userinput!

see http://php.net/manual/en/security.database.sql-injection.php

Upvotes: 0

jcho360
jcho360

Reputation: 3759

NO NO NO, DON't DO THAT!!! You'll be hacked so easy!

use PDO or prepare statement

SELECT r.*,u.* FROM users u JOIN requests r ON (r.uid = u.id) WHERE r.request_id = ?

(you miss the space between the * and FROM)

It looks that you are not using OOP, I highly recommend you to take a fast tutorial to learn the basic about OOP, or if you have time and want to learn I will tell you to use some king of framework as Codeigni.ter or CakePHP to learn a lot about class and functions

Upvotes: 1

Related Questions