DrTrans Posted August 24, 2009 Share Posted August 24, 2009 Heres my Code: $query2 = "SELECT COUNT(*) FROM property WHERE Owner_ID = '$ownerid'"; $result2 = mysql_query($query2); if ($row2 = mysql_fetch_array($result2)) print"<b>Total Properties Owned:</b> ".$row2[0]; This right now displays Total Properties Owned: 3 now below it, how would i do a multiple select textarea box that shoes each property name. the column in the mysql database in the property table is "PropertyName" This has stumped me.. Thanks for your help. Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 24, 2009 Share Posted August 24, 2009 Just query all the records first. You can then use mysql_num_rows() to get the count. Also, any reason you are using $query2, $result2. Unless you are still using the previous query and result you are just creating more variables in memory I would also suggest separating the logic from the output. I assumed that there was a unique ID for the property records as well. PHP Logic <?php $query = "SELECT propertyID, PropertyName FROM property WHERE Owner_ID = '$ownerid'"; $result = mysql_query($query); $propertyCount = mysql_num_rows($result); $propertyOptions = ''; while ($row = mysql_fetch_assoc($result) { $propertyOptions = "<option value="{$row['propertyID']}">{$row['propertyname']}</option> "; } ?> Output Total Properties Owned: <?php echo $propertyCount; ?> <br /><br /> Select a property: <select name="property"> <?php echo $propertyOptions; ?> </select> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.