Jump to content

[SOLVED] Adding variables and Select


Cless

Recommended Posts

Hello,

 

I have two questions. The first one is, how do you add two variables together? Not string variables (ones with words), but variables using numbers. So, if $Int1= 4, and $Int2= 3, I want to add those up to make them 7 (4+3=7). I used to know, however, I forgot. Is it

$Int1+$Int2;

?

 

Second question. How could you, erm, in a mysql select function, make a second condition in the where part? Um, that is obviously confusing. Here.

 

So,

$Result= mysql_query("SELECT * FROM $Table WHERE Username='$_POST['Username']'")

Yes. That would find your username from whatever specified table, or whatever. However. let's say you allowed people to have the same names, which no one would do, nor am I, however, I am using the normal User information stuff to show you examples and stuff. Anyways, let's say you allowed people to have the same names, but they had to have different genders... So, if two users had the name "Fool" XD, but their genders were not the same... how could you select the user info, then?

 

Like... allowing the where to have two conditions.

$Result= mysql_query("SELECT * FROM $Table WHERE Username='$_POST['Username']'")

How could that also use WHERE Gender='$_POST['Gender']? This obviously wouldn't work...

$Result= mysql_query("SELECT * FROM $Table WHERE Username='$_POST['Username']' WHERE Gender='$_POST['Gender']'")

So... it would have two conditions. :S

 

God, that was SERIOUSLY confusing... Sorry if you couldn't understand.

 

Thanks.

Link to comment
Share on other sites

$sum=$x+$y;

Oh, I see. Thanks!

 

you can have this

Username='{$_POST['Username']}'

or

Username=".$_POST['Username']."

Wha--? o.o I don't get it. xD I don't see what you're talking about... I already know how to find usernames using POST and such, lol.

Link to comment
Share on other sites

In answer to the second question: yes.

$Result= mysql_query("SELECT * FROM $Table WHERE Username='$_POST['Username']' AND Gender='$_POST['Gender']'")

Or:

$Result= mysql_query("SELECT * FROM $Table WHERE Username='$_POST['Username']' OR Gender='$_POST['Gender']'")

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.