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

  • Home
  • SEARCH
  • 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 3871082
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:47:23+00:00 2026-05-19T21:47:23+00:00

I searched old questions, but couldn’t find an answer or wrap my head around

  • 0

I searched old questions, but couldn’t find an answer or wrap my head around anything relevant (new to PHP and MySQl so take it easy)!

I have a MySQL table with the columns: id, subid, name; I ran this query:

CREATE TABLE mytable (id int(999999) NOT NULL auto_increment,subid varchar(99) NOT NULL,name varchar(99) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))

From the value in subid on the latest row I want to set to $latestsubid, this is what I’ve managed to throw together:

    <?
    $user="me";
    $password="blah";
    $database="mydb";
    $host="localhost";
    mysql_connect($host,$user,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT subid FROM mytable";
    $result=mysql_query($query);
    $num=mysql_numrows($result);
    mysql_close();
    ?>

If anyone could give me a hand it’d be great!

  • 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-05-19T21:47:23+00:00Added an answer on May 19, 2026 at 9:47 pm

    I’m not sure if i understand what you want to achieve, but if you want to get the “subid” column value from the table row with the highest “id” value you can do:

    $query="SELECT subid FROM mytable ORDER BY id DESC LIMIT 1";
    $result=mysql_query($query);
    $row = mysql_fetch_assoc($result);
    $latest_subid = $row['subid'];
    

    This will sort the table descending on id (so the first row returned is the one with the highest id) and then just limit your result to 1 row,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I searched before but couldn't find any answers. I am somewhat new to c++,
Searched, but couldn't find a good answer. I have an ASP.NET application that I
I searched for the answer to this question but couldn't find any good. Maybe
Searched around on SO for an answer. Found some interesting stuff but I am
I have searched for this but did not find a perfect function in php.
Searched a lot about this problem but never found a answer, that solved it.
I searched before asking this question. I didn't find an answer probably because I
Background information: I've searched stackoverflow for a specific solution and couldn't find one that
Hey guys, before you guys say anything I have searched and can not find
I feel stupid asking this question, but I can not find a clear answer

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.