Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8013939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:46:45+00:00 2026-06-04T19:46:45+00:00

Is it possible to have a image that will change if an sql record

  • 0

Is it possible to have a image that will change if an sql record is created since the last visit of that registerd user and another image if criteria not met.

The record table is matningar with a date field datum.
Maybe the below code something close to achieving this?!

    <?php

    $stmt = "SELECT * FROM matningar WHERE `datum` > date("F j, Y, g:i a", $database-    >getLastUserRegisteredDate()";
    $result=mysql_query($stmt);
    foreach($result as $rec){
    echo "<img src=\"images/somepicture.png\" />";
    } 
    ?>

Would really appreciate some input on how to proceed!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:46:47+00:00Added an answer on June 4, 2026 at 7:46 pm

    You could count the records returned and use conditional statements to determine what image you want to display. For example using your code:

    /* Using a mysql query which is discouraged and will be depreceated in future */
    
          // declare variables
          $i = 0;
          $lastRegisteredDate = date("F j, Y, g:i a", $database->getLastUserRegisteredDate());
    
          // declare statement string
          $stmt = "SELECT * FROM matningar WHERE `datum` > $lastRegisteredDate";
    
          // execute query
          $result=mysql_query($stmt);
    
          // make sure query executed properly
          if (!$result) {
            die('Invalid query: ' . mysql_error());
          }
    
          // manually count the number of results
          while ($row = mysql_fetch_assoc($result)) {
            $i++;
          }
    
          // display image based on conditions
          if($i == 0) {
            // display one image
          }
          else {
            // display another image
          }
    

    Just as a side note mysql functions are going to be depreceated in upcoming PHP releases so I would start looking at using the PDO or mysqli libraries for mysql queries.

    /* Using the PDO library */
    
      // declare variables
      $i = 0;
      $lastRegisteredDate = date("F j, Y, g:i a", $database->getLastUserRegisteredDate());
    
      // declare database handler
      $DBH = new PDO( "mysql:host=$host;dbname=$dbname", $user, $pass );
    
      // prepare query
      $STH = $DBH->prepare( "SELECT * FROM matningar WHERE `datum` > ?" );
    
      // execute query
      $STH->execute( array( $lastRegisteredDate ) );
    
      // set fetch mode  
      $STH->setFetchMode( PDO::FETCH_OBJ );
    
      // manually count the number of results
      while ( $row = $STH->fetch() ) {
        $i++;
      }
    
      // display image based on conditions
      if($i == 0) {
        // display one image
      }
      else {
        // display another image
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have one image and i want that when i will home mouse on
I have a question about IPTC metadata. Is it possible to search images that
Is it possible to have transparent background image using CSS3? background: url(../img/bg_paperlines.jpg) repeat-x; Using
So I have an interesting image setup and I was wondering if it's possible
Is it possible to create a cursor from an image and have it be
Is it possible to have a relationship from a user table to a system
Is it possible to have multiple classes that inherit/extends same class in Google AppEngine
I have been asked to write a GUI that will allow objects to be
I have navigation menu using images, I want that if the user click a
i have simple form that uploads image to server and returns php string containing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.