Forum Moderators: coopster
Im not the ebst when it comes to explaining thngs so if you need any information mroe i'd be happy to give you it.
I have a database (That i did not create, Im just using it), that is laid out like this:
ID - itemno - elementname - elementdescription
-----------------------------------------------
1 - 998 - title - Brand new house!
2 - 998 - sqft - 807
3 - 998 - address - 1234 one lane
4 - 998 - features - Pool, sauna, backyard, basement
Now what I want to do is write a simple way of storing all of that info so that I can recall it by using something like:
echo $items['sqft']; and it will return 807.
I hope this makes sense.
Thanks!
Greg
---------------------------------------
If your pulling it from mysql just use it like you said...
CODE
$query = "SELECT elementname,elementdescription FROM table WHERE itemno = '998'";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo $row['elementname'] . " = " . $row['elementdescription'];
}
If your familiar with multidimensional arrays:
CODE
$query = "SELECT * FROM table";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $row['itemno'];
$elementname = $row['elementname'];
$items[$id][$elementname] = $row['elementdescription'];
}
Then you can address it as:
echo $items['998']['sqft'];