cbolton74 Posted January 14, 2013 Share Posted January 14, 2013 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 Quote Link to comment Share on other sites More sharing options...
Christian F. Posted January 14, 2013 Share Posted January 14, 2013 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. Quote Link to comment Share on other sites More sharing options...
cbolton74 Posted January 14, 2013 Author Share Posted January 14, 2013 Ok Thanks a lot, I will start looking up links and how to add variables. Thanks Again Chris Quote Link to comment Share on other sites More sharing options...
cbolton74 Posted January 14, 2013 Author Share Posted January 14, 2013 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 Quote Link to comment Share on other sites More sharing options...
cbolton74 Posted January 14, 2013 Author Share Posted January 14, 2013 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 Quote Link to comment Share on other sites More sharing options...
Christian F. Posted January 15, 2013 Share Posted January 15, 2013 You've used single quotes around the string that prints out the URL, which means that variables will not be parsed inside of it. You need to terminate the string, and concatenate the variable to it. Just like you've done with the $pupilID variable. Quote Link to comment Share on other sites More sharing options...
cbolton74 Posted January 15, 2013 Author Share Posted January 15, 2013 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 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.