I need to show files that I have in a listing files and directories in mi < iframe >
This is my listinf files code:
$directorioInicial = "./";
$rep = opendir($directorioInicial);
echo "<ul>";
while ($todosArchivos = readdir($rep)) {
if ($todosArchivos != '..' && $todosArchivos != '.' && $todosArchivos != '') {
echo "<li>";
echo "<a href=" . $directorioInicial . "/" . $todosArchivos . " target='_blank'>" . $todosArchivos . "</a><br />";
echo "</li>";
}
}
closedir($rep);
clearstatcache();
echo "< /ul>";
I need to do click in the file that I show in my list and the file will be show in my frame, but I dont know how...At the momento I show the file in another page... But it's not what I need... Thank you...
This is my frame:
<iframe id="probando" src="<?php echo $url; ?>" scrolling="auto" height="700" width="800" marginheight="0" marginwidth="0" name="probando"></iframe>
Name a iframe and set that name in target attribute of the hyperlink.
Try this :
$directorioInicial = "./";
$rep = opendir($directorioInicial);
echo "<ul>";
while ($todosArchivos = readdir($rep)) {
if ($todosArchivos != '..' && $todosArchivos != '.' && $todosArchivos != '') {
echo "<li>";
echo "<a href=" . $directorioInicial . "/" . $todosArchivos . " target='probando'>" . $todosArchivos . "</a><br />";
echo "</li>";
}
}
closedir($rep);
clearstatcache();
echo "< /ul>";
<iframe id="probando" src="<?php echo $url; ?>" scrolling="auto" height="700" width="800" marginheight="0" marginwidth="0" name="probando"></iframe>
More : http://www.w3schools.com/html/html_iframe.asp
Related
I am trying to add a video tag if the PHP code receives it from a $_GET method.
The problem is in the 2nd echo
<?php
if($_GET['video1'] == NULL) {
}
} else {
$vid = $_GET["video1"];
echo '<video width="320" height="240" controls>';
echo '<source src=' . <?php echo $_GET["video1"]; ?> . ' type="video/mp4">';
echo '</video>';
}
?>
PHP is not recursively embeddable:
echo '<source src=' . <?php echo $_GET["video1"]; ?> . ' type="video/mp4">';
You are ALREADY in "php mode" with your echo statement.Therefore you cannot "go deeper" into php mode.
Why do you need such a hideously ugly convoluted statement anyways? Why can't you simply have
echo '<source src=' . $_GET["video1"] . ' type="video/mp4">';
?
Replace:
echo '<source src=' . <?php echo $_GET["video1"]; ?> . ' type="video/mp4">';
With:
echo '<source src=' . $_GET["video1"] . ' type="video/mp4">';
There is no need to nest PHP code clocks.
Hi,
when I click the folder that is in the first folder it just can't recognize what's in it.
What is it I'm doing wrong ?
<?php
$fil = new SplFileObject(__FILE__);
$dato = new DateTime();
$dato->setTimezone(new DateTimeZone('Europe/Copenhagen'));
$dato->setTimestamp($fil->getMTime()); // getMTime sidst modificeret
if($_GET) {
$path = $fil->getPath();
$path = $path . "/" . $_GET['mappe'];
} else {
$path = $fil->getPath();
}
$mappeinterator = new FilesystemIterator($path);
foreach ($mappeinterator as $fileinfo) {
$type = $fileinfo->isDir();
if(!$type){
echo '<div style="width: 648px; margin:0 auto;">';
echo '<div id="name">';
echo $fileinfo->getFilename();
echo '</div>';
echo '<div id="kb">';
echo $fileinfo->getSize() . ' kb' . '<br>';
echo '</div>';
echo '<div id="mo">';
echo 'Modified on';
echo '</div>';
echo '<div id="m">';
$modificeret = $dato->format('d-m-Y H:i:s');
echo $modificeret . '<br>';
echo '</div>';
echo '</div><br><br>';
} else {
echo '<div style="width: 648px; margin:0 auto;">';
echo '<div id="name">';
// ------------------------------------------------------
$m = $fileinfo->getFilename();
echo '<a href=op02.php?mappe=' . $m . '>';
echo $m;
echo '</a>';
echo '</div>';
// ------------------------------------------------------
echo '<div id="kb">';
echo $fileinfo->getSize() . ' kb' . '<br>';
echo '</div>';
echo '<div id="mo">';
echo 'Modified on';
echo '</div>';
echo '<div id="m">';
$modificeret = $dato->format('d-m-Y H:i:s');
echo $modificeret . '<br>';
echo '</div>';
echo '</div><br><br>';
}
}
?>
I have more folder in each folder just for the test.
But as you can see it does go further
You are using the directory of __FILE__ as base. You have to provide the whole path to your sub-subdir that means including MAPPE. Your directory is not C:\xampp\htdocs\AW\Filsystem\mappe3 but C:\xampp\htdocs\AW\Filsystem\MAPPE\mappe3. Therefore you should include the whole relative path in your link:
$m = substr($path."\\".$fileinfo->getFilename(), strlen(dirname(__FILE__))+1);
echo '<a href=op02.php?mappe=' . $m . '>';
But beware: using request vars for building a path could be a security problem.
I want to add three class for bottom of pagination where show page number , I used that in PHP but I can't figure out where to put class name inside of php echo to make work... because i'm getting errors...
class="box_one" for ... << Prev Page
class="box_two" for ... echo $thenumrows or $i
class= "box_three" ... Next Page >>
here is code...
<?php
if ($thenumrows != "")
{
echo "<br>";
if ($thecurrentpage > 1)
echo "<a href='". $_SERVER['PHP_SELF'] . "?cat= ". $theselectedcat ."&rows= "
. $thenumrows ."&page=". $thepreviouspage ."'>
<< Prev Page </a> "; for ($i=1;$i<=$totalpages;$i++)
{
if ($i == $thecurrentpage)
echo $i ." ";
else
echo "<a href='". $_SERVER['PHP_SELF'] ."?cat=". $theselectedcat ."&rows=".
$thenumrows ."&page=". $i ."'>$i</a> ";
}
if ($thecurrentpage < $totalpages)
echo "<a href='". $_SERVER['PHP_SELF'] ."?cat=". $theselectedcat ."&rows=".
$thenumrows ."&page=". $thenextpage ."'>Next Page >></a> ";
}
?>
please help thanks.
AM
I had to clean up your code. The classes are added to the a-tags:
if ($thenumrows != "") {
echo "<br />";
// Back
if ($thecurrentpage > 1) {
echo '<a class="box_one" href="'. $_SERVER['PHP_SELF'] . '?cat=' . $theselectedcat . '&rows=' . $thenumrows . '&page=' . $thepreviouspage . '"><< Prev Page</a> ';
}
// Paginating
for ($i=1; $i<=$totalpages; $i++) {
if ($i == $thecurrentpage) {
echo '<span class="box_two">' . $i .'</span> ';
}
else {
echo '<a class="box_two" href="' . $_SERVER['PHP_SELF'] . '?cat=' . $theselectedcat . '&rows=' . $thenumrows . '&page=' . $i . '">' . $i . '</a> ';
}
}
// Next
if ($thecurrentpage < $totalpages) {
echo '<a class="box_three" href="' . $_SERVER['PHP_SELF'] . '?cat=' . $theselectedcat . '&rows=' . $thenumrows . '&page=' . $thenextpage .'">Next Page >></a> ';
}
}
?>
I have this page that looks a little like this.
<div class="ecigcontainer">
<div class="backbutt"><?php include("php/back.php"); ?></div>
<div class="ecig"><?php include("php/ecig.php"); ?></div>
<div class="forwardbutt"><?php include("php/forward.php"); ?></div>
</div>
A back button that works like this.
<?php
if (isset($_GET["ecig"])) {
$back = $_GET["ecig"] - 1;
echo "<a href=\"?ecig=" . $back . "\">";
echo "<img src=\"images/ecigs/" . $back . ".png\" height=\"300px\" /></a>";
} else {
$back = $_GET["ecig"] - 1;
echo "<a href=\"?ecig=" . $back . "\">";
echo "<img src=\"images/ecigs/" . $back . ".png\" height=\"300px\" /></a>";
}?>
The forward button pretty much has the same code, and the display looks like this.
<div class="ecigpic">
<img src="images/ecigs/<?php include("php/ecigcounter.php"); ?>.png" height="400px" />
</div>
<div class="ecigdesc">
<?php
if (isset($_GET["ecig"])) {
include("ecigs/" . $_GET["ecig"] . ".php");
echo "<h3>" . $ecigname . "</h3>";
echo "<p>" . $ecigdesc . "</p>";
} else {
$_GET["ecig"] = 1;
include("ecigs/" . $_GET["ecig"] . ".php");
echo "<h3>" . $ecigname . "</h3>";
echo "<p>" . $ecigdesc . "</p>";
}?>
</div>
With the "ecigcounter" that does this.
<?php
if (isset($_GET["ecig"])) {
echo $_GET["ecig"];
} else {
$_GET["ecig"] = 1;
echo $_GET["ecig"];
}?>
But the whole reason for this question is, how to I make it so it only displays numbers 1-40? Kind of lost and can't really seem to figure it out, and put it where it needs to go.
All the it needed was
<?php
if (isset($_GET["ecig"])) {
if ($_GET["ecig"] == 1){
$back = 40;
echo "<a href=\"?ecig=" . $back . "\">";
echo "<img src=\"images/ecigs/" . $back . ".png\" height=\"300px\" /></a>";
} else {
$back = $_GET["ecig"] - 1;
echo "<a href=\"?ecig=" . $back . "\">";
echo "<img src=\"images/ecigs/" . $back . ".png\" height=\"300px\" /></a>";
}
} else {
$back = $_GET["ecig"] - 1;
echo "<a href=\"?ecig=" . $back . "\">";
echo "<img src=\"images/ecigs/" . $back . ".png\" height=\"300px\" /></a>";
}?>
This little script made the world.
if ($_GET["ecig"] == 1){
$back = 40;
echo "<a href=\"?ecig=" . $back . "\">";
echo "<img src=\"images/ecigs/" . $back . ".png\" height=\"300px\" /></a>";
This my code:
<?php
$lijstDoelmannen = mysql_query("SELECT * FROM Speler WHERE positie = 'Doelman' ORDER BY familienaam, voornaam");
$teller = 1;
while($rij = mysql_fetch_array($lijstDoelmannen))
{
if($teller < 5){
echo "<td><a href='spelerDetail.php?spelerId='" . $rij['id'] . "><img src='images/spelers/unknown.png' alt='' width='50' />
<br /><br />" . $rij["id"] . " " . $rij['familienaam'] . " " . $rij['voornaam'] . "</a></td>";
}
}
?>
The problem is that in the hyperlink the parameter spelerId = spaces (not filled in). If I echo $rij["id"], it gives me the right value.
You have a ' in the wrong spot in your href.
"...<a href='spelerDetail.php?spelerId='" . $rij['id'] . ">..."
This should be:
"...<a href='spelerDetail.php?spelerId=" . $rij['id'] . "'>..."
<a href='spelerDetail.php?spelerId='" . $rij['id'] . ">
You need to move the apostrophe:
<a href='spelerDetail.php?spelerId=" . $rij['id'] . "'>
It's currently ending the link, before the variable is added.
You can also do:
echo "<td><a href='spelerDetail.php?spelerId={$rij['id']}'
while($rij = mysql_fetch_array($lijstDoelmannen))
{
if($teller < 5){
echo "<td><a href='spelerDetail.php?spelerId='" . $rij['id'] . "><img src='images/spelers/unknown.png' alt='' width='50' />
<br /><br />" . $rij["id"] . " " . $rij['familienaam'] . " " . $rij['voornaam'] . "</a></td>";
}
}
?>
I prefer writing the above code this way to avid these types of issues:
while($rij = mysql_fetch_array($lijstDoelmannen)){
if($teller < 5){ ?>
<td><a href="spelerDetail.php?spelerId=<?php echo $rij['id'] ?>">
<img src="images/spelers/unknown.png" alt="" width="50" />
<br /><br /><?php echo $rij['id'] . " " . $rij['familienaam'] . " " . $rij['voornaam'] ?></a></td>
<?php }} ?>