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

thanks can you show me the code format for adding a width and height tag for every pictiure? i want each picture to be the same size.. say 100 x 100 pixels?

 

again ive tried messing with the code but the pics are appearing big!

 

thanks for  your help

Link to comment
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>";
} 

?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

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.