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 8945109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:10:36+00:00 2026-06-15T12:10:36+00:00

Im trying to make an sql function that displays the highest value however all

  • 0

Im trying to make an sql function that displays the highest value however all the variations of the MAX function i use, still turn up with an empty image. What’s going on here? how do i fix this?

//displays no image and doesn’t give any errors

$result = mysql_query("SELECT MAX(id) AS id FROM people") or die (mysql_error());

//displays image 87

$result = mysql_query("SELECT  * FROM people WHERE id = 87") or die (mysql_error());

enter image description here

  • 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-15T12:10:37+00:00Added an answer on June 15, 2026 at 12:10 pm

    It shouldn’t display an image, it should give a result of 87.

    See MAX

    You could do:

    select * from people order by id desc limit 0, 1 
    

    which should give you the latest image by ID.

    To make this dynamic and allow a next button you would need to store the value of image being viewed. When the next button is clicked you could then do

    select * from people order by id desc limit 1, 1 //Start at row 1, bring back 1.
    

    See MySQL Limit

    You would need to use PHP to assign the values in limit and your next link though. To do this you would need to have link like so:

    <a href="www.mysite.com/page?imagecount=1">Next</a>
    

    Then using PHP you could:

    <?php
        if (isset($_GET["imagecount"]))
            $next = (int)$_GET["imagecount"]; //Don't forget the (int) cast to avoid SQL injection!!!
        else
            $next = 0;
    
       $result = mysql_query("select * from people order by id desc limit $next, 1") or die(mysql_error());
    ?>
    

    TO expand on the link, you could then make your link dynamic:

    <a href="www.mysite.com/page?imagecount=<?php echo $next+1; ?>">Next</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make an SQL Function that returns a nvarchar(MAX) string. The
I'm just trying to make a simple function that will return all the data
I am trying to make an SQL statement that takes eight different numbers and
I'm trying to write a stored procedure in SQL that will : Make a
I'm trying to make my index() function display only the ExpenseClaims belonging to that
I trying to make a sql script that will randomize the city, state, and
I use NUnit integration tests. I am trying to test to make sure that
I am trying to make a mock database that displays the equipment data for
I'm trying to make a connection to a SQL Server Express DB on localhost,
I am trying to make a query to an SQL database and I can't

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.