Jump to content

Item catalogue


ThEMakeR

Recommended Posts

I really need some help from this community regarding a script/code (in php) for an item catalogue with the following fields:

id
name
description
image

I 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 key
item_name        Text                latin1_swedish_ci        NO
item_desc        Text                latin1_swedish_ci        NO
item_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!
Link to comment
https://forums.phpfreaks.com/topic/17622-item-catalogue/
Share on other sites

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 connection
while ($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.
Link to comment
https://forums.phpfreaks.com/topic/17622-item-catalogue/#findComment-75090
Share on other sites

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".
Link to comment
https://forums.phpfreaks.com/topic/17622-item-catalogue/#findComment-75094
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.