Jump to content

Using mysql results as php variables


englishcodemonkey

Recommended Posts

So i am lost after reading a lot about variables i want to know whether there is a way to assign a value to my variable from a mysql query.  my code is :

 


?php

require_once('conn.php');

$pic = $_REQUEST['image'];

$q = "SELECT image FROM hosta, images WHERE hosta_name = $pic, imgid = hosta_id";

$r = @mysqli_query ($dbc, $q);

if ($r) {

        while($row=mysql_fetch_array($result)){ 
            echo "'image'$img=$row['image']"; 
           
        }  
}

$path = "http://********.com/$img";

$imagepath=$path;

$image=imagecreatefromjpeg($imagepath);

header('Content-Type: image/jpeg');

imagejpeg($image);

?>

 

The variable $pic is coming from a form, but the variable $img i am hoping will be filled from my query to the database? I have only ever used queries to fill dropdown boxes or tables, so I am totally lost on how to make this a dynamic variable so to say.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/125349-using-mysql-results-as-php-variables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.