Echo table td not working

Discussion in 'PHP' started by tasos55, Jun 4, 2013.

  1. #1
    Hello, i cant understand what the problem is .... when i add the css file you cant see what i echo out but only the tables and when i delete the css file everithing work fine...

    Here is the php file. maybe something is wrong here..
    $sql = "SELECT * FROM producten";
    $myData = mysql_query($sql,$con);
     
    echo '<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
                    <tr>
                        <th class="table-header-check"><a id="toggle-all" ></a> </th>
                        <th class="table-header-repeat line-left minwidth-1"><a href="">Product</a>    </th>
                        <th class="table-header-repeat line-left minwidth-1"><a href="">Categorie</a></th>
                        <th class="table-header-repeat line-left"><a href="">Beschrijving</a></th>
                        <th class="table-header-repeat line-left"><a href="">Nr</a></th>
                        <th class="table-header-repeat line-left"><a href="">Prijs</a></th>
                        <th class="table-header-options line-left"><a href="">Options</a></th>
                    </tr>';
    while($record = mysql_fetch_array($myData)){
     
    echo "<tr>";
    echo '<td><input  type="checkbox"/></td>';
    echo "<td>" . " " . $record['Product'] ." </td>";
    echo "<td>" . " " . $record['Item'] . " </td>";
    echo "<td>" . " " . $record['Description'] . " </td>";
    echo "<td>" . " " . $record['Extra'] . " </td>";
    echo "<td>" . " " . $record['Valuta'] . " </td>";
    echo "<td>" . " " . $record['Price'] . " </td>";
    echo "</tr>";
     
    }
     
     
    echo "</table>";
     
    mysql_close($con);
     
    ?>
    PHP:
    Thanks for any help.
     
    tasos55, Jun 4, 2013 IP
  2. jscg

    jscg Well-Known Member

    Messages:
    161
    Likes Received:
    5
    Best Answers:
    3
    Trophy Points:
    108
    Digital Goods:
    2
    #2
    Describe better your problem, i cant really understand it.
     
    jscg, Jun 4, 2013 IP
  3. Root Scope

    Root Scope Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Why are you posting your PHP file instead of CSS then?
     
    Root Scope, Jun 4, 2013 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4



    This.

    Also, if adding a CSS file makes things disappear, it's probably a good idea to look at the CSS code first.
     
    nico_swd, Jun 4, 2013 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    Unless of course how you include the CSS echo'ing out link is broken... but really as others have said we need to see more...

    Though what you have is a needlessly pointlessly convoluted mess of garbage... using multiple echo for nothing, multiple string additions for nothing, endless pointless classes for nothing, attributes like BORDER that have no business in any HTML written after 1997, etc, etc... Big tip, if the majority of your items inside a single parent are all getting the same class, none of them should have that class -- only apply classes when things are DIFFERENT. (A lesson the nitwits over at turdpress seem to refuse to learn)

    Much less the use of the mysql_ functions which we've been told for EIGHT YEARS to stop using, and that they FINALLY added giant red warning boxes to the manual further emphasizing the point. (that everyone seems to still be ignoring)

    /* assuming $db is a connected PDO object */
    
    $statement = $db->query('
    	SELECT * FROM production
    ');
    
    echo '
    	<table id="productTable">
    		<thead>
    			<tr>
    				<th scope="col" class="toggle"><a id="toggle-all" href="#"></a></th>
    				<th scope="col" class="minimum1"><a href="#">Product</a></th>
    				<th scope="col" class="minimum1"><a href="#">Categorie</a></th>
    				<th scope="col"><a href="#">Beschrijving</a></th>
    				<th scope="col"><a href="#">Nr</a></th>
    				<th scope="col"><a href="#">Prijs</a></th>
    				<th scope="col" class="options"><a href="#">Options</a></th>
    			</tr>
    		</thead><tbody>';
    			
    while ($row = $statement->fetch()) {
    	echo '
    			<tr>
    				<td><input type="checkbox"/></td>
    				<td>',$row['Product'],'</td>
    				<td>',$row['Item'],'</td>
    				<td>',$row['Description'],'</td>
    				<td>',$row['Extra'],'</td>
    				<td>',$row['Valuta'],'</td>
    				<td>',$row['Price'],'</td>
    			</tr>';
    }
    
    echo '
    		</tbody>
    	</table>';
     
    ?>
    Code (markup):
    At least cleans up what you have shown us so far.
     
    deathshadow, Jun 4, 2013 IP
  6. Sir-Mammad

    Sir-Mammad Active Member

    Messages:
    148
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #6
    Add this in END of your css file :

     
    Sir-Mammad, Jun 4, 2013 IP
  7. Rajeev Reddy G

    Rajeev Reddy G Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #7
    tasos55

    When you are writing html code inside PHP remember that wherever "=" comes you need to be careful woth the syntax.
    For Example:

    if your code is
    <th class="table-header-check"><a id="toggle-all" ></a> </th>
    Code (markup):
    Your code when writing inside the PHP should be like this:
    <th class=\"table-header-check\"><a id=\"toggle-all\" ></a> </th>
    Code (markup):

    Your Code after Modification is as follows:

    $sql = "SELECT * FROM producten";
    $myData = mysql_query($sql,$con);
     
    echo '<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" id=\"product-table\">
                    <tr>
                        <th class=\"table-header-check\"><a id=\"toggle-all\" ></a> </th>
                        <th class=\"table-header-repeat line-left minwidth-1\"><a href=\"\">Product</a>    </th>
                        <th class=\"table-header-repeat line-left minwidth-1\"><a href=\"\">Categorie</a></th>
                        <th class=\"table-header-repeat line-left\"><a href=\"\">Beschrijving</a></th>
                        <th class=\"table-header-repeat line-left\"><a href=\"\">Nr</a></th>
                        <th class=\"table-header-repeat line-left\"><a href=\"\">Prijs</a></th>
                        <th class=\"table-header-options line-left\"><a href=\"\">Options</a></th>
                    </tr>';
    while($record = mysql_fetch_array($myData)){
     
    echo "<tr>";
    echo '<td><input  type=\"checkbox\"/></td>';
    echo "<td>" . " " . $record['Product'] ." </td>";
    echo "<td>" . " " . $record['Item'] . " </td>";
    echo "<td>" . " " . $record['Description'] . " </td>";
    echo "<td>" . " " . $record['Extra'] . " </td>";
    echo "<td>" . " " . $record['Valuta'] . " </td>";
    echo "<td>" . " " . $record['Price'] . " </td>";
    echo "</tr>";
     
    }
     
     
    echo "</table>";
     
    mysql_close($con);
     
    ?>
    Code (markup):
     
    Rajeev Reddy G, Jun 19, 2013 IP
  8. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #8
    Please, PLEASE tell me you don't actually write code that way!!! That is the UGLIEST, DUMBEST way to build an echo; Take a look at what I did -- if you use single quotes to open and close the echo, you don't need ANY backslash escaping of doubles -- that train wreck of slashes you put in is a painful disaster of code... and for nothing since apparently you are USING single quotes, so there is NO legitimate reason to be escaping the doubles!!!
     
    deathshadow, Jun 19, 2013 IP