mysql - Passing variable in php -


the variable $q=$_get["q"]; passing correctly value "q" $query , echoing $row['year'].

however, not working while statement in same code.

while ($rows = $result2->fetch_array())  { $row0 [] = $rows['year'];             $row1 [] = $rows['month'];         $row2 [] = $rows['sales']; }  

if try type directly value after $_get work ( $q=2013; example )

can give me make while work $q=$_get["q"];

bellow complete code.

appreciate help

<?php $q=$_get["q"];  $mysqli = new mysqli('localhost','user','pswd','database');   /* check connection */ if (mysqli_connect_errno()) { printf("connect failed: %s\n", mysqli_connect_error()); exit();  }  $query = "select * table_test `year`='".$q."'";  $result = $mysqli->query($query);  if ($row = $result->fetch_array())  { echo "<td>" . $row['year'] . "</td>";  }     $result2 = $mysqli->query($query);  while ($rows = $result2->fetch_array())  { $row0 [] = $rows['year'];            $row1 [] = $rows['month'];        $row2 [] = $rows['sales'];  }      /* free result set */ $result->close();    $mysqli->close();   ?> 

$q=$_get["q"]; return null if don't have submit form method='get' or url of page not contain query string ?q=2013 www.example.com?q=2013.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -