php - How do I process multiple results from a SQL query sharing a common ID? -
i'm failing miserably head around know ought simple, , unsure if solution lies in query or in processing result, struggling search i'm sure has been covered in post.
i'm working single mysql table, need able retrieve , process content shares common id. unfortunately, restructuring database isn't option.
here's simple select * contentid = '2' query returns:
|contenttype|contentid|content | -------------------------------------- |title |2 |<h1>title</h1>| |intro |2 |<p>intro</p> | |main |2 |<p>main</p> | what's correct way retrieve specific 'title', 'intro' or 'main' content?
thanks in advance.
$result = mysql_query("select * contentid = '2'"); $array = array(); while($rows = mysql_fetch_array($result,mysqli_assoc)){ $array[$rows['contenttype']] = $rows['content']; } you can use $array each content type
Comments
Post a Comment