How can you populate data from an external text document, xml sh开发者_C百科eet or php MySql db? I'm using a MacPro, Dreamweaver CS4, Xampp & Php MySql Database. I'm open to suggestions as to what would be the easiest method for my setup.
example:
Text Doc: Where I would type the info. to be placed into the divs?
Item 1
id_1: 123456
pic_1: /imgs/phones/iphone4.jpg
Title_1: iphone4
price_1: $500
description_1: The New iPhone 4 now available for only $500
releasedate_1: 3/29/2011
Divs to be populated with corresponding data from txt sheet or xml sheet.
<div id="item_1">
<div id="pic_1"></div>
<div id="Title_1"></div>
<div id="price_1"></div>
<div id="description_1"></div>
<div id="id_1"></div>
<div id="releasedate_1"></div>
</div>
only reason I'm asking is because there will be many items listed on the page and of course I would like to make the process easier for editing the items.
You will need to decide how exactly you want to do this. XML or MySQL for housing the data is the most natural. Displaying the data can be done by JavaScript or PHP. It is pretty simple once you know what you are trying to accomplish and can articulate it.
Once you've made your connection, you could do something like this..
<?php
$sql = mysql_query("SELECT * FROM items");
while($result=mysql_fetch_array($sql))
{
$pic = $result['pic_1'];
echo "<div><img src='$pic'/></div>";
}
?>
精彩评论