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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:32:04+00:00 2026-06-16T15:32:04+00:00

I want to initialize a variable from an entry in an sql table; this

  • 0

I want to initialize a variable from an entry in an sql table; this entry is one I’ve queried for.

//Grab user id from users.sql
$quser = $db->query("
    SELECT *
        FROM users //in this table is a column named userident
        WHERE username = '$user' //this where conditional filters to a lone row         
");*/

I tried $var = $quser["ident"]; since this is how I would display table entries in a foreach() loop, but this doesn’t seem to work.

There is only one ident entry per user, so when I filter the query with where, it results in one row. Why can’t I grab the entry and place in a variable?

  • 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-16T15:32:06+00:00Added an answer on June 16, 2026 at 3:32 pm

    This is what you need to do

    1. Execute the query
    2. Pick up the first row (as there will be only one row this’ll work otherwise do it in a loop)
    3. Get the column from the row produced

    Here’s an example

        $quser = $db->query("SELECT * FROM users WHERE username = '$user'");
        $first_row=$quser->row();
    
        $reqdData=$first_row->ident; // Or whateber column you need
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to initialize my Cygwin environment with a variable coming from a batch
I want to initialize a Javascript variable from some JSON (generated via Jackson) in
I want to initialize a static Class variable in Java: public class NumberExpression {
I declare the private variable as private List<MultipartFile> files; When I want initialize it
i have a function(initialize) inside the a.as File.i want to access the that Variable
In my test app, I want to style variable height table cells with a
I am using sqlserver 2008 ,I want to initialize and increment variable ( @NUMTwo
So, I'm trying to initialize a DatagramSocket in a constructor, and I want this
The user comes to this page from a different page where they click on
I'm writing a custom control derived from CWnd . I want to initialize 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.