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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:43:27+00:00 2026-06-03T22:43:27+00:00

I want to extract up to five values from an array and place them

  • 0

I want to extract up to five values from an array and place them in a msql query as such:

$frontpage_hot_list_data = array(); 

while (@$row = mysql_fetch_array($sql_frontpage_hot_list)) {
    $frontpage_hot_list_data[] = $row['id']; 
}

$sql_frontpage_hot_down = mysql_query("SELECT * FROM submissions WHERE 
id !='$frontpage_hot_list_data[0]' AND id !='$frontpage_hot_list_data[1]' AND
id !='$frontpage_hot_list_data[2]' AND id !='$frontpage_hot_list_data[3]' AND 
id !='$frontpage_hot_list_data[4]' AND thumbnail_large=0 AND popular=1 AND 
popular_datetime > '$frontpage_hot_hot_three_onlineNowTm' AND 
views > '$frontpage_hot_hot_three_views' ORDER BY views DESC LIMIT 4");

The problem here appears to be when I have less than five values, I get the following error:

Notice: Undefined offset: 1 in
D:\Hosting\8847501\html\scripts\timeframes.php on line 298

Notice: Undefined offset: 2 in
D:\Hosting\8847501\html\scripts\timeframes.php on line 299

Notice: Undefined offset: 3 in
D:\Hosting\8847501\html\scripts\timeframes.php on line 300

Notice: Undefined offset: 4 in
D:\Hosting\8847501\html\scripts\timeframes.php on line 301

Any idea how to solve this problem? Maybe placing in the query only the exact number of variables? Im lost…

  • 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-06-03T22:43:29+00:00Added an answer on June 3, 2026 at 10:43 pm

    You can use implode to create a comma-separated list of your IDs, then put this newly created list into a MySQL IN expression (UPDATE: now I see that you’re using != in your query, so let’s make it NOT IN).

    $list = implode(',', $frontpage_hot_list_data);
    $sql_frontpage_hot_down = mysql_query("SELECT * FROM submissions WHERE 
    id NOT IN ($list) AND thumbnail_large=0 AND popular=1 AND 
    popular_datetime > '$frontpage_hot_hot_three_onlineNowTm' AND 
    views > '$frontpage_hot_hot_three_views' ORDER BY views DESC LIMIT 4");
    

    Important note: I assumed here that your ids are numeric, so implode() would produce something like 1,5,133,31. If they are strings, then you have to wrap them in apostrophes first using array_map() for example.

    Also, if you expect that the array can be empty, you can add another condition that will omit the whole id NOT IN () AND part when necessary.

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

Sidebar

Related Questions

i want to extract number string values of a char array. Actually I want
i want to extract data from the database rather local data while selecting value
i want to extract the available fields as an array from a fillable pdf.
I want to extract values from music structure directories using File::Find::Rule and I'm having
I want extract the path of images from a html page using PHP-preg_match_all(), the
I want to extract the last inserted record from database, using this type of
I want to extract text from crawled html web pages. I am using the
I want to extract data from a word document with extension docx. This document
Want to extract the text value from a lookup table's column in a db.
I want to extract unique characters from files ( UTF-8 , contains asian characters)

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.