/    Sign up×
Community /Pin to ProfileBookmark

database generated forms

I have a questions that will take some explaining but should have a simple solution.
I create a form using info from a database. eg. I look for all rows with the title “teacher”. This might be rows 3, 8, and 14. My database might have a field called ‘class’. My form would then include three text fields named class_3, class_8 and class_14. I submit the form and query the database again the same way and get the same three rows (3,8, and 14). How can I update these database rows with the appropriate fields? I have tried using a do – while loop. While $row is equal to ‘3’ I want to get the value of $class_3. I tried this but it doesn’t work.

[code=php]mysql_query (“UPDATE database SET class=’$class_$row’ WHERE row=$row “);[/code]

‘$class_$row’ is not the right way to do this. I hope I explained this clear enough and that someone can give me a simple solution.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @kanuski spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...