Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user = '*';
- $pass = '*';
- $host = 'localhost';
- $dbName = '*';
- mysql_connect($host, $user, $pass) or exit('Unable to connect to MySQL');
- mysql_select_db($dbName) or exit('Could not select db');
- $sql = 'SELECT * FROM categories';
- $res = mysql_query($sql);
- $categories = array();
- while($row = mysql_fetch_assoc($res)){
- $categories[] = $row;
- }
- $sql2 = 'SELECT * FROM manufacturers';
- $res2 = mysql_query($sql2);
- $manufacturers = array();
- while($row2 = mysql_fetch_assoc($res2)){
- $manufacturers[] = $row2;
- }
- ?>
- <html>
- <head>
- <title>New product</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <link rel='stylesheet' href='css/main.css'>
- </head>
- <body>
- <div>
- <a href ="categories.php">Categories</a> |
- <a href ="manufacturers.php">Manufacturers</a> |
- <a href ="products.php">Products</a>
- </div>
- <hr />
- <form action="product-insert.php" method="POST">
- <table>
- <tr>
- <td>Name</td>
- <td><input type="text" name="name" /></td>
- </tr>
- <tr>
- <td>Description</td>
- <td><textarea name="description" rows="10" cols="100"></textarea></td>
- </tr>
- <tr>
- <td>Category name</td>
- <td>
- <select name='categoryID' >
- <?php foreach( $categories as $category)?>
- <option value="<?php echo $category['id']?>"> <?php echo $category['name'] ?></option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Manufacturer name</td>
- <td>
- <select name='manufacturerID' >
- <?php foreach( $manufacturers as $manufacturer)?>
- <option value="<?php echo $manufacturer['id']?>"> <?php echo $manufacturer['name'] ?></option>
- </select>
- </td>
- </tr>
- <tr>
- <td colspan="2"><input type="submit" name="submit" value="Submit" /></td>
- </tr>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment