contra10 Posted December 25, 2008 Share Posted December 25, 2008 is there a way to work around this code <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if (isset($_POST['submit'])){ if(is_numeric($_POST['grp'])){ $id = $_POST['grp']; $query= "SELECT * FROM groups WHERE id = $id"; $result = mysql_query($query) or die(mysql_error());; $group = mysql_fetch_assoc($result); $groupname = $group['name']; $insert = "INSERT INTO groups (user) VALUES ('$username') WHERE name = '$groupname'"; $add_group = mysql_query($insert) or die(mysql_error()); } else { echo $_POST['grp'] . ": Is not numeric..."; } ?> I need to upload information in a specific area but i can't user the where function Quote Link to comment Share on other sites More sharing options...
contra10 Posted December 25, 2008 Author Share Posted December 25, 2008 is there a way? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 25, 2008 Share Posted December 25, 2008 Not sure about anyone else, but I have no idea on what you are asking. Quote Link to comment Share on other sites More sharing options...
contra10 Posted December 25, 2008 Author Share Posted December 25, 2008 sry k I want to input into a row of one of my tables a value but in a specific row...a row is created before and I want to know if there is a way to upload into that same row a new variable without using the UPDATE syntax <?php $insert = "INSERT INTO groups (user) VALUES ('$username') WHERE name = '$groupname'"; ?> like i want the username to be uploaded in a specific row Quote Link to comment Share on other sites More sharing options...
contra10 Posted December 25, 2008 Author Share Posted December 25, 2008 please tell me if that is clear enough? Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 25, 2008 Share Posted December 25, 2008 try this psudo code. $insert="INSERT INTO groups (user) SELECT * FROM groups WHERE name='$groupname'"; Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 25, 2008 Share Posted December 25, 2008 Go to the bottom of this page, where i got the example from. http://dev.mysql.com/doc/refman/5.1/en/insert.html no nothing about it format, It wired but suppose to work. Quote Link to comment Share on other sites More sharing options...
contra10 Posted December 25, 2008 Author Share Posted December 25, 2008 that only inputted the username not in the row where i wanted it to be apart of othe values Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.