jandrews3 Posted May 30, 2011 Share Posted May 30, 2011 I need to update a particular table and there be a whole lot of field names. I'd like to do it without having to use them the same way you can access then like $row[12] after a "select" query. The standard for updating (at least how I write it) goes like this ... $query = "UPDATE linguistics SET welcome1='$var3', welcome2='$var4' WHERE language = '$lengua'"; Well, I'd like to do it where I don't have to name welcome1 and welcome2, but instead refer to their numerical position within the database. On a "select" query we can do this. Can this be done on an update? Something perhaps like ... $query = "UPDATE linguistics SET 3='$var3', 4='$var4' WHERE language = '$lengua'"; ... where 3 and 4 represent the 4th and 5th fields respectively. I know that this particular phrasing doesn't work because I've tried it, but surely there has to be something. This will save me LOTS of time. Thanks!! Link to comment https://forums.phpfreaks.com/topic/237917-mysql-update-without-field-names/ Share on other sites More sharing options...
mikesta707 Posted May 30, 2011 Share Posted May 30, 2011 while a numerical reference to a column in an update statement seems to be impossible, why don't you use arrays and a foreach loop to generate your list of columns to update for you Link to comment https://forums.phpfreaks.com/topic/237917-mysql-update-without-field-names/#findComment-1222573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.