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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:12:50+00:00 2026-05-30T07:12:50+00:00

First things first ive tried to fix this myself for hours and spent a

  • 0

First things first ive tried to fix this myself for hours and spent a good time trying to find an answer too but to no avail.. anyways any help wud be greatly appreciated, its for college! 🙂

i have a session variable of “custID” stored when someone enters their id on a login page.
in my mysql database the customer table has the rows “custID” and “clientID”. what i want to do is use the client id linked to that customer id to display the details of that client in a table (clientCompany is another table with “clientID” in it. all primary keys/foreign keys are working fine). the $refclient seems to be working. i echoed the result and it gave me “2001” which is what i wanted.

$refclient = mysql_query("SELECT clientID FROM Customer WHERE custID='$_SESSION[custID]'");

echo mysql_result($refclient, 0); // outputs "2001" which is the client ID. this works

however i now want that number to be used in my $client statement in the where clause.

$client = mysql_query("SELECT * FROM clientCompany WHERE clientID = '$refclient'");

this isnt working tho.. i understand that the $refclient gives “resource id #” but how do i convert that into a number so the where clause effectively says ” WHERE clientID = 2001 ” ? i dont know how to use join statements (im a noob!)
i did a quick count function which shows thats its not gettng the data from the table (it’s connected to the server ok)

$count2=mysql_num_rows($client);
if($count2==1)
 {
  echo "working"; // 1 row is all that it should create
 }
else 
 {
  echo "not working"; //this is what always shows
 }

i have some table headers here which i left out to shorten my question. all if statements, tables work fine, all brackets closed, stuff like that 🙂

here is what should be outputted:

 while($row = mysql_fetch_array($client))
{
echo "<tr>";
echo "<td>" .$row['clientID']. "</td>";
echo "<td>" .$row['compName']. "</td>";
echo "<td>" .$row['compAddress']. "</td>";
echo "<td>" .$row['contactPersonForCompany']. "</td>";
echo "<td>" .$row['compEmail']. "</td>";
echo "<td>" .$row['compPhoneNum']. "</td>";
echo "</tr>";
}

basically what should i use instead of ‘$refclient’ in my “$client” select statement?
when i type ‘2001’ instead of ‘$refclient’ it works perfectly but obviously i need to have it linked to the custID typed in so cant do that. also the customer cant know the clientID so i cant get them to input it/store is in a session variable..

$client = mysql_query("SELECT * FROM clientCompany WHERE clientID = '$refclient'");

PS sorry bout the essay of a question that is! just wanted to give as much detail as i could =) thanks in advance!

  • 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-30T07:12:51+00:00Added an answer on May 30, 2026 at 7:12 am

    You should save the value to a variable like so:

    $refclient = mysql_query("SELECT clientID FROM Customer WHERE custID='$_SESSION[custID]'");
    $client_num = mysql_result($refclient, 0);
    $client = mysql_query("SELECT * FROM clientCompany WHERE clientID = '$client_num'");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first things first, please excuse my utter noobness. I really tried to find a
Okay, so this is not the first time I've had this problem, but it
I'm doing my first steps with OpenGL ES 2.0 trying things on my ipod
This may be a really simple question, but things I've tried don't seem to
I've just started learning MATLAB, and the first thing i tried is to plot
I've installed PowerShell recently and one of the first things I started looking for
First things first. I'm running CodeIgniter on a PHP/MySQL site. I've been tasked with
First things first, I'm using: Java 1.7.0_02 MySQL 5.1.50 ZendServer CE (if that matters)
One of the first things I learned in C++ was that #include <iostream> int
One of the first things I like to do when I make a site

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.