Need PHP Help - Really hard

Hey guys,

I’m stuck in a weird situation. Heres what I have going on with my script. Please bare with me as this is really hard to explain.

I created a table for username, password, and shop for “Shop Owners”. I then created another table for username and password for “Normal Users”. But when I’m registering for a shop owner, I added a code that would add an extra row for every new shop to “Normal users” .

When filling out the registration form for “Normal Users”, they have to click on the checkboxes of the shops they have shopped at. To get all the latest shops, I run this PHP code.



<?php 

$result = mysql_query("SELECT * FROM shopowners");

while($row = mysql_fetch_array($result))
  {
  echo "<input type='checkbox' name='" . $row['Shop'] . "' value='1' /> - " . $row['Shop'];
  echo "<br />";
  }

?> 


Thats all well and nice but my problem is how would I go about inserting the values in the checkboxes to the “Normal Users” database. Because before, when creating the shop owners accounts, I made it so that everytime a new shop it added, it adds a row to the “Normal Users”.

Heres what I tried but it didn’t work.

     	$registerquerytwo = mysql_query("INSERT INTO normalusers (Username, Password, Name

$result = mysql_query("SELECT * FROM shopowners");

while($row = mysql_fetch_array($result))
  {
  echo  "," . $row['Shop'];
  }

) VALUES ('".$usernametwo."', '".$passwordtwo."', '".$name."'

$result = mysql_query("SELECT * FROM shopowners");

while($row = mysql_fetch_array($result))
  {
  echo  ",\\'\\".$" . $row['Shop'] . ".\\"\\';
  }

)");


If anyone has a clue about what I’m trying to do here, please help me out. I’d greatly appreciate it.

Thanks,

Why are you using 2 tables that are the same in the first place… read about database normalisation and create a table for usergroups :wink: