ok well ive managed to do PHP script to insert data into the database e.g. stock codes, descriptions and price. i have then created scripts to print this information onto the page. I normally have to manually add in the HTML & PHP for each item in order for the information to be displayed on a page i was wondering how would i do it so it dynamically adds in the HTML & PHP so the new items can be displayed on the screen without doing it manually i kinda guess you would use MYSQL to store the HTML but i can't find any good examples to learn of. if anyone could possibly guide me in the right way that would be great.
you can take reference from php.net website Here you found complete documenation in doc file just download and start study.. You will get so many exampe in that documentation It's really help to learn how to manipulate dynamic text............
the idea that i have about it is that i would use a loop for so each stock item found i would echo the HTML code, but im not to sure if this wld be the best way to do it.
it's called database bro... the general way to make it work in php is using a form to submit. then, process it by retrieving the form variables using $_GET and store it using mysql_query
i just want a example which would like basically loop through all of the item codes in the database and then echo the html each time, and then just once it has run out of stock codes. obviously i dnt want people to do it for me just a small example i can do the rest myself.
i usually use combination of mysql_query, "while" loop and mysql_fetch_assocc. the example on php.net is clear... just enter the mysql section.
Hi, Below is a small PHP script you can use: - I assume that the name of the table is prod_table and it has following fields - stock_code, desc and price. The PHP script below will fetch all the records from this table and show it on the screen <? $qstr = "select * from prod_table"; $qry = mysql_query($qstr); while ($arr = mysql_fetch_assocc($qry)) { echo "Stock Code: " . $arr["stock_code"] . "<br>"; echo "Description: " . $arr["desc"] . "<br>"; echo "Price: " . $arr["price"] . "<br>"; } ?> Hope this helps. -Maneet
I'm guessing what you are looking for is a template engine, have you looked at http://smarty.php.net ?
thanks that helped i got this working. <?php $query = "SELECT * from stock"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { echo "<div id=\"test\" style=\"height: 50px; width: 100px;\">" .$row["item_code"] .$row["item_desc"] ."</div><br>"; } ?> Code (markup):