i'm amateur when comes php, makes sense. have following foreach loop fetches of "credits" linked music artist using artist's id (mixer, producer, arranger, composer, etc). want able replace different credit names more "list friendly." attempt below works loops until hits credit not linked artist, stops.
<?php function getskills($id) { $query = "select c2a.credit_id, cr.credit_name `credit_to_artist` c2a inner join `credits` cr on cr.credit_id = c2a.credit_id inner join `artist` on a.artist_id = c2a.artist_id c2a.artist_id = $id group c2a.credit_id order cr.credit_name"; $res = mysql_query($query); while ($row = mysql_fetch_assoc($res)) { $skills[] = $row; } return $skills; } ?> <?php foreach (getskills($id) $skill): ?> <?php echo str_replace( array('arranger','mixer','producer','composer','engineer','mixer','recorder','vocalist','writer'), array('song arrangement','audio mixing','music production','music/vocal recording','song writing','singing/performance'), $skill['credit_name']); ?><br /> <?php endforeach; ?>
how go adding if statement code replaces "array" in result?
add check if $skill['credit_name']
array or not -
if(is_array($skill['credit_name'])) { // code }
Comments
Post a Comment