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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:27:40+00:00 2026-05-27T05:27:40+00:00

MYSQL table structure: id , name , status , color how can i use

  • 0

MYSQL table structure:
id , name , status , color

how can i use PHP to get some data from my database(mysql) ,the php script will look for table rows that have “good” in the “status” column. Then echo those rows which have good in status(P/S out into a JS file. It also get the color from each row (with status=good) and ptu it into javascript(jQUery)

I did a little research on how to use php to generate javascript.

Here’s a php script, it’s not working btw:

<?php
header("content-type: application/x-javascript");

  include 'connect.php';
  $sql = "SELECT * FROM users WHERE status ='good'"; 
  $query = mysql_query($sql)or die(mysql_error());

  $rows = array();
while($row = mysql_fetch_array( $query )){
  $rows[] = $row;
  echo "$('a[href*=\"row[username]\"]').css('color', 'row[color]');\n";
}

?>

The out put is (which wont work):

$('a[href*="row[username]"]').css('color', 'row[color]');

The connect.php is working(connects to database) , just the script is not working.

(BTW: The file name of this is usercolor.js.php , is it correct?)
I hope someone could guide me.

Thanks and have a wonderful day.

  • 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-27T05:27:40+00:00Added an answer on May 27, 2026 at 5:27 am
    echo "$('a[href*=\"row[username]\"]').css('color', 'row[color]');\n";
    

    won’t work. Try

    $username = $row['username'];
    $color = $row['color']; 
    echo "$('a[href*=\"$username\"]').css('color', '$color');\n";
    

    or

    echo "$('a[href*=\"{$row['username']}\"]').css('color', '{$row['color']}');\n";
    

    see the manual for an explanation. Also, according to your mysql table structure, the column is called name and not username.

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

Sidebar

Related Questions

Is it possible to somehow get structure of MySQL database, or just some table
How can I using KohanaPHP framework and database module get mysql table structure? I've
i have a php question, how can i get all the data from the
how to make a good MySQL Database Table Structure from this XML-Code? <xml> <product>
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a many to many table setup in my mysql database. Teams can
i have a mysql table structure : emails( id , name , email )
I'd like to select some Addresses from a MySQL DB. Addresses can have a
Lets say I have two MySQL databases with some complex table structures. Neither database
i need some help with this sql query heres my mysql table structure: DOMAINS

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.