Saving single value from database using php

How to get only one value from a database using PHP?
I searched almost everywhere, but didn't seem to find a solution for these, for example, for what I'm trying to do is

"SELECT name FROM TABLE
WHERE UNIQUE_ID=Some unique ID"
+5
source share
3 answers

You can get one value from the table using this query:

"SELECT name FROM TABLE WHERE UNIQUE_ID=Some unique ID limit 1"

Note the use of limit 1 in the request. Hope this helps!

0
source

what about the following php code:

$strSQL = "SELECT name FROM TABLE WHERE UNIQUE_ID=Some unique ID";
$result = mysql_query($strSQL) or die('SQL Error :: '.mysql_error());
$row = mysql_fetch_assoc($result);
echo $row['name'];

Hope this will give the desired name.

:
1.) SQL-.
2.) db
3.)
4.)

+3

:

<?php
$db = mysql_connect("mysql.mysite.com", "username", "password");
mysql_select_db("database", $db);
$result = mysql_query("SELECT name FROM TABLE WHERE UNIQUE_ID=Some unique ID");
$data = mysql_fetch_row($result);

echo $data["name"];
?>
+3
source

All Articles