i have a question:
i have a mysql table that has values such as pages_viewed
that increments every time a user accesses a page such as 1,2,3 etc.
My question is simple how do i display an image when the field equals or is more than 1?
like
select pages_viewed from table;
if field pages_viewed > 1 than echo images/image.png
开发者_开发知识库pardon my php i'm not too good at it.
i've been reading here and in other forums but all i can find is drupal or wordpress.
something like
header('Content-Type: image/png')
echo file_get_contents(images/image.png)
Here is everything basically short of database connection, table name, field name.
mysql_connect("localhost", "mysql_user", "mysql_password") or die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("select * from table");
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
# Any other code to post the page information
if($row['pages_viewed'] > 0) echo "<img src='images/image.png' />";
# Any other code to post the page information
}
精彩评论