auto generate link URL from database

auto generate link URL from database

tooncestoonces Posts: 15Questions: 2Answers: 0
edited April 2011 in General
Hi Alan. Love Datatables, it makes my life a lot easier. I am the dangerous kind of developer - self taught and non professional lol. I know just enough to frustrate myself :-) So hence my question :

I have successfully created a page that uses datatables to load a phpMysql dataset into a table using JSON. No problem at all there. What I need to do after this though is make it so that in each line there is a clickable button (form button or graphic, don't really care which) that when clicked generates a url based on which row was clicked. So for example, if the locID (my index field) in the clicked row is "22", I want it to generate a url similar to www.myurl.com/process.php?parameter=22" and navigate to it so that my php script can respond according to what row was clicked on. There seem to be complex ways of doing it that i have a hard time wrapping my head around... is there a simple way for us non experts? My problem is when I look at the example code, not being a java expert i don't really grasp what the most relevant lines are for me. For example I don't even know whether the best way would be to do it in the server_processing.php file, or client side. Thanks in advance for your help

Replies

  • tooncestoonces Posts: 15Questions: 2Answers: 0
    solved it thru stubbornness and mind numbing trial and error. For anyone else with the same problem this is what i did : I'm sure there's a more elegant way, but I went to about line 162 in the server_processing.php samle script provided with datatables, and inserted this in the previously commented out area :

    [code]

    $foobar3 = $aRow[ $aColumns[$i] ];
    $foobar1 = '';

    $row[] = $foobar1. '>'. $aRow[ $aColumns[$i] ] .'';

    [/code]

    this adds a link and the first part of the url up to where the variable needs to be, and then adds the column value, and then closes off the html syntax to make it a valid tag. Then when you view the page the column in question calls the "detail" page and passes the value to it for further processing. Hope it helps anyone in the same boat as me.
This discussion has been closed.