Jump to content

Selectable Table Row


cbolton74

Recommended Posts

Hi, I have just started to learn html and php.

I have a webpage which retrieves a list of names from a table and adds them to a drop down list within a form. When a user selects a name and presses submit the name is then passed onto the the next php page which displays all the details.

I wanted to make it a little more fancy and so changed the drop down list to a table.

 

The question, is it possible to make the names or rows selectable so the program carries out the same task but instead the user selects a name in the table or a row?

The table is dynamic as more users are added or deleted from the system.

 

If any one could point me in the right direction please.

 

Thanks

 

Chris

Link to comment
Share on other sites

To answer your question: Yes, it's possible.

Generally, simple things like this is always possible. ;)

 

As for how it's done, it is as simple as just adding a link around the name. Making sure the link sends the same information to the server as the drop-down did. You might need to change the backend from $_POST to $_GET, but other than that there shouldn't be any changes necessary.

 

There is also some more advanced options with JS, but I recommend making it work with plain HTML first. JS can always be added on top of that later on, but it can be quite difficult going the other way.

Link to comment
Share on other sites

Ok I added the following code to my dynamically built table

 

<tr>

<td><font face="Arial, Helvetica, sans-serif"><?php echo $pupilID; ?></font></td>

<td><font face="Arial, Helvetica, sans-serif"><?php echo '<a href="startTest.php?link=' .$pupilID. '>$pupilName</a>';?></font></td>

<td><font face="Arial, Helvetica, sans-serif"><?php echo $pupilSurname; ?></font></td>

</tr

 

The link works and send across the correct info to the startTest.php page but the table does not dynamically fill in the $pupilName any more. I have tried echo $pupilName but still no joy.

 

Any ideas?

 

Thanks

 

Chris

Link to comment
Share on other sites

Sorry I realise I missed the " after .$pupilID. Ive added it and still the same problem. The lad in this forum seems to be having the same problem as me http://answers.yahoo.com/question/index?qid=20090202113421AAALF0A

Ive tried all the answers but none of them fills the column with the pupil names. I just get $pupilName repeated down the column instead.

 

Thanks Again

Link to comment
Share on other sites

Thanks for that I think I know what Ive done wrong now. The . is used to concatenate two strings so it has treat $pupilID as text instead of a variable. Don't even know why I had them in there, must have been late at night!

 

Thanks for all your help Christian!

 

Chris

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.