Webmaster's Community
Designing and Development => Programming => Topic started by: Rahul Kaushik on December 03, 2011, 11:08:51 AM
-
i am facing problem to get id from data base i tried many time and code goes look like this
$id = ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) ? intval( $_GET['id'] ) : 0;
$id = ereg_replace('[^0-9]','',$_GET['id']);
$q="SELECT * FROM countdown Where id =$_GET[id]";
$result=mysql_query($q,$db);
$num=mysql_num_rows($result);
echo $num;
pls give a better way to complete it
rahul kaushik
-
Hi rahul,
you can work like this if you are working in any open source or home .
if(isset($_GET['id']) && preg_match('/^[0-9]{1,8}$/', $_GET['id']))
{
$Countdown = $_GET['id'];
$result = "SELECT * from table name where id= $Countdown";
hope it will work for you.....