tags:

views:

50

answers:

3

Hi to all!

I have a query that gets the name and an id.
The results is like this :

54 - Rian Ree Barrientos

I wanted to get the number 54.
I used echo (int)$_GET['number'];
But the result is "0". How can I get the number?

+1  A: 

You can't get it that way, you need to make two query string vars for it eg:

<a href="somepage.php?number=54&str=some_string">

Make sure that if you do so, you use the urlencode function.

Now you can use:

echo (int) $_GET['number'];

And:

echo $_GET['str'];

Otherise you can use the explode function to get the two values by specifying the - delimiter.

Sarfraz
why `mysql_real_escape_string`? oO
knittl
@knittl: Yup, not needed really.
Sarfraz
A: 

I think you want id from the value you get from the query

I think you want something like following

$strPrice1 = mysql_query("SELECT id, name FROM table_name where id=".$_GET['id'] );
$strPrice = mysql_fetch_array($strPrice1); 
echo (int)$_strPrice['id'];
Salil
A: 

But the result is "0". How can I get the number?

Really?

When I run:

print (int)('54 - Rian Ree Barrientos') . "\n";

I get 54

(php v 5.1.6)

Maybe $_GET['number'] doesn't contain what you think.

C.

symcbean