Jump to content

If...else and a database...


forumnz

Recommended Posts

in this example we use the link direct to the folder path but you can also use

the table colum for that ok.

 

image_number is a int or a enum set 0 or 1 ok.

<?php

$database=mysql_connect("localhost","username" , "password");

mysql_select_db("database name",$database);

$query="select * from images";

$result=mysql_query($query);

while($img=mysql_fetch_assoc($result)){

$image_num=$img['image_number'];

if($image_num==1){

echo"<img src='www.what_ever.com/image0.jpg'></img>";

}elseif($image_num==0){

echo"<img src'www.whatever.com/image1.jpg'></img>";

}else {

echo" sorry there is no images to show";

}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/38874-ifelse-and-a-database/#findComment-186936
Share on other sites

set the column to 0 or 1 you should get iver a pic from google ok

<?php
//just fill this in ok.
$database=mysql_connect("localhost","username" , "password");

mysql_select_db("test",$database);

$query="select * from memebrs";

$result=mysql_query($query);

while($img=mysql_fetch_assoc($result)){

$image_num=$img['stg1'];

if($image_num==1){

echo"<img src='http://www.google.co.uk/intl/en_uk/images/logo.gif'></img>";

}elseif($image_num==0){

echo"<img src='http://images.google.co.uk/intl/en_ALL/images/images_hp.gif'></img>";

}else {

echo" sorry there is no images to show";

}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/38874-ifelse-and-a-database/#findComment-186947
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.