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

The Archive Base Latest Questions

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

I’m trying to connect MySQL database and getting out datas I need it to

  • 0

I’m trying to connect MySQL database and getting out datas
I need it to get only (Data) in order by ID(daily)
and separate both datas and calling them by two different variables
the database looks something like this:

------------------------------
| ID |   Data  |  Data2
------------------------------
| 1  |  tea    |   hot
| 2  |  milk   |   hot
| 3  | pepsi   |  cold

and output will be only one line (one data)

I don’t make it as above 🙂 it’s just for clarifying….and what’s best collation and type for huge data in UTF-8 ?

Edit:
Can you make it return 5 rows instead of 1? by ID? for e.g. for first day (1-2-3-4-5)ID’s and for second day (6-7-8-9-10) and so on?

  • 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-23T13:47:12+00:00Added an answer on May 23, 2026 at 1:47 pm
        quotes
        ----------------------------------
        | id | data        | data2
        ----------------------------------
        | 1  | first quote | translated quote
        | 2  | second...   | bla bla
    

    And then you select it like:

       $firstday="2011-06-06";
        $getquote = mysql_query("SELECT * FROM quotes WHERE id=(DATEDIFF(CURDATE()+1, '$firstday'))");
    $quote = mysql_fetch_object($getquote);
    echo $quote->data . $quote->data2;
    

    EDIT!!: I have eliminated datediff, so the ID returned from date difference is DIRECTLY in WHERE.

    What this does is calculate difference between first day and current date. So each day that datediff will be 1 bigger.
    DATEDIFF(CURDATE()+1, '$firstday') as datediff can be interpreted as

    datediff = differenceBetween(Currentday +1 and firstDay)
    
    • Yesterday was 2011-07-06, therefore datediff = 2011-07-07 (there is +1!) - 2011-07-06 which is 1
    • today, it’s 2011-07-08 - 2011-07-06 which is 2
    • tomorrow 2011-07-09 - 2011-07-06 which is 3
    • day after tomorrow 2011-07-10 - 2011-07-06 which is 4
    • in one month it will be 2011-08-08 - 2011-07-06 which is 33

    so, datediff is each day bigger by 1

    quotes
    -------------------------
    |id| data
    -------------------------
    |1| quote          day 1 (because date difference from start == 1)
    |2| quote 2        day 2 (datediff == 2)
    |3| quote 3        day 3 (datediff == 3)
    |4| quote 4        day 4
    .....
    

    Or shortly: Each day will be a different quote, starting with ID 1 forward.

    I can’t explain more then this..


    EDIT #2: 5 quotes a day

    $offset = date_diff(new DateTime('now'), new DateTime('2011-08-29'))->format('%d');
    $getquote = "SELECT * FROM quotes LIMIT {$offset},5";
    

    second edit thanks to ajreal (SQL LIMIT syntax error)


    EDIT #3: 5 quotes a day, changeable by variable..

    option 1:

    $choose=0; //statically defined, only first of that day will pop out
    

    option 2:

    $choose = mysql_real_escape_string($_GET["qid"]); //which one will be defined in url.. (watch out, people can figure it out and browse through all quotes
    

    option 3:

    $choose = rand(0,4); //will choose it randomly from those 5 daily quotes
    

    So pick one of those options you like, and add it before this:

    $offset = 5*date_diff(new DateTime('now'), new DateTime('2011-08-29'))->format('%d') + $choose;
    $getquote = mysql_query("SELECT * FROM quotes WHERE id = '$offset'");
    $quote = mysql_fetch_object($getquote);
    echo $quote->data . $quote->data2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.