Simple MySQL Problem.

5 replies
Hey warriors,

I'm looking to call the last integer from a row in a database, and display it was plain text.

Here's the pseudocode:

SELECT Last Integer from DATABASE
OUTPUT Last Integer AS $lastint

then the php:

echo 'Links Generated: $lastint';

Any help at all guys?

trying to learn php and this is pretty crucial to me

Jamie.
#mysql #problem #simple
  • Profile picture of the author Speedyapoc
    I suggest you read up on PHP and MySQL from a resource such as the W3Schools as the task of doing this is very well documented.

    The code below adds multiple rows retrieved from your MySQL database into an array, and then echo's the last object in that array.

    Where "table" is a table.
    Where "row" is an inserted row.
    Where "integer_column" is a column in your table containing the piece of data you wish to withdraw.

    Apparently this board cannot handle PHP code in a thread without timing out when posting, so the code that I wrote is in the link here: <?php $query = mysql_query('SELECT `row` FROM `table`;'); $result = ar - Pastebin.com
    {{ DiscussionBoard.errors[4974653].message }}
  • Profile picture of the author ussher
    SELECT the_column_that_holds_the_integers
    FROM the_database_table
    ORDER BY the_column_that_holds_the_integers DESC
    LIMIT 1

    will return only the highest integer

    another way
    SELECT MAX(the_column_that_holds_the_integers)
    FROM the_database_table

    if you want only the most recent
    SELECT timestamp, the_column_that_holds_the_integers
    FROM the_database_table
    ORDER BY timestamp DESC
    LIMIT 1
    Signature

    "Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."

    - jamroom.net
    Download Jamroom free: Download
    {{ DiscussionBoard.errors[4974895].message }}
  • Profile picture of the author ussher
    and taking another guess based on this "echo 'Links Generated: $lastint';"

    if you want to count how many rows are in the database:
    SELECT COUNT(the_column_that_holds_the_integers) AS total_links
    FROM the_database_table
    Signature

    "Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."

    - jamroom.net
    Download Jamroom free: Download
    {{ DiscussionBoard.errors[4975409].message }}
    • Profile picture of the author rileywhitaker13
      Thanks for giving the useful information.
      {{ DiscussionBoard.errors[4976074].message }}
  • Profile picture of the author James Gould
    Thanks for the info guys!

    I'm giving this a shot now
    {{ DiscussionBoard.errors[4980057].message }}

Trending Topics