Here is my MySQL Table:
DB name: dbname
Table name: tbname
column1 | column2
Info 1 | Other 1
Info 2 | Other 2
What I'm trying to get is: In PHP I have the value Info 1
as $info
, I want to search in the DB to get Other 1
on the same row, and add it to variable $other
.
How do I do that? Thanks in advance.
First you need to create connection like
$con = mysqli_connect($hostname,$user,$password,$database);
Then do
$selectquery="SELECT column2 FROM tbname WHERE column1 = '$info'";
$query = mysqli_query($con,$selectquery) or die(mysqli_error());
$result=mysqli_fetch_array($query);