strange mysql and php behavior -
this strange question use query value database based on name name exist in database , if add new product grabs name on old products not
here db structure vaporama.be sql pdf
site demo http://vaporama.be
pphp code
try { $stmt = $db->prepare("select * category cat = 'product' order name asc"); $stmt->execute(); $category = $stmt->fetchall(pdo::fetch_assoc); foreach($category $cat) { $naam = $cat['name']; //subcats query en count $stmt2 = $db->prepare("select * products cat = :name group (merk) order name asc"); $stmt2->execute(array(':name' => $naam)); $count = $stmt2->rowcount(); //echo cats echo " <li class='dropdown'> <a class='dropdown-toggle' href='#'> {$naam} ({$count}) </a> "; $subcat = $stmt2->fetchall(pdo::fetch_assoc); //echo subcats echo "<ul class='dropdown-menu'>"; foreach($subcat $sub) { $stmt3 = $db->prepare("select * merken name = :merk order name asc"); $stmt3->execute(array(':merk' => $sub['merk'])); $merk = $stmt3->fetch(pdo::fetch_assoc); echo " <li><a href='//{$_server['server_name']}/merk?merk={$merk[id]}'>{$sub[merk]}</a></li> "; } echo "</ul>"; } } catch(exception $e) { echo '<h2><font color=red>'; var_dump($e->getmessage()); die ('</h2></font> '); }
so basicly should show , grab id not does
but if add new product , work more fun , code says group names should unic in dropdown see 2 time joyetech first 1 not contain id , second contains id ( 33 )
so why not group result , doesnt find need ? here db of working item ( id 33 ) , above non working item
id | name | merk
64 | test | joyetech
i not see difference ? greets powerchaos
Comments
Post a Comment