adke001458 Posted September 16, 2014 Share Posted September 16, 2014 Hello,I have created a webpage that essentially generates an sql query and then puts the results into a table that is displayed.On one of the columns in this displayed table, I want to allow the user to click on each of the values which will in turn execute a php function. I have the hyperlink working but this is to a separate page.What I actually need to do is firstly - just ran a php function that will create a new table beneath the currently displayed one.Secondly, once this is achieved, I need to pass some value to the function so that the generated table is dependent on the value that was clicked.I've tried a few things and researched but I am struggling. I am a beginner.Any help would be greatly appreciated.Here is an extract of the code used for inputting data into the original table - showValuesSR is the function name<?phpwhile (!$rsMetrics->EOF) {?><tr><?phpfor ($x=0; $x<$numberOfFields; $x++) {if ($fieldNames[$x] == "Values_SR"){ ?><td><a href= ?showValuesSR><?php echo $rsMetrics->fields[$fieldNames[$x]]->Value?></a></td><?php }else{ ?><td><?php echo $rsMetrics->fields[$fieldNames[$x]]->Value?></td><?php}}?></tr><?php$rsMetrics->MoveNext();}?></table><?phpfunction showValuesSR(){?><table border="0" cellpadding="5" width="100%"><tr><tdbackground="../images/table_toolbar_bkg.gif" align="center"><font color="Blue" face="verdana" size="2"><strong>function working</strong></td></tr></table><?php}?> Quote Link to comment Share on other sites More sharing options...
BuildMyWeb Posted September 16, 2014 Share Posted September 16, 2014 welcome adke... a good first start would be to put this in a different forum. its not an HTML issue Quote Link to comment Share on other sites More sharing options...
Barand Posted September 16, 2014 Share Posted September 16, 2014 Mouse clicks are handled by the browser on the client after PHP has finished executing on the server so you cannot call a PHP function directly in response to a mouse event. If you don't want to go to another page then you need to use AJAX. You should Google AJAX to find out more but, basically, you use a javascript function to send a request message to a PHP script the server in response to the click. The script executes and sends data back to the calling function which then displays it on the page. 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.