php - PDO query not executing in while loop -


i tyring use pdo retrieve data database.

i can retrieve 'name' during first iteration not after 2nd iteration.

my code follows:-

while ($row = $stmt->fetch(pdo::fetch_assoc)) {    $id = $row["id"];    $query = "select name style_master id=$id";    $stmt = $db->query($query);    $style_name = $stmt->fetch(pdo::fetch_assoc)["name"];    echo $style_name; // first id name displayed next id onwards no style name displayed. } 

$stmt->fetch(pdo::fetch_assoc)["name"]; ?

  $style_name = $stmt2->fetch(pdo::fetch_assoc)["name"]; 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -