This is a very newbie post. I think I'm just missing something.
Anyway.
I'm trying to display the contents of one column's field (not column name) specified by the contents of another filed in the same row.
Here I show you my table and what I need:
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 71
Server version: 5.5.8-log MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use interntv;
Database changed
mysql> SELECT * FROM members2;
+----+-------+-------+----------------+-------------------+
| id | user | pass | name | email |
+----+-------+-------+----------------+-------------------+
| 21 | ADMIN | 7aeb0 | Jakob Neumaier | Jakob@gmail.com |
| 54 | user1 | da8e0 | Adam Portman | user1@hotmail.com |
| 13 | user2 | 0f1d3 | Peter Lupica | user2@live.com |
+----+-------+-------+----------------+-------------------+
3 rows in set (0.00 sec)
mysql> SELECT name FROM members2 WHERE user = 'admin';
+----------------+
| name |
+----------------+
| Jakob Neumaier |
+----------------+
1 row in set (0.00 sec)
mysql>
I have tried:
<?php
define('DB_NAME','interntv');
define('DB_USER','root');
define('DB_PASSWORD','');
define('DB_HOST','localhost');
$mysqllink = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$mysqllink) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $mysqllink);
if (!$db_selected) {
die ('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}
echo 'Connected successfully<br /><br />';
echo mysql_query("SELECT name FROM members2 WHERE user = 'admin'");
?>
The only output I get is:
Connected successfully
Resource id #4
Can someone help me?