php - Echo two different user's column -
i want echo information account's line, shown on page.
exemple: if user aaron logins, , goes page "yasmine" want echo yasmine's picture.
this code now
php:
mysql_select_db("vestiged_sala"); $user = $_session['username']; $ppoza = ''; // add these lines in place of $result query $result = mysql_query("select * users username='$user' limit 1"); while($row = mysql_fetch_array($result)){ $ppoza = $row['ppoza']; } if (!$result) { echo "could not run query ($sql) db: " . mysql_error(); exit; }
and html
<div class="ppoza"><?php echo $ppoza; ?></div>
the problem echo aaron's profile picture instead of yasmine's
you need run select
current user's data.
select * users username= ?
or
select * users userid= ?
you should update driver pdo
or mysqli
can use parameterized queries i've shown here. prevent sql injections , quote data correctly.
you can read more here:
- http://php.net/manual/en/mysqlinfo.api.choosing.php
- http://php.net/manual/en/mysqli.quickstart.prepared-statements.php (or...)
- http://php.net/manual/en/pdo.prepared-statements.php (...dont use pdo ,
mysqli
, (normysql_
separate)
Comments
Post a Comment