I have a table called “profile” in mysql database
Table structure:
user | hasimg | imgurl
As you can see “hasimg” and “imgurl”, normally if a user does not have an image, hasimg will be set to 0 and imgurl is set to none.
On the other hand, if a user has an image assigned then hasimg is set to 1 and imgurl will contain the link.
-
How can I display ones that have images (
hasimgset to 1) with<img src="imgurlhtml tags? -
How can I display ones that do not have images (
hasimgset to 0) , without<img src?
I want to make a list which display users with images and user that does not have image.
Here’s the code im using to echo out the data row by row
<?php
$sql = "SELECT * FROM profile ORDER BY user DSC";
$query = mysql_query($sql)or die(mysql_error());
$rows = array();
while($row = mysql_fetch_array( $query )){
$rows[] = $row;
echo "User:$row[user]<br>Image:$row[hasimg]\n";
}
?>
P/S mysql connection established.
If you want to keep your layout fancy way you can use default image.
EDIT:
Your PHP code could be like this.