php - How do I output certain index values from a foreach array? -
this structure in database:
items |itemlink ---------------------- kill bill|kill bill link preman |preman link
this code:
$db = new pdo("mysql:host=$hostname;dbname=$database", $username, $password); $items = 'select items menus'; $itemlink = 'select itemlink menus'; $itemquery = $db->query($items); $linkquery = $db->query($itemlink); $fetchitem = $itemquery->fetchall(pdo::fetch_assoc); $fetchlink = $linkquery->fetchall(pdo::fetch_assoc); $merged = array_merge($fetchitem,$fetchlink); foreach($merged $entry) { foreach( $entry $key => $value ) { } }
from above code, how output items' datas?
using example above answer question
$result = mysql_query('select * names'); while ($row = mysql_fetch_array($result, mysql_assoc)) { echo $row["firstname"] . " " . $row["lastname"] . "<br>"; } mysql_close($conn); ?>
Comments
Post a Comment