This is intented for learning purposes, feel free to study the code

Create a drawing that looks like this (pyramid)
The number should be incremented with the modulus.

just saw that i forgot a ' in $array['yourField1']

Something is not right in your logic.

$company_id = $_POST['company_id'];
$company_name = $_POST['company_name'];

// What do you do with these post`s ?

You do not close your form

A simple logic is this. Also try using PDO classes instead of the deprecated MySQL.


echo '<select name="yourName">';

while($arr = mysql_fetch_array($sql)) {
  echo '<option value="'.$arr['yourField1].'">'.$arr['yourField2'].'</option>';

echo '</select>';


Joins are good but i'm trying to use separate selects, it is faster sometimes especially for big tables.

I'll show you the simple MySQL version.

$sql = mysql_query("SELECT * FROM table1 WHERE id = '3'");

if(mysql_num_rows($sql) > 0) {
    $arr = mysql_fetch_array($sql);

    // you also can use different loops

    $sql = mysql_query("SELECT * FROM table2 WHERE id = '".$arr['id']."');
simplypixie commented: This is no use for what the OP is trying to do -2