Jump to content

Recommended Posts

hi all, dont know why this isnt working :(

 

Atm got an error on line 17 T_string expeting (

 

<?php

// connect to db


$num_fields= mysql_num_fields($query_result );
if ($num_fields) { //build the order by row
echo "<tr>" ; 
for ($i = 0; $i < $num_fields; $i++) {
$colname = mysql_field_name($query_result , $i) ;
//build a default header for both ascending and descending link
$orderlink = ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname . "&sort=desc\" title=\"Sort the records in descending order\">Sort descending</a>") ;
$orderlink .= "  " ;
$orderlink .= ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname . "&sort=asc\" title=\"Sort the records in ascending order\">Sort ascending</a>") ; 

if $_GET['columnname']== $colname {
if ($order=="asc") {
$orderlink = ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname ." &sort=desc\" title=\"Sort the records in descending order\">Sort descending</a>") ; // default replaced by single link
} else {
$orderlink = ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname . "&sort=asc\" title=\"Sort the records in ascending order\">Sort ascending</a>") ; 
}
}
echo ("<td>" . $orderlink . "</td>" ; // place each link-couplein a new cell
}
echo "</tr>" ;
} else {
echo "Empty recordset" ;
}
//and then here comes your code to display the records from the recordset.
while ($row = @mysql_fetch_array ($query_result)) {

echo " <tr align=\"center\" bgcolor=\"$row[colourcode]\"> 
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[CustomerID]</font></td>
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[Name]</font></td>
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[Address]</font></td>
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[Postcode]</font></td>
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[Telephone]</font></td>
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[Email]</font></td>
</tr>";

}

?>


Link to comment
https://forums.phpfreaks.com/topic/83296-anyone-debug-this/
Share on other sites

<?php

// connect to db


$num_fields = mysql_num_fields($query_result);
if ($num_fields) { //build the order by row
    echo "<tr>";
    for ($i = 0; $i < $num_fields; $i++) {
        $colname = mysql_field_name($query_result, $i);
        //build a default header for both ascending and descending link
        $orderlink = ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname .
            "&sort=desc\" title=\"Sort the records in descending order\">Sort descending</a>");
        $orderlink .= "  ";
        $orderlink .= ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname .
            "&sort=asc\" title=\"Sort the records in ascending order\">Sort ascending</a>");

        if ($_GET['columnname'] == $colname) {
            if ($order == "asc") {
                $orderlink = ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname .
                    " &sort=desc\" title=\"Sort the records in descending order\">Sort descending</a>"); // default replaced by single link
            } else {
                $orderlink = ("<a href=\"" . $_SERVER["PHP_SELF"] . "?columnname=" . $colname .
                    "&sort=asc\" title=\"Sort the records in ascending order\">Sort ascending</a>");
            }
        }
        echo "<td>" . $orderlink . "</td>"; // place each link-couplein a new cell
    }
    echo "</tr>";
} else {
    echo "Empty recordset";
}
//and then here comes your code to display the records from the recordset.
while ($row = @mysql_fetch_array($query_result)) {

    echo "<tr align=\"center\" bgcolor=\"$row[colourcode]\"> 
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[CustomerID]</font></td>
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[Name]</font></td>
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[Address]</font></td>
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[Postcode]</font></td>
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[Telephone]</font></td>
<td align=\"left\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#006699\">&nbsp$row[Email]</font></td>
</tr>";
}

?>

 

neat too.

Link to comment
https://forums.phpfreaks.com/topic/83296-anyone-debug-this/#findComment-423823
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.