1

I came across this question today. In the original version, the OP included a link to the relevant code instead of including it in the question. I asked the OP to put the code in the question, and he/she did so, but the spacing was weird. I was going to ask the OP to fix the spacing, but I saw in the rendered preview from the edit window that the preview differed from the actual post.

Edit window rendered preview: enter image description here

Actual Post:

enter image description here

Is there any particular reason the spacing is different between the preview and the real post?

I have seen this MSO post about previews not matching the real post, but that was about lists, not code blocks.

1 Answer 1

1

The person used TABs instead of 4 spaces for the PHP portion of the code. The tabs look fine in the editor, but become full-width tabs. I went ahead and replaced all the tabs with 4 spaces and removed the code snippet out.

Edit: The person used a mix of TABs and spaces. I assume the snippet thing didn't like this.

Edit 2: And THEN THE POST IMPLODED so now none of us can see the differences.

Original, in snippets.

        <head>
            <title>Desktop</title>
        </head>
        <body style="font-family:Arial;">
            <table border="1">
            <thead>
                <tr>
                    <td><strong>REG</strong></td>
                    <td><strong>VAS</strong></td>
                    <td><strong>SRS</strong></td>
                    <td><strong>ETA</strong></td>
                    <td><strong>CS</strong></td>
                </tr>
            </thead>
            <tbody>
            <?php
    			ini_set('display_errors', 1);
    			error_reporting(~0);

    			$serverName = “1.2.3.4”; //serverName\instanceName
    			$connectionInfo = array( "Database"=>”database”, "UID"=>”user”, "PWD"=>”password”);
    			$conn = sqlsrv_connect( $serverName, $connectionInfo);
    			

    			$sql = ("SELECT * FROM table WHERE AccountID = ‘12345’”);
    			$stmt = sqlsrv_query($conn, $sql);
    			if( $stmt === false) {
    				 die( print_r( sqlsrv_errors(), true) );
    			};

    			 if($row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)) {
                ?>
                    <tr>
                        <td style="text-transform:Uppercase"><?php echo $row[‘REG’]?></td>
    				
    <?php
    	IF ($row[“VAS”]=="Tick") {
    		echo "<td bgcolor=green; style=color:white;>";
    		echo "VAS “Complete;
    		echo "</td>";
    } ELSE {
    		echo "<td bgcolor=red>";
    		echo "VAS Incomplete”;
    		echo "</td>";
    } 
    ?>
    			
    <?php
    	IF ($row["Being_Serviced"]=="Tick") {
    		echo "<td bgcolor=green; style=color:white;>";
    		echo “SRS Complete”;
    		echo "</td>";
    } ELSE {
    		echo "<td bgcolor=red>";
    		echo “SRS Incomplete”;
    		echo "</td>";
    } 
    ?>

                        <td>
    <?php
    	IF ($row["ETA"]=="") {
    		echo "No ETA available";
    } ELSE {
    		echo $row["ETA"];
    } 
    ?>
    				</td>
                        
    <?php
    	IF ($row["Service_Complete"]=="Tick") {
    		echo "<td bgcolor=green; style=color:white;>";
    		echo “CS Complete”;
    		echo "</td>";
    } ELSE {
    		echo "<td bgcolor=red>";
    		echo “CS Incomplete”;
    		echo "</td>";
    } 
    ?>
                    </tr>
                <?php
                }
                ?>
                </tbody>
                </table>
        </body>
    </html>

Outside of snippet box:

    <head>
        <title>Desktop</title>
    </head>
    <body style="font-family:Arial;">
        <table border="1">
        <thead>
            <tr>
                <td><strong>REG</strong></td>
                <td><strong>VAS</strong></td>
                <td><strong>SRS</strong></td>
                <td><strong>ETA</strong></td>
                <td><strong>CS</strong></td>
            </tr>
        </thead>
        <tbody>
        <?php
            ini_set('display_errors', 1);
            error_reporting(~0);

            $serverName = “1.2.3.4”; //serverName\instanceName
            $connectionInfo = array( "Database"=>”database”, "UID"=>”user”, "PWD"=>”password”);
            $conn = sqlsrv_connect( $serverName, $connectionInfo);


            $sql = ("SELECT * FROM table WHERE AccountID = ‘12345’”);
            $stmt = sqlsrv_query($conn, $sql);
            if( $stmt === false) {
                 die( print_r( sqlsrv_errors(), true) );
            };

             if($row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)) {
            ?>
                <tr>
                    <td style="text-transform:Uppercase"><?php echo $row[‘REG’]?></td>

<?php
    IF ($row[“VAS”]=="Tick") {
        echo "<td bgcolor=green; style=color:white;>";
        echo "VAS “Complete;
        echo "</td>";
} ELSE {
        echo "<td bgcolor=red>";
        echo "VAS Incomplete”;
        echo "</td>";
} 
?>

<?php
    IF ($row["Being_Serviced"]=="Tick") {
        echo "<td bgcolor=green; style=color:white;>";
        echo “SRS Complete”;
        echo "</td>";
} ELSE {
        echo "<td bgcolor=red>";
        echo “SRS Incomplete”;
        echo "</td>";
} 
?>

                    <td>
<?php
    IF ($row["ETA"]=="") {
        echo "No ETA available";
} ELSE {
        echo $row["ETA"];
} 
?>
                </td>

<?php
    IF ($row["Service_Complete"]=="Tick") {
        echo "<td bgcolor=green; style=color:white;>";
        echo “CS Complete”;
        echo "</td>";
} ELSE {
        echo "<td bgcolor=red>";
        echo “CS Incomplete”;
        echo "</td>";
} 
?>
                </tr>
            <?php
            }
            ?>
            </tbody>
            </table>
    </body>
</html>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .