473,378 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

structure a select statement with multiple where

Hi,
I am doing a project with dreamweaver and i ran into a hitch with my select statement.
I have this

Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2.     FROM client, `statement`
  3.     WHERE client.client_id = `statement`.client_id 
when i execute this it selects everybody in the database. So i want to add another WHERE statement to this query, this time one that compares the client.username with the session variable "MM_Username".
Thank you in anticipation of solving this for me!
So I am looking at something like this

Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2.     FROM client, `statement`
  3.     WHERE client.client_id = `statement`.client_id  AND WHERE client.username = '$_SESSION['MM_Username']'
The session php code is as follows



Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     if (!isset($_SESSION)) {
  3.       session_start();
  4.     }
  5.     $MM_authorizedUsers = "";
  6.     $MM_donotCheckaccess = "true";
  7.  
  8.     // *** Restrict Access To Page: Grant or deny access to this page
  9.     function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  10.       // For security, start by assuming the visitor is NOT authorized. 
  11.       $isValid = False; 
  12.  
  13.       // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  14.       // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  15.       if (!empty($UserName)) { 
  16.         // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
  17.         // Parse the strings into arrays. 
  18.         $arrUsers = Explode(",", $strUsers); 
  19.         $arrGroups = Explode(",", $strGroups); 
  20.         if (in_array($UserName, $arrUsers)) { 
  21.           $isValid = true; 
  22.         } 
  23.         // Or, you may restrict access to only certain users based on their username. 
  24.         if (in_array($UserGroup, $arrGroups)) { 
  25.           $isValid = true; 
  26.         } 
  27.         if (($strUsers == "") && true) { 
  28.           $isValid = true; 
  29.         } 
  30.       } 
  31.       return $isValid; 
  32.     }
  33.  
  34.     $MM_restrictGoTo = "myflog.php";
  35.     if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  36.       $MM_qsChar = "?";
  37.       $MM_referrer = $_SERVER['PHP_SELF'];
  38.       if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  39.       if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  40.       $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  41.       $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  42.       header("Location: ". $MM_restrictGoTo); 
  43.       exit;
  44.     }
  45.     ?>
  46.  
Jan 17 '13 #1
2 1443
Rabbit
12,516 Expert Mod 8TB
I don't see your query anywhere in your PHP code.

As far as your query goes, the syntax is wrong, you only need to use the WHERE clause once. And the SQL engine won't have access to your PHP variables so you will have to append the value to the SQL string in your code.
Jan 17 '13 #2
Anas Mosaad
185 128KB
That reminds me of one mysteries select statement. It's the only case I could see where twice in a select statement:
Expand|Select|Wrap|Line Numbers
  1. SELECT SELECT FROM WHERE WHERE
It's explained very well by Serge here https://www.ibm.com/developerworks/m...here49?lang=en
Jan 25 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Guy Hocking | last post by:
Hi there, I have a problem in my ASP/SQL Server application i am developing, i hope you guys can help. I have a ASP form with list boxes populated by SQL tables. When a user selects a value...
8
by: Adam Nemitoff | last post by:
Is is possible to construct a SELECT statement that contains a WHERE clause that uses the value from a column in the "next" row? ie. given a table with a single field named "myField" with the...
1
by: avinash | last post by:
hi myself avi i am developing one appliacaion in which i am using vb 6 as front end, adodb as database library and sql sever 7 as backend. i want to update one table for which i required data from...
15
by: grunar | last post by:
After some thought on what I need in a Python ORM (multiple primary keys, complex joins, case statements etc.), and after having built these libraries for other un-named languages, I decided to...
3
by: rhamlin | last post by:
I'm fairly new to creating complex sql statements and need a little help. In plain english I want to do this: Select menu rows where the row's userGroupIDs equal the user's userGroupIDs. ...
4
by: Dave [Hawk-Systems] | last post by:
have a data table that records entries by date(unix timestamp) and customer number. each custnum will have several entries showing a running ledger type snapshot. we have the need to get the most...
0
by: djflow | last post by:
Hi! II was wondering if you can help me with SQL query.. Below 7 separated select query works fine(only when they are retrieved separately) But I want to combined them together and so that i...
3
by: sangam56 | last post by:
Hello!I am using following sql statement: SELECT Menu.MenuID,Menu.TextUrl FROM Menu WHERE Menu.MenuID= (SELECT Permissions.MenuID FROM Permissions WHERE Permissions.RoleID=(SELECT Roles.RoleID...
1
by: ebo2006 | last post by:
There are two combo boxes in my form: CORP and CLASS. The WHERE clause of the SELECT statement in the Row Source Property of the CLASS combo box works only every time I start the form. It does not...
1
by: ncsthbell | last post by:
Once again... I am supporting another Access database that I did not build. The previous 'owner' of this built the tables with spaces in the table names as well as the column names. I am having a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.