Hey guys, I have a database that I can't edit... a screenshot of it is attached. This db has a unique 'subscriber_id' for each person, and it stores their first name under 'field_id' 1 and the last name under 'field_id' 2.... if I'm saying that correctly. The attached image should help explain that. I want to query this database so that it outputs the first name and last name, then a <br> So far I have the following code (very simple): <?php $con = mysql_connect("localhost","xxx","xxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("pintmeis_pmsignup", $con); $result = mysql_query("SELECT `pm_subscriber_data`.* FROM pm_subscriber_data WHERE field_id='1'"); while($row = mysql_fetch_array($result)) { echo $row['value']; echo "<br />"; } mysql_close($con); ?> PHP: And this correctly displays the first name. But I have no idea how to make it display the last name. I tried this (and other variations of it): WHERE field_id='1' OR field_id='2' but this outputs the first name and last name on separate lines, and it orders the names wrong in many cases. I'm at a loss here... any help would be much appreciated. Thanks so much! I have this code executed on this page if it helps: http://www.pintmeisters.com/subscribers.php
I can't view the image due dp forum error or something!? If you can show me the table format (fields) i can help you!
Thanks EricBruggema, I've got it all figured out, except for one thing. I have this code now, and it's working good, but it doesn't put spaces between the first and last name: $result = mysql_query("SELECT `pm_subscriber_data`.* FROM pm_subscriber_data WHERE field_id IN (1, 2) ORDER BY subscriber_id ASC, field_id ASC"); $tags = array(1=>'<li>%s', 2=>'%s</li>'); echo "<ol style='margin-left:25px;'>"; while($row = mysql_fetch_array($result)){ printf($tags[$row['field_id']], $row['value']); } echo "</ol>"; PHP: I don't even know if getting spaces is possible w this code (i'm obviously not great with PHP), but this is how it looks now: http://www.pintmeisters.com/subscribers.php