Jump to content

adding a picture with a variable


ben1981

Recommended Posts

see my code below well the $picture variable contains just for example birthday1.jpg which exists and works if i use the birthday1.jpg string instead of the variable

can i make this work so it displays a different picture for each result / row of the query?

 

$cxn = mysqli_connect($host,$user,$password,$dbname);

$sql = "SELECT * FROM products WHERE category='birthday'";

$result = mysqli_query($cxn,$sql);

while ($row = mysqli_fetch_row($result))
{
$picture='$row[2]';
echo "<div class='text'><img src='$picture'>" .$row[3]." ".$row[4]." ".$row[5]. "</div>";
} 
echo "</div>";

?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/44756-adding-a-picture-with-a-variable/
Share on other sites

ive got the following working... how can i add the width and height to it? tried messin but page keeps comin up blank - im not getting on too well with this coding business!!

 

$cxn = mysqli_connect($host,$user,$password,$dbname);

$sql = "SELECT * FROM products WHERE category='baby'";

$result = mysqli_query($cxn,$sql);

while ($row = mysqli_fetch_row($result))
{
echo "<p><img src='images/" .$row[3]. "'>" .$row[3]." ".$row[2]." ".$row[4]." ".$row[5]. "</p>";
} 

?>

Ahh i have another question sorry guys.... this one has been causing me problems in the past as well...

 

when you insert an image and set align to right or left - and there isnt much text beside it - then the next picture is put next to it instead of below it

 

is there a way of making sure the next picture will be underneath instead of alongside and slightly down from the last one?

I remember reading there was some code you could use to make sure that your logo jpg file loads before anything else?

 

because at the moment the page loads in a funny order and the logo is usually last.

 

does anyone know which command i mean? its nice to have the logo looking more permanent...

oh also help much appreciated,

 

is there a way to call another htm file from an exisiting one?

 

i ask because I have a menu of links on the side of the page, and i have to write the details of these on every other page on the web site. so if i make one change to the menu, i have to edit about 10 pages.

 

is there a way to call these details from another file so i only edit one file?

 

for example like storing some variables in a seperate file and calling using INCLUDE?

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.