PHP Causing Problems with Table?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
carleihar
Forum Commoner
Posts: 36
Joined: Fri Nov 13, 2009 5:59 pm

PHP Causing Problems with Table?

Post by carleihar »

In most of my pages, I use an echo statement to display a table. In my header file, I have a div that displays a table with the users login information. For some reason the table isn't displaying like a table, instead its just a line. I just can't figure out what's wrong! Any help?

Code: Select all

<div class="login">
                        
                        
                        
                        <?
                        
                        include('config.inc.php');
                        require_once('mysqli_connect.php');
 
                        
                        if(!validate_login($_COOKIE['username'], $_COOKIE['password'])) {  
                              echo 'Sorry, you\'re not logged in. Go <a href="login.php">here</a>';
                              mysqli_close($dbc);
                              include ('includes/footer01.inc.php');
                              exit();  
                        } else {
                        
                            $EG = getUsersMoney();
                    
                        
                            echo'<table>
                                    <tr>
                                        <td><span class="loginBold">UN: </span></td>
                                        <td>' . $_COOKIE['username'] . '</td>
                                    </tr>
                                    <tr>
                                        <td><span class="loginBold">EG: </span></td>
                                        <td>' . $EG . '</td>
                                    </tr>
                                    <tr>
                                        <td><span class="loginBold"><a href="http://liveequian.com/logout.php">Logout</a></span></td>
                                    </tr>
                                </table>';
 
                        }
                        ?>
                        
                        
                        </div>
User avatar
F00Baron
Forum Newbie
Posts: 6
Joined: Sat Feb 20, 2010 11:43 am

Re: PHP Causing Problems with Table?

Post by F00Baron »

$EG must have some html that's messing with the table.
Also you should put

Code: Select all

<td colspan="2">
for the last row.
carleihar
Forum Commoner
Posts: 36
Joined: Fri Nov 13, 2009 5:59 pm

Re: PHP Causing Problems with Table?

Post by carleihar »

No, that doesn't work because it still doesn't display the table data even without both variables.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: PHP Causing Problems with Table?

Post by social_experiment »

Code: Select all

<?php echo '<table>
                                    <tr>
                                        <td><span class="loginBold">UN: </span></td>
                                        <td>Joe</td>
                                    </tr>
                                    <tr>
                                        <td><span class="loginBold">EG: </span></td>
                                        <td>' . $EG . '</td>
                                    </tr>
                                    <tr>
                                        <td><span class="loginBold"><a href="http://liveequian.com/logout.php">Logout</a></span></td>
                                    </tr>
                                </table>';?>
If you parse just the above code the table displays correct, so it's possible that something inside '$EG = getUsersMoney();' is adding additional markup to the html, throwing out the table (like F00Baron mentioned).

Could you paste the code for 'getUsersMoney()' ?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply