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

The Archive Base Latest Questions

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

I am currently trying to pass data from my server to my main page.

  • 0

I am currently trying to pass data from my server to my main page. I currently have my php echoing for each returned result:

while($row = mysql_fetch_array($result))
{
    echo "<img class='s' id=" . $row['id'] . " src=QR/" . $row['src'] ".png>";

}

when i tried adding a field, num, after id:

<img class='s' id=(rowid) num=".$row['num']." .......

I get undefined when i use

alert(this.num)

but

alert(this.id)

works. How can I pass the num value too?

EDIT:

Hey Everyone, thanks for you help, I have included a jsfiddle on how i solved this problem.
http://jsfiddle.net/3yzcx/4/

I had to use jQuery and used .attr() to define my own attribute called num and called that out.

  • 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-23T15:20:46+00:00Added an answer on May 23, 2026 at 3:20 pm

    Very simple. id is a valid property for the img tag. num is not. You can’t assign arbitrary properties to a tag and expect it to work.

    If you want to pass your PHP data to javascript, using a hidden form element or even more simply something like this:

    <?php
    echo '<script type="text/javascript">';
    echo 'var num = ' . $num . ';';
    echo '</script>';
    ?>
    

    Of course I know you’re in a loop, this is just an example. You could easily make it an array or something.

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

Sidebar

Related Questions

I'm currently trying to use the current session of a php web page from
I have an IPhone app that uses webservices to get data from a server.
I am trying to pass JSON data from the client browser to an ASP.NET
I am currently trying to decompress some data that I have coming in with
I'm currently trying to pull data from a database using a variable and then
I'm currently trying to pass a mono threaded program to multithread. This software do
I am currently trying to pass a generated JSON string to dojo for parsing
I am currently trying to create a function which will allow me to pass
My team is currently trying to automate the deployment of our .Net and PHP
I'm currently working on an iPhone app and I have a library from 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.