开发者

PHP GET number query

Hi to all!

I have a query 开发者_如何学Pythonthat 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?


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.


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'];


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜