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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:12:14+00:00 2026-05-26T06:12:14+00:00

OK I tried looking through the mySQL threads but I couldn’t find what I

  • 0

OK I tried looking through the mySQL threads but I couldn’t find what I wanted probably because I didn’t know the correct terms.

Anyways I need a query to return rows that are equal to a string. This case “David” I want to show two things “comments” and “postdate”. Only the date is being shown right now but no comments. Yes there is data in the comments.

Here is what I have so far:

> $query  = "SELECT * FROM sessionscomments  session = 'David'"; 
> $result = mysql_query($query);
> 
> 
> while($row = mysql_fetch_assoc($result)) {
> 
>   echo    "<div id=fav>";     
>   echo    strip_tags( "Date: {$row['postdate']}");
>   echo    "</div>";   
>   echo    "<br>";     
>   echo    strip_tags("{$row['comments']}");
>   echo    "<br>";     
>   echo    "<hr class= \"box\">";
> 
> }

and I have the date stored with CURRENT_TIMESTAMP how can I just show the day month and year?

and how can I have the last echo line NOT happen with the last run through?

Thanks in advance.

  • 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-26T06:12:14+00:00Added an answer on May 26, 2026 at 6:12 am

    It’s called a WHERE clause, and you’ve almost got it in your query:

    SELECT comments, postdate
    FROM sessioncomments
    WHERE session='David'
    

    Don’t use SELECT *. It’s inefficient, especially if it’s a “wide” table and you’re only going to use a couple fields. It’s like hauling home a month’s worth of groceries and then throwing it all in the trash and eating only the jellybeans and cookies.

    As well, don’t assume a query succeeds. At bare mininum, for developing purposes, you should always do something like this:

    $result = mysql_query($sql) or die(mysql_error());
                                ^^^^^^^^^^^^^^^^^^^^^
    

    This’ll kill the script if the query fails, and tell you exactly why it failed. Otherwise your script would simply continue onwards with no (or bad) results and probably screw up later on because of this bad data.

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

Sidebar

Related Questions

I've tried looking through the documentation, but I can't seem to find (or recognize)
I tried looking through some other posts, but didn't see anything exactly what I'm
I've tried looking at similar problems, but could not easily find one that helped
I know silly question but i tried looking it up on Google with no
I tried looking through all the pages about unit tests and could not find
I've tried looking around and there are similar problems, but mine is way more
i have tried looking online but had no luck, How i could delete all
What exactly does execve() do? I've tried looking at the documentation (http://linux.die.net/man/2/execve) but given
This is a fairly involved bug, and I've tried looking around to find other
I tried urllib{2}, pycurl and I'm looking at twisted's new http client. But: I

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.