So, I have some code that connects to sqlserver (microsoft) like this
$DispQuery = "select top 1
a.name as TableName,
b.name as Attribute,
c.name as DataType,
b.isnullable AllowNulls,
CASE WHEN d.name is null THEN 0 ELSE 1 END as PKey,
CASE WHEN e.parent_object_id is null THEN 0 ELSE 1 END as FKey,
CASE WHEN e.parent_object_id is null THEN '-' ELSE g.name END as RefTable
from sysobjects a
join syscolumns as b on a.id = b.id
join systypes as c on b.xtype = c.xtype left join (SELECT so.id,sc.colid,sc.name FROM syscolumns sc JOIN sysobjects so ON so.id = sc.id JOIN sysindexkeys si ON so.id = si.id and sc.colid = si.colid WHERE si.indid = 1) d on a.id = d.id and b.colid = d.colid
left join sys.foreign_key_columns as e on a.id = e.parent_object_id and b.colid = e.parent_column_id
left join sys.objects as g on e.referenced_object_id = g.object_id
left join sys.extended_properties as h on a.id = h.major_id and b.colid = h.minor_id
where a.type = 'U' and a.name = '".$_GET['tbl']."'";
$DispResult = sqlsrv_query( $conn, $DispQuery );
if( $DispResult === false) {die( print_r( sqlsrv_errors(), true) );}
while( $Row = sqlsrv_fetch_array( $DispResult, SQLSRV_FETCH_ASSOC) )
{
IF($Row['TableName']<>""){$RowTable= $Row['TableName'];}ELSE{$RowTable= " ";}
IF($Row['Attribute']<>""){$RowAttribute= $Row['Attribute'];}ELSE{$RowAttribute= " ";}
IF($Row['DataType']<>""){$RowDataType= $Row['DataType'];}ELSE{$RowDataType= " ";}
$RowAllowNulls= $Row['AllowNulls'];
$RowPKey= $Row['PKey'];
$RowFKey= $Row['FKey'];
$RowRefTable= $Row['RefTable'];
$RowDescription= $Row['Descr'];
ECHO "<TR>";
ECHO "<TD WIDTH='" . $ID_ColWidth . "' class='tablebody' style='border-bottom-style: solid; border-left-style: solid; text-align:center;'>".$RowCount."</TD>\n";
ECHO "<TD WIDTH='" . $TABLE_ColWidth . "' class='tablebody' style='border-bottom-style: solid; border-left-style: solid; text-align:center;'>".$RowTable."</TD>\n";
ECHO "<TD WIDTH='" . $ATTRIBUTE_ColWidth . "' class='tablebody' style='border-bottom-style: solid; border-left-style: solid; text-align:center;'>".$RowAttribute."</TD>\n";
ECHO "<TD WIDTH='" . $DATATYPE_ColWidth . "' class='tablebody' style='border-bottom-style: solid; border-left-style: solid; text-align:left;'>".$RowDataType."</TD>\n";
ECHO "<TD WIDTH='" . $ALLOWNULLS_ColWidth . "' class='tablebody' style='border-bottom-style: solid; border-left-style: solid; text-align:center;'>".$RowAllowNulls."</TD>\n";
ECHO "<TD WIDTH='" . $PKEY_ColWidth . "' class='tablebody' style='border-bottom-style: solid; border-left-style: solid; text-align:center;'>".$RowPKey."</TD>\n";
ECHO "<TD WIDTH='" . $FKEY_ColWidth . "' class='tablebody' style='border-bottom-style: solid; border-left-style: solid; text-align:center;'>".$RowFKey."</TD>\n";
ECHO "<TD WIDTH='" . $REFTABLE_ColWidth . "' class='tablebody' style='border-bottom-style: solid; border-left-style: solid; text-align:center;'>".$RowRefTable."</TD>\n";
ECHO "<TD WIDTH='" . $DESCR_ColWidth . "' class='tablebody' style='border-bottom-style: solid; border-left-style: solid; border-right-style: solid; text-align:center;'>".$RowDescription."</TD>\n";
ECHO "</TR>";
$RowCount = $RowCount + 1;
}
and the second I add this line to the SQL (after the Reftable row)
,
CASE WHEN h.value is null THEN '-' ELSE h.value END as Descr
it no longer displays rows. As a matter of fact the entire while statement and all the html that it echoes no longer shows up in the source code when I go to the page and view source. I take the same code and paste it into sql manager and I get results with no problems.
I am racking my brain trying to figure out how to problem solve this to no avail. Please let me know if anyone has any suggestions. Thanks in advance!