ThEMakeR Posted August 15, 2006 Share Posted August 15, 2006 I really need some help from this community regarding a script/code (in php) for an item catalogue with the following fields:idnamedescriptionimageI have made a database with those four fields in it:[b]field[/b] [b]Type[/b] [b]Collation[/b] [b]Null[/b] [b]Extra[/b]id int(11) NO auto_increment <id is primary keyitem_name Text latin1_swedish_ci NOitem_desc Text latin1_swedish_ci NOitem_img Blob NO^Hope thats clear enough peeps. Well I can make the database but I can't do the PHP code needed to display the contents of that database on a php page. Does anyone have any code or an example of a similar system I can use??Any help is much appreciated! Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 Well, here is the basic concept:[code]<?php//connect to your database$server = "localhost"; //most common$user = "user"; //database user$password = "password"; //database password$database = "database"; //database$connection = mysql_connect("$server","$user","$password"); $db = mysql_select_db("$database", $connection); ?><table width="100%"> <tr> <td>ID</td> <td>Item Name</td> <td>Item Description</td> <td>Item Image</td> </tr><?php$query = "SELECT * FROM table"; //select the results, be sure to change "table" to whatever your table is$result = mysql_query($query, $connection) or die(mysql_error()); //check the query and connectionwhile ($row = mysql_fetch_array($result)) { //loop through the results$id = $row['id'];$item_name = $row['item_name'];$item_desc = $row['item_desc'];$item_img = $row['item_img'];//echo the results?> <tr> <td><?php echo $id; ?></td> <td><?php echo $item_name; ?></td> <td><?php echo $item_desc; ?></td> <td><?php echo $item_img; ?></td> </tr><?php}?></table>[/code]That should give you the idea. From there you can make your changes etc. Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 15, 2006 Share Posted August 15, 2006 ^lol beat me to it. Speedy..Speedy.lol. I guess I should retake a typing class. Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 Lol, I've learned around here that if you want to be the first to answer, then you need to type fast. Which is one of the reasons I always find myself editing the code after posting it due to errors. Then I am thinking "Man, I hope the OP doesn't try this code before I fix the errors". Quote Link to comment Share on other sites More sharing options...
ThEMakeR Posted August 15, 2006 Author Share Posted August 15, 2006 Wow!That was mega quick and muchly appreciated! I will work on it now. See now that i've looked at it in the code (so to speak) I see how it all works but im damned if i'll ever learn how to do it myself :) 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.