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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:20:20+00:00 2026-05-23T11:20:20+00:00

I am running into issues with the following code: $ids = ” . implode(‘,

  • 0

I am running into issues with the following code:

$ids = '"' . implode('", "', $crumbs) . '"';
$motd = array();
$dober = $db->query("SELECT id, name, msg, datetime FROM tbl_depts td INNER JOIN tbl_motd tm ON td.id = tm.deptid WHERE td.id IN (" . $ids . ")");

while ($row = $dober->fetch_array()) {
                $motd[] = $row;
      }

A print_r reveals this:

Array
(
[0] => Array
    (
        [0] => 1
        [id] => 1
        [1] => Management
        [name] => Management
        [2] => New Management Rule!
        [msg] => New Management Rule!
        [3] => 
        [datetime] => 
    )

[1] => Array
    (
        [0] => 2
        [id] => 2
        [1] => Human Resources
        [name] => Human Resources
        [2] => DPS
        [msg] => DPS
        [3] => 
        [datetime] => 
    )
)

As such, I cannot use this code to generate things:

foreach ($motd[] as &$value) {

        if ($motd['msg'] != "") {
            if ($i == 0) {
                ?>


                <li><a href="#" title="content_<?php echo $value['id']; ?>"
                       class="tab active"><?php echo $value['name']; ?></a></li>
                <?
            } elseif ($i == $len - 1) {
                ?>
                <li><a href="#" title="content_<?php echo $value['id']; ?>"
                       class="tab"><?php echo $value['name']; ?></a></li>

                <?php } else { ?>
                <li><a href="#" title="content_<?php echo $value['id']; ?>"
                       class="tab"><?php echo $value['name']; ?></a></li>
                <?
            }
            $i++;
        }
    }

Any ideas on what I’m doing wrong here?

EDIT: you might find it easier to understand if you read this first: Optimize this SQL query

  • 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-23T11:20:21+00:00Added an answer on May 23, 2026 at 11:20 am

    First – your code will not work because of this two lines:

    foreach ($motd[] as &$value) {
        if ($motd['msg'] != "") {
    

    You should use $motd, not $motd[] in foreach and check $value[‘msg’], not $motd[‘msg’]

    Second, try to use mysql_fetch_assoc instead of mysql_fetch_array

    Third – there is no initial value for $i.

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

Sidebar

Related Questions

I fear that I am running into memory leak issues by doing the following:
EDIT: I am basically running into the following documented issue . I am using
I've been running into a presentation issue with Internet Explorer. The following simple block
We're running into issues with how we specify font sizes. If we specify the
I am working on a client server system, and am running into issues where
I'm currently running into some issues resizing images using GD. Everything works fine until
I'm running into some issues with having a lot of UIImages in memory, so
I've compiled a java project into a Jar file, and am having issues running
I am running into issues when displaying special characters on the Windows console. I
I'm running into performance issues with Django because of m2m relationships. I have a

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.