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
https://forums.phpfreaks.com/topic/59349-solved-adding-variables-and-select/
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']'")

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.