Dynamic Links

Dynamic Links

orchid1orchid1 Posts: 18Questions: 0Answers: 0
edited August 2009 in General
Here's a problematic case
anybody have any idea how to implement links inside of the cells
here's my dillema
I pull information from mysql its the name of a bird "parrotX"
if I just wanted to display the name in the cell this would be fine
here is the code for that taken from the server_side_example.php

[code]
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$sOutput .= "[";
$sOutput .= "'".$aRow['birdLabel']."',"; //this works for displaying just the text inside the table cell
$sOutput .= "'".$aRow['birdName']."',";
$sOutput .= "'".$aRow['species']."',";
$sOutput .= "'".$aRow['family']."',";
$sOutput .= "'".$aRow['genus']."'";
$sOutput .= "],";
}
$sOutput = substr_replace( $sOutput, "", -1 );
$sOutput .= '] }';
[/code]

why does this not work

[code]

while ( $aRow = mysql_fetch_array( $rResult ) )
{
$sOutput .= "[";
$sOutput .= "'"."",$aRow['birdName'],""."',";
$sOutput .= "'".$aRow['birdName']."',";
$sOutput .= "'".$aRow['species']."',";
$sOutput .= "'".$aRow['family']."',";
$sOutput .= "'".$aRow['genus']."'";
$sOutput .= "],";
}
$sOutput = substr_replace( $sOutput, "", -1 );
$sOutput .= '] }';
[/code]



Anybody done this before??

Replies

  • orchid1orchid1 Posts: 18Questions: 0Answers: 0
    I think I have found a solution I'm not exactly sure how to incorporate it but I'll post back when I have more info
    this will probably help someone else out in the future
    in the script tags
    [code]
    "aoColumns": [
    null,
    { "sType": "html" }
    ]
    [/code]

    but I am not sure where to put it since my code already looks like this

    [code]


    $(document).ready(function() {
    $('#example').dataTable( {

    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "search/server.php"
    } );
    } );




    [/code]
  • orchid1orchid1 Posts: 18Questions: 0Answers: 0
    any ideas anybody??
  • allanallan Posts: 63,578Questions: 1Answers: 10,483 Site admin
    The basic idea is right - but there are two things wrong with this line:

    [code]
    $sOutput .= "'"."",$aRow['birdName'],""."',";
    [/code]
    1. You got commas rather than dots for the concatenation.
    2. The HTML it produces is invalid (with single quotes in the HTML rather than double.

    Regards,
    Allan
  • fliesflies Posts: 35Questions: 0Answers: 0
    edited August 2009
    [code]
    $sOutput .= "'".$aRow['birdName']."',";
    [/code]

    try that,

    as Allan said you had , instead of . for inserting rows record inside output:
    [code]
    $sOutput .= "'"."",$aRow['birdName'],""."',";
    [/code]
This discussion has been closed.