Hi am trying to query the database and return the value to the client. So this is my code with two functions. The the rate is supposed to get the rate in the db.
public function connect($description){
//creating connection
$con = new mysqli('localhost','root','','ci_vetro');
//mysql_connect('localhost','root','') or die("Connection Error: ".mysql_error());
//mysql_select_db('ci_vetro');
//check connection
if($con->connect_error):
die('Connection Error: '. $con->connect_error);
endif;
$sql= "SELECT * from. exchange_rates where description=.'$description'.";
$result= $con->query($sql);
if($result->num_rows > 0):
while($row = $result->fetch_assoc()) :
$rate=$row["rate"]. "<br>";
endwhile;
else:
echo "0";
endif;
$con->close();
return $rate;
}
public function getCurrency($currency) {
$rate=connect($currency);
switch ($currency){
case 'USD':
return int($rate);
break;
default:
return 0;
break;
}
}