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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:06:57+00:00 2026-05-28T08:06:57+00:00

Hi all got a small problem accessing a looped php variable. My script loops

  • 0

Hi all got a small problem accessing a looped php variable. My script loops through and uses x and y from a mysql database. It also loops the id out which I cannot get access to, it comes up as undefined. I am using a mouse out function to detect each separate div that has been looped and get specific id.

Help very much appreciated!

Javascript to get attributes ready for database manipulation:

  $(this).mouseout(function() {

   var stickytext_id = $(this).attr('textstickyid');//alerted out returns undefined.

   });

Looped PHP to get attr form:

      $get_textsticky_result=mysql_query($get_textsticky_query);

      while($row=mysql_fetch_assoc($get_textsticky_result)){
        $x = $row['textsticky_x'];
        $y = $row['textsticky_y'];

 echo '<div class="textsticky" style="position: absolute; left:'.$x.'px; top:'.$y.'px;" textstickyid="'.$row['textsticky_id'].'">
    <div class="textstickyvalueholder"contentEditable="true">'. $row['textsticky_text'] .'  
     </div><button>Like</button></div>';

      }
      ?>

Can get other looped vars e.g. $row[‘textsticky_text’]; and x and y for position without issue, Is there a better way to do this? I have a feeling the inline style is affecting it but not sure….

  • 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-28T08:06:58+00:00Added an answer on May 28, 2026 at 8:06 am

    Okay, I am just going to go out on a limb here and assume your initial selector is incorrect. $(this) is the window in typical code flow.

    $(this).mouseout(function() {
        var stickytext_id = $(this).attr('textstickyid');//alerted out returns undefined.
    });
    

    Should be:

    $('div.textsticky').mouseout(function() {
        var stickytext_id = $(this).attr('textstickyid');//alerted out returns undefined.
    });
    

    Also, as Kris mentioned in comments, instead of inventing tags use the data attribute which is a part of html5.

    <div class="textsticky" data-textstickyid="blah" />
    

    It can then be accessed via jQuery’s data method.

    http://jsfiddle.net/kQeaf/

    And as long as we are offering advice, if you are in jQuery 1.7+ you should be using prop instead of attr for accessing properties (unless of course you decide to use the data method) just recommended.

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

Sidebar

Related Questions

I have a small PHP mysql query looking at a table in my database.
I've got a Java project, which uses a small SQLite database. Now I want
Hi:) I have got a small problem with template double extends system. I have
I am working on a small project and i have got a problem. If
I'm trying to automate many repetitive tasks at work and this small problem got
I've got a little stuck with a small problem here: I use serialport communications
I used a small plugin from the jQuery-JavaScript-Library called Innerfade that I got here
I am developing a small web application that uses jquery's drag and drop. Problem
I got a small problem that I can't figure out. I have a superclass
Bit of a newb but just having a small problem using jquery cycle all

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.