0

Ok so I have 3 tables

1.phone: id name manufacturerid osid

2.manufacturer manufacturerid manufacturername

3.os osid osname

How can i put the data from one of the tables (manufacturerid1 -> manufacturerid2 and osid1>osid2) to the the first one everytime i want to upload the first table...

I'm not even sure im asking the right question, all i want is to make a table for a manufacturer so when i display the manufacturer names, i click on one of the names and every phone that belongs to that manufacturer/os shows up.

Also how can i update the data through php (my full phone table is much longer with data that i dont need to have more tables to use)

This the script i used before realising i need tables for manufacuter(brand) and os(OperatingSystem) so that when i display them by one of them, more manufacturers of the same name wont pop up.

 <?php
 include 'connect.php';
 mysql_select_db("phone", $connect);


 $id = $_POST['ID'];
 $name = $_POST['name'];
 $stock = $_POST['stock'];
 $brand = $_POST['brand'];
 $operatingsystem = $_POST['operatingsystem'];
 $camera = $_POST['camera'];
 $handset = $_POST['handset'];
 $screen = $_POST['screen'];
 $connectivity = $_POST['connectivity'];
 $batterylife = $_POST['batterylife'];
 $memory = $_POST['memory'];
 $messaging = $_POST['messaging'];
 $soundformat = $_POST['soundformat'];
 $price = $_POST['price'];
 $flag= $_POST['flag'];

 $sql = "UPDATE phone SET name='$name', stock='$stock', brand='$brand',   operatingsystem='$operatingsystem', camera='$camera', handset='$handset', screen='$screen', connectivity='$connectivity', batterylife='$batterylife', memory='$memory', messaging='$messaging', soundformat='$soundformat', price='$price', flag='$flag' WHERE ID='$id' ";


 if (!mysql_query($sql,$connect))
 {
 die('Error: ' . mysql_error());
 }
 echo "<h1>1 record was just updated in the database.</h1>";

 mysql_close($con);

 ?>      
Snyckey
  • 1
  • 2

1 Answers1

0

"I'm not even sure im asking the right question, all i want is to make a table for a manufacturer so when i display the manufacturer names, i click on one of the names and every phone that belongs to that manufacturer/os shows up."

In that case to make things easy on yourself, have one table called phones, one table called manufacturer and one table that links the phone to the manufacturer (and possibly another table for O/S ?)

Manufacturer table:
manufacturerID
name
otherData
moreData

Phone table:
phoneID
name
phoneData

OS Table:
osID
name
osData

Link Table:
phoneID
osID
manufacturerID

Perform all of your searches on the link table, then simply retrieve the information you want from the other tables.

RobStevo
  • 153
  • 6
  • Okay i guess that will help me but...my main problem is that i dont know how to get the info from the link table manufacturerID to get it from the manufacturer table so it gets the information about a certain phone(phone table) :( – Snyckey Feb 07 '13 at 03:26