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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.