Note that there are some explanatory texts on larger screens.

plurals
  1. POdynamic table raws, depending on the number of the content
    primarykey
    data
    text
    <p>This is my php code that connects me with another ftp server and shows me the content of it. It then puts the results in a table. However, I want the table to create a new tag after every third entry. I did try the following :</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;some crap&lt;/title&gt; &lt;style type="text/css"&gt; &lt;!-- @import url("style.css"); --&gt; &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;table id="gradient-style"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th colspan='99'&gt;folders&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tfoot&gt; &lt;tr&gt; &lt;td colspan='99'&gt;End&lt;/td&gt; &lt;/tr&gt; &lt;/tfoot&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;?php $ftpHost = 'xxx'; $ftpUser = 'xxx'; $ftpPass = 'xxx'; $startDir = 'logs'; $n = 0; if (isset($_GET['file'])) { // Get file contents (can also be fetched with cURL) $contents = file_get_contents("ftp://$ftpUser:$ftpPass@$ftpHost/$startDir/" . urldecode($_GET['file'])); // Get mime type (requires PHP 5.3+) $finfo = new finfo(FILEINFO_MIME); $mimeType = $finfo-&gt;buffer($contents); // Set content type header and output file header("Content-type: $mimeType"); echo $contents; } else { $dir = (isset($_GET['dir'])) ? $_GET['dir'] : ''; $conn = ftp_connect($ftpHost) or die("Could not connect, please refresh in 2 seconds"); ftp_login($conn, $ftpUser, $ftpPass); // change dir to avoid ftp_rawlist bug for directory names with spaces in them ftp_chdir($conn, "$startDir/$dir"); // fetch the raw list $list = ftp_rawlist($conn, ''); reset($list); while (list(, $item) = each($list)) { if(!empty($item)) { // Split raw result into pieces $pieces = preg_split("/[\s]+/", $item, 9); // Get item name $name = $pieces[8]; // Skip parent and current dots if ($name == '.' || $name == '..' || $name == 'index.html') continue; if($n%3 == 0){echo "&lt;tr&gt;";} // Is directory if ($pieces[0]{0} == 'd') { echo "&lt;a href='?dir={$dir}/{$name}'&gt;&lt;strong&gt;{$name}&lt;/strong&gt;&lt;/a&gt;&lt;td&gt;"; } // Is file else { echo "&lt;a href='displayer.php?file={$dir}/{$name}'&gt;{$name}&lt;/a&gt;&lt;td&gt;"; } $n++; } } } ftp_close($conn); ?&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>but I get a weird result <a href="http://ahstpc.6te.net/site/1.php" rel="nofollow">click here to see my page</a><br> what seems to be wrong in my code ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload