Re: [PHP] if then else statement not working

2005-05-09 Thread Deep
Hi,

Where are the dollar signs before seatnum, seat1 etc
in the if condition.

..Deeps..

--- Anasta <[EMAIL PROTECTED]> wrote:
> What am i doing wrong here, the output is always
> 'empty'
> 
> 
> 
> 
>   $result = mysql_query("SELECT username FROM users
> WHERE seatnum='seat1'") or die(mysql_error());
> 
>   if (seatnum == seat1) {
> echo username;
> } else {
> echo 'empty';
> }
> ?>
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] if then else

2005-05-06 Thread Richard Lynch
On Wed, May 4, 2005 12:20 am, Anasta said:
> Can anyone help with a statement, ive tried but it never works.
> I need to show a value if it is set to a specific value  ie:
>
> At the moment If a user is logs in a record is updated from 'away' to
> 'online'---so i want an echo statement to show a value from another table
> if
> they are set to online or else they show another value.
> (2 seperate tables).

//This gets 'away' or 'online':
//(Or something like it in your tables)
$query = "select status from whatever where username = '$username';
.
.
.

//Choose a table based on their logged in status:
if ($status == 'away'){
  $table = 'away_table';
}
else{
  $table = 'online_table';
}

//Now build a query with that table:
$query = "select stuff from $table where username = '$username'";


This is just ONE way of doing it.

Depending on your table structure, there could be other, better, faster
ways to do it.

We'd need to know more about the 'away' and 'online' table[s] and a bit
more info to really help you...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] if then else statement not working

2005-05-05 Thread Rasmus Lerdorf
Anasta wrote:
> What am i doing wrong here, the output is always 'empty'
> 
>   $result = mysql_query("SELECT username FROM users
> WHERE seatnum='seat1'") or die(mysql_error());
> 
>   if (seatnum == seat1) {
> echo username;
> } else {
> echo 'empty';
> }
> ?>

That doesn't even look like PHP code.  In PHP variables have $ in front
of them, and you are only sending a query, you aren't assignining
anything to the variables.  And further, your actual SQL query is
already applying that restriction, so any usernames returned by the
query will by definition have their seatnums be set to 'seat1' in the
database.

-Rasmus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] if then else statement not working

2005-05-05 Thread Philip Hallstrom
What am i doing wrong here, the output is always 'empty'

 if (seatnum == seat1) {
echo username;
} else {
echo 'empty';
}
?>
Just guessing since I'm not sure what you're trying to do, but...

$result = mysql_query("SELECT username FROM users WHERE seatnum='seat1'")
  or die(mysql_error());
list($username) = mysql_fetch_array($result, MYSQL_NUM);
if ($seatnum == "seat1") {
echo $username;
}else {
echo 'empty';
}
?>
What I'm not seeing is where you set $seatnum in the first place and why 
you're doing the if/else at all since your mysql query will only return a 
username *if* seatnum='seat1' already so the above code I'm guessing will 
always print out $username (or blank if the query returns no results).

Anyway, the above should get you going in the right direction...
-philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] if then else statement not working

2005-05-05 Thread Gabriel Guzman
Anasta wrote:
What am i doing wrong here, the output is always 'empty'


  if (seatnum == seat1) {
echo username;
} else {
echo 'empty';
}
?>
mysql_query() returns a resource, not the results themselves.
read: http://us3.php.net/manual/en/function.mysql-query.php especially 
the 2nd example to see what else you need to do to get to your results.

hint:  mysql_fetch_assoc()
have fun,
gabe.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] if then else statement not working

2005-05-05 Thread bala chandar
On 5/5/05, Anasta <[EMAIL PROTECTED]> wrote:
> What am i doing wrong here, the output is always 'empty'
> 
>   $result = mysql_query("SELECT username FROM users
> WHERE seatnum='seat1'") or die(mysql_error());
> 
>   if (seatnum == seat1) {

you must use 

  if (seatnum == "seat1") {

> echo username;
> } else {
> echo 'empty';
> }
> ?>
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
bala> balachandar muruganantham
blog> lynx http://chandar.blogspot.com
web> http://www.chennaishopping.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] if then else statement not working

2005-05-05 Thread Anasta
What am i doing wrong here, the output is always 'empty'






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] if then else

2005-05-04 Thread Anasta
Can anyone help with a statement, ive tried but it never works.
I need to show a value if it is set to a specific value  ie:

At the moment If a user is logs in a record is updated from 'away' to
'online'---so i want an echo statement to show a value from another table if
they are set to online or else they show another value.
(2 seperate tables).

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] if then else short form

2005-01-21 Thread Manoj
 language tutorial (basic)...

>if ( a=b ) ? a=1 ; a=2;
  a = a==b ? 1 : 2 ;
Cheer,
Manoj Kr. Sheoran 
Software Engg. 
Daffodil Software Ltd. 
web: www.daffodildb.com 
INDIA 






On Fri, 2005-01-21 at 17:31, Ben Edwards wrote:
> I seem to remember seing someone use a abreaviated form of a
> if/them/else of the type that can be used in java.
> 
> It was something like
> 
> if ( a=b ) ? a=1 ; a=2;
> 
> Anybody know what the correct syntax is?
> 
> Ben
> -- 
> Ben Edwards - Poole, UK, England
> WARNING:This email contained partisan views - dont ever accuse me of
> using the veneer of objectivity
> If you have a problem emailing me use
> http://www.gurtlush.org.uk/profiles.php?uid=4
> (email address this email is sent from may be defunct)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] if then else short form

2005-01-21 Thread Jochem Maas
Ben Edwards wrote:
I seem to remember seing someone use a abreaviated form of a
if/them/else of the type that can be used in java.
It was something like
if ( a=b ) ? a=1 ; a=2;
I called it the 'tertiary' syntax which is not correct:
to quote a page I found: "
that the book refers to a "tertiary" operator, instead of a "ternary" 
operator. Of course, "tertiary" means third. "Ternary" means having 
three parts and is the correct way to describe the ?: operator. 
Alternatively, this operator could be described as "trinary".
"

Anybody know what the correct syntax is?
Ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] if then else short form

2005-01-21 Thread Jochem Maas
Ben Edwards wrote:
I seem to remember seing someone use a abreaviated form of a
if/them/else of the type that can be used in java.
It was something like
if ( a=b ) ? a=1 ; a=2;
$a = ($a == $b) ? 1: 2;
which meand: if $a is equal to $b then set $a to 1 otherwise set $a to 
2. that is equivalent to:

if ($a == $b) {
$a = 1;
} else {
$a = 1;
}
btw: its called the 'tertiary' syntax (because its the third form)
Anybody know what the correct syntax is?
Ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] if then else short form

2005-01-21 Thread Sergio Gorelyshev
On Fri, 21 Jan 2005 12:01:09 +
Ben Edwards <[EMAIL PROTECTED]> wrote:

> I seem to remember seing someone use a abreaviated form of a
> if/them/else of the type that can be used in java.
> 
> It was something like
> 
> if ( a=b ) ? a=1 ; a=2;
> 
> Anybody know what the correct syntax is?

condition ? do_that_if_true : do_that_if_false;

> Ben
> -- 
> Ben Edwards - Poole, UK, England
> WARNING:This email contained partisan views - dont ever accuse me of
> using the veneer of objectivity
> If you have a problem emailing me use
> http://www.gurtlush.org.uk/profiles.php?uid=4
> (email address this email is sent from may be defunct)
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


-- 
RE5PECT
Sergio Gorelyshev

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] if then else short form

2005-01-21 Thread Richard Davey
Hello Ben,

Friday, January 21, 2005, 12:01:09 PM, you wrote:

BE> I seem to remember seing someone use a abreaviated form of a
BE> if/them/else of the type that can be used in java.

BE> It was something like

BE> if ( a=b ) ? a=1 ; a=2;

BE> Anybody know what the correct syntax is?

It's called a ternary operator.

$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];

In the PHP manual under Comparison Operators.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I am not young enough to know everything." - Oscar Wilde

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] if then else short form

2005-01-21 Thread Ben Edwards
I seem to remember seing someone use a abreaviated form of a
if/them/else of the type that can be used in java.

It was something like

if ( a=b ) ? a=1 ; a=2;

Anybody know what the correct syntax is?

Ben
-- 
Ben Edwards - Poole, UK, England
WARNING:This email contained partisan views - dont ever accuse me of
using the veneer of objectivity
If you have a problem emailing me use
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] if then else?

2001-08-18 Thread Glyndower

btw...this is the code i'm trying

Please keep the laughter to a minimum...ah heck with it...laugh all you
want...its good for ya



Professional Experience: 


This field is empty

output for users with a variable other than value1 or value2






This field is empty

output for users with a variable other than value1 or value2



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] if then else?

2001-08-18 Thread Glyndower



-Original Message-
From: Glyndower [mailto:[EMAIL PROTECTED]]
Sent: Sunday, August 19, 2001 12:12 AM
Cc: [EMAIL PROTECTED]
Subject:


Ok, here we go

I'm new to PHP and also to MySql, but i'm making a pretty good go so far.
Until now, lol

I have a mysql database with several optional feilds (pe1.pe2.pe2,e1,e2,e3,
etc)

What I'm looking for is a way to check the value of each optional feild and
if said feild is "not null" or contains data. I want to create a header for
that feild and then a bulleted list of the options in the feilds under the
header.

i.e something along the lines of:

 

So the final output would end up like:

Professional Education
* College
* High School
* Middle School

TIA


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] if... then... else with HTML

2001-04-23 Thread Richard Crawford


Alternatively, and this is what I would do because it would be easier to 
maintain should you want to change the content later on, you could use 
includes as per the following:


\n\nTry This\n\n\n");
if(condition)
include("html_block_1.html");
else
include("html_block_2.html");
print("\n");
?>

I suppose it would depend on how big your HTML blocks are.

Either way -- using includes or using the method below -- will work, and 
with neither method will you have to escape out your special characters.



>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 4/23/01, 3:59:41 PM, "elias" <[EMAIL PROTECTED]> wrote 
regarding Re: [PHP] if... then... else with HTML:


> yes, consider this:

> 
> 
> 
> your name is 
> 
> name is not set!
> 
> 
> 

> -elias
> http://eassoft.cjb.net

> "Martin Thoma" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Hello !
> >
> > I want to do something like
> >
> > if (condition)
> > output this html-block
> > else
> > output that html-block
> >
> >
> > Without printig or echoing the html-block out (because the block has a
> > lot of  ", which I all would have to slash out...)
> >
> > How can I do that ?
> >
> > Martin
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >



> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] if... then... else with HTML

2001-04-23 Thread elias

yes, consider this:




your name is 

name is not set!




-elias
http://eassoft.cjb.net

"Martin Thoma" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hello !
>
> I want to do something like
>
> if (condition)
> output this html-block
> else
> output that html-block
>
>
> Without printig or echoing the html-block out (because the block has a
> lot of  ", which I all would have to slash out...)
>
> How can I do that ?
>
> Martin
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




SV: [PHP] if... then... else with HTML

2001-04-23 Thread Fredrik Wahlberg

I hope I understood your question right. 
You can do like this

html text

other html




> -Ursprungligt meddelande-
> Fran: Martin Thoma [mailto:[EMAIL PROTECTED]]
> Skickat: den 23 april 2001 14:41
> Till: [EMAIL PROTECTED]
> Amne: [PHP] if... then... else with HTML
> 
> 
> Hello !
> 
> I want to do something like
> 
> if (condition)
> output this html-block
> else
> output that html-block
> 
> 
> Without printig or echoing the html-block out (because the block has a
> lot of  ", which I all would have to slash out...)
> 
> How can I do that ?
> 
> Martin
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] if... then... else with HTML

2001-04-23 Thread Avetis Avagyan

Something like this:

   output this html-block

output that html-block


Regards,
Avetis


Martin Thoma wrote:

> Hello !
>
> I want to do something like
>
> if (condition)
> output this html-block
> else
> output that html-block
>
> Without printig or echoing the html-block out (because the block has a
> lot of  ", which I all would have to slash out...)
>
> How can I do that ?
>
> Martin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
[EMAIL PROTECTED]
ICT Specialist
UNDP, Armenia



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] if... then... else with HTML

2001-04-23 Thread Tyler Longren



1st HTML here



2nd HTML here



> -Original Message-
> From: Martin Thoma [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 23, 2001 7:41 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] if... then... else with HTML
> 
> 
> Hello !
> 
> I want to do something like
> 
> if (condition)
> output this html-block
> else
> output that html-block
> 
> 
> Without printig or echoing the html-block out (because the block has a
> lot of  ", which I all would have to slash out...)
> 
> How can I do that ?
> 
> Martin
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] if... then... else with HTML

2001-04-23 Thread Geir Eivind Mork

On Monday 23 April 2001 14:41, Martin Thoma wrote:
if ($word != "flat") {

echo <<
html

html


-- 
 php developer / CoreTrek AS| I judge a religion as being good or bad 
 Sandnes / Rogaland / Norway| based on whether its adherents become
 web: http://www.moijk.net/ | better people as a result of practicing 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] if... then... else with HTML

2001-04-23 Thread Taylor, Stewart


   HTML

   HTML


-Stewart

-Original Message-
From: Martin Thoma [mailto:[EMAIL PROTECTED]]
Sent: 23 April 2001 13:41
To: [EMAIL PROTECTED]
Subject: [PHP] if... then... else with HTML


Hello !

I want to do something like

if (condition)
output this html-block
else
output that html-block


Without printig or echoing the html-block out (because the block has a
lot of  ", which I all would have to slash out...)

How can I do that ?

Martin




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] if... then... else with HTML

2001-04-23 Thread Martin Thoma

Ah, I forgott the {} ;-)


You are using Internet Explorer

You are not using Internet Explorer


Martin Thoma schrieb:

> Hello !
>
> I want to do something like
>
> if (condition)
> output this html-block
> else
> output that html-block
>
> Without printig or echoing the html-block out (because the block has a
> lot of  ", which I all would have to slash out...)
>
> How can I do that ?
>
> Martin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] if... then... else with HTML

2001-04-23 Thread Martin Thoma

Hello !

I want to do something like

if (condition)
output this html-block
else
output that html-block


Without printig or echoing the html-block out (because the block has a
lot of  ", which I all would have to slash out...)

How can I do that ?

Martin




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]