I have an index.php page that does a query from a database of users, in this database there is a field called isadmin.. I am wondering if it would be possible to do some type of IF statement based on that field having a certain value? Some how fetching the status of that field, like if field=1 then echo "this" and if it equals 0 then display nothing..?
Thanks
5 2128
I have an index.php page that does a query from a database of users, in this database there is a field called isadmin.. I am wondering if it would be possible to do some type of IF statement based on that field having a certain value? Some how fetching the status of that field, like if field=1 then echo "this" and if it equals 0 then display nothing..?
Thanks
That can be done by sql.. - SELECT * FROM `your_table` WHERE `field_1`='value_1' AND `isadmin`='required_value'
If you want to try that with an if in PHP, do it like
[PHP]
while ($row = myqsl_fetch_array($sql))
{
if ($row['isadmin']==" required_value")
{
echo "string to be printed";
}
}[/PHP]
But the SQL solution is recommended.
Sorry for bursting in, but I think what OP means is that he/she wants to replace a selected column value using an IF function. As the following example: when field_1 equals 1 it will be shown as 'this' - SELECT *, IF(field_1=1, 'this', field_1) AS field1_new FROM your_table;
Ronald
This is a MySQL question so I will move it to the MySQL forum.
moderator
Sorry for bursting in, but I think what OP means is that he/she wants to replace a selected column value using an IF function. As the following example: when field_1 equals 1 it will be shown as 'this' - SELECT *, IF(field_1=1, 'this', field_1) AS field1_new FROM your_table;
Ronald
ohh... if that's the case, then I guess I misinterpreted the question.
Harpreet
ohh... if that's the case, then I guess I misinterpreted the question.
Harpreet
Happens to me frequently. Sometimes it is hard to understand what the OP means, because the real question is more or less hidden in the stated question.
Ronald
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tim Williams |
last post by:
I'm trying to write a simple python program to access a MySQL
database. I'm having a problem with using MySQLdb to get the results
of a SQL command in a cursor. Sometimes the cursor.execute works,...
|
by: Alastair Cameron |
last post by:
VB6, MSXML 3.2 installed:
Q1.
I am having a problem selecting nodes with XPATH expressions when an
attribute values contain backslashes (\\) in as part of its value:
For example the...
|
by: Joshua Ammann |
last post by:
Hello,
I'm trying to export a query containing contact information, including a
field. Some zip codes have one or two leading zeros, for example,
San Juan, PR (00927) and Springfield, MA...
|
by: Adil Bohoudi |
last post by:
Hi all,
i'm using a datagrid to show somedata retrieved from an sql-server 2000.
this datagrid contains two columns a startdate and an enddate column.
i used a storedprocedure to get both...
|
by: Daniel Manes |
last post by:
I'm baffled. I have a column in a SQL Server Express database called
"Longitude," which is a float. When I view the table in a DataGridView,
some of the numbers, which only have two decimal places...
|
by: william |
last post by:
#include <stdio.h>
int main()
{
char *str=NULL;
char x="today is good!";
printf("%s", str);
str=strtok(x," ");
if (str=="today") //<==here is line that confuses me
printf("they equals!\n");
|
by: VbaNewbee |
last post by:
I have a form with a few filters. Once the user clicks "search button", the code first evaluates my filters, then shows the query results in a List Box" titled backschedule.
I have a few text...
|
by: Lucas |
last post by:
Hi,
I want to display an exception in a javascript alert and I'm rendering
that client code using
ClientScript.RegisterStartupScript(GetType(), key,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |