If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Radio button selection based on mysql query result.

Hi,

In my page i am displaying the record in a table and there is one edit button in table which will fill the Form on same page with selected table row, all the text boxes are populating after clicking the edit button in table but radio button option is not selected/checked.

Why are you making it harder to maintain and develop by putting the static scripting in the markup? I don't know what you are using to wrap your database accesses, but it looks like a waste of memory as I suspect that $res is being filled with the complete result set. (try to avoid doing that! Pass the result handler, NOT the result!)... and that markup... This is 2014 not 1997, what's with the FONT tags, CELLPADDING, BORDER, ALIGN and TARGET attributes, and host of other things that are a decade and a half out of date? (and a guaranteed waste of bandwidth in the age of CSS!)

On the PHP side why are you using multiple echo to do the job of one? Why do you have an outer table that will only ever have one TD (that's a DIV's job -- assuming there should even BE a wrapper). Where are your LABEL on the form? What makes that form tabular data?

Why are you using target="_SELF" when that's the default behavior? Again, not that you should be using TARGET in the first place!

Much less all the hidden ID that only seem to serve a purpose for scripting, in which case output them as scripting.

Worse though, you seem to be setting up to output multiple rows. If in those rows they all get the same 'name' inside the same form, how is anything except the first row even supposed to work? I'd consider using (textContent || innerText) on the TD instead of using hidden inputs for that. Then it would be a simple dom-walk that you could easily automate.

Basically, about a third to half your HTML belongs in the trash can as unneccessary bloat, and what you are trying to do with the scripting makes no sense for what your multiple rows of output is.

You should probably also learn what THEAD, TBODY, CAPTION and TH are for, and how to use them.

I gave you the exact code - just change the names to fit your project.

And what exactly is this project? School work? Or 'real' work? If it's real work, then you may have misrepresented yourself to your employer. If it's school work, well, you're supposed to be learning so do some work and learn!

it will be helpful if you can provide a sample code to add, edit and delete data from mysql on same page in a single form and display the stored data in a grid with radio button for selection and the selected record get filled in the above form to edit or delete.

I have searched for the above but couldn't find any tutorial or sample for that.

It seems that besides demonstrating your inability to write proper English, you are also letting us know that you don't have a clue as to how to write proper PHP either, and furthermore don't even want to bother to learn how to do it. Therefore I have no interest in any further conversation with you.

This forum is about helping those with an interest in php programming. You seem to only have an interest in a goal, not learning how to get there. Too bad for you.