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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:40:55+00:00 2026-05-27T09:40:55+00:00

I see several questions relating to my problem, but I’m very new to programming

  • 0

I see several questions relating to my problem, but I’m very new to programming and cant figure out half the responses. Below is the only thing I have gotten working for getting data out of my table, it is however doing way more than I need it to, and still giving me an undesired result.

I simply want to take the string from the first row of my table and save into a php variable called $news1.

$connection = mysql_connect("localhost", "USERNAME", "PW");

if(!$connection)
{
    die("<p>no connection to database</p>");   
}

if(!mysql_select_db("akron11_db", $connection))
{
    die("<p>Kunne ikke finde databasen</p>");
}

$result = mysql_query("SELECT news1 FROM TurenTilDannmark", $connection);   

if(!$result)
{
    die("<p>Efterspørgslen slog fejl " . mysql_error() . "</p>");   
}

$rows = mysql_num_rows($result);

for ($item = 0; $item < $rows; $item++)
{
    echo "<li>" . mysql_result($result, $item) . "</li>";  
} 

echo "</p>"; 
  • 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-27T09:40:55+00:00Added an answer on May 27, 2026 at 9:40 am

    You can use limit to fetch just one result:

    $result = mysql_query('SELECT news1 FROM TurenTilDannmark LIMIT 1', $connection);
    

    Then you you can use mysql_fetch_assoc:

    $row = mysql_fetch_assoc($result);
    echo $row['news1']; // ta-da!
    

    Or mysql_result:

    $news1 = mysql_result($result, 0); // 0 is the index of the field, not the row
    echo $news1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see several questions relating somewhat to this, but I still can't find the
(I see several questions related to my problem but none of the solutions work
I see several other questions about load testing web services. But as far as
I'm new to Java programming. I have several questions about how to implement RingFiFoBuffer:
I see this in Facebook (also Google), but can't figure out how to do
Have several questions. Don't flame me - I'm newbie, but eager to know more.
I have several questions regarding forms and PHP but if I should put them
I realise there are several questions on this subject but I believe my angle
I referred to several questions here about recursion but I am not able to
Several (newbie) questions: 1) I see a lot of public Person SelectedPerson { get;

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.