Im using a php include and i want to limit how much is shown at the first page:
1.php
<?php include('dynpage/some_text.htm'); ?>
2.htm
<p style="margin-left: 80px;"> <strong>some title nr.1</strong></p>
<p>Some text nr.1</p>
<strong>some title nr.2</strong>
<p><strong>NB!</strong>some really long text</p>
i want that "1.php" is showing only "some title nr.1" and "Some text nr.1"
i tried different codes i found from internet but none of them worked.
Thank you
I believe you will have to make the logic to display limited data on 2.htm (I suggest make it a php file).
Pass a parameter to the second php file and based on it display the data.
Something like include file like "2.php?showless=true"
On 2.php write.
$showless = $_GET['showless']
if($showless =='true'){
echo // what you want to show
}{
echo // for other cases show everything.
}
Related
I added a simple PHP echo tag on my website:
<?php echo "Test"; ?>
This message should be displayed above the header (which has a green background. The header moves a little, but I can't see the text "Test".
Then I tried this code:
<?php echo "<h1>Test</h1>"; ?>
Again, the header moves a little more, but the text is invisible.
First:
After the normal echo tag:
After adding h1:
Can you help me?
Your PHP echo needs to be inside the HTML body element to be displayed on the page. Everything else you see is a result of the browser attempting to correct invalid HTML (which can look very different between different browsers).
I have a very simple php script, of which is made to read the content of a file and then print it out on the site, using the method "readfile();" Here below you can see my code.
<?php
$readThisFile = './myFile.txt';
readfile($readThisFile);
?>
Now my question is whether it is possible to change the color of the text outcome, of which is visible on the website page. To give an example, once the php method has run and read my file and it outputs "hello world" on the site, because that is whats inside. Then the output is in black like any regular text, I was wondering whether it is possible to change that outcome to white or alike so that it is "invisible" on a white page.
I have seen it is possible to do this if the content which is on the site is "echoed" and not "read" like below here.
<?php
echo '<span style="color:white; align:center;">Hello World!</span>';
?>
But if that is possible to do with "readfile();" as well, I am not completely sure how I would implement it.
You can always do this:
<?php
$readThisFile = './myFile.txt';
echo `<span style="color:white; align:center;">`
readfile($readThisFile);
echo '</span>';
?>
Put the read text inside other element :)
I want a div code to read a .txt file from a certain folder and it will display the .txt content on the div code.
E.I: If i upload a thisisatest.txt, with the contents of "This is a test" Date:"Whatever the date is" and the div will see that i uploaded the file to the said folder and it will display "This is a test, date posted: Whatever the date is". It will also display all the original .txts.
Currently i am using:
<?php
echo file_get_contents("test.txt");
?>
It is working fine but i need it to see that if i post something lie {date} and the text following it will be displayed differently.
Any help?
Thanks.
The simplest way would be using PHP inside your HTML code.
file_get_contents function will read the content of the file as it is.
nl2br will transform new lines to br for proper display in HTML.
<div>
<?php
echo nl2br(file_get_contents(path_to_your_file));
?>
</div>
I have an application that returns data to a PHP/HTML file but the issue is it can call my application many times per page load:
An example HTML file with my calls only asking for images:
<img border="0" alt="" src="http://mydomain.com/test/index.php?element=1"></img>
</br>
<img border="0" alt="" src="http://mydomain.com/test/index.php?element=2"></img>
</br>
<img border="0" alt="" src="http://mydomain.com/test/index.php?element=3"></img>
</br>
This works fine every time and all of the images are returned, however my trouble starts when I want to return text/html.
The server side code works fine:
header('Content-type: text/html');
ob_start();
echo $filepath;
ob_flush();
ob_end_clean();
$filepath contains some text or HTML such as, "Check out our <strong>NEW</strong> offers!"
All I want is to return the HTML text and allow it to be embedded within the page so that if they want:
<h1>Check out our <strong>NEW</strong> offers!</h1>
or
<p>Check out our <strong>NEW</strong> offers!</p>
It will work fine.
The problem is, which HTML Tag should I use to call for the data in the same way I use <img> for images?
I have tried <object>, `
` etc... but these are no good as all I want is the raw HTML data returned.
Using the Javascript load() is not good as it relies on the web page builder creating a function call for every time they want to get data.
You can't do it with HTML, you could use jQuery + AJAX.
You have to use Ajax. you cannot do it in html.
You can output it with PHP and then if you update the file it will update site wide without making changes everywhere. Is there a reason you want to do it this way and not just insert the code manually? This could cause problems with the caching of your pages depending on how dynamic they are.
newOffers.php
<?php
echo '<h1>Check out our <strong>NEW</strong> offers!</h1>';
?>
Then in your site source:
<p>Blah blah blah...</p>
<?php include 'newOffers.php'; ?>
<p>Click our new offers link above</p>
You can use an <iframe> for this, but this is not really ideal as the resizing is not done automatically.
Alternatively you can indeed use Ajax to change the code.
Either way: think about your reason for wanting to include the HTML like this instead of just returning this html code with the original return?
I have an interesting question, or atleast I think it is.
I have this website http://21-card-games.com/best/casino-reviews/casino-casino-titan.asp. You will see the image and below it the content.
Is it possible to combine the image with the text and left align the image and make the text flow next to the image.
The pages are all dynamically created, The content on the page is a variable that I import from a mysql db...
Here is some of the coding:
<div id="yui-main"><div class="yui-b"><?php echo $g_page_content2 ?><br />
<?php include($_SERVER['DOCUMENT_ROOT'].'/includes/standard_images_screenshot_1.php');?><?php echo $g_content_text1 ?>
<?php /* This is the second banner for this page */ include($_SERVER['DOCUMENT_ROOT'].'/includes/banners/'.$row_rs_settings['g_sites_affiliate_ads2'].'.php');?></div>
The $g_content_text1 is the variable that pulls in the text, and the '/includes/standard_images_screenshot_1.php' is the image. The include image file is part of a script that creates the image on the fly (imagick).
However this is more or less what I where thinking:
to create a regex that replaces the first occurance of <p> with this include($_SERVER['DOCUMENT_ROOT'].'/includes/banners/'.$row_rs_settings['g_sites_affiliate_ads2'].'.php' but I am not sure if the php will still execute if I do that...
Any ideas on how I can accomplish this would be appreciated.
I don't get it.
Why you want to create a regexp to let the text flow on the left of the image?
This is a css issue.
Just add float:left to the image.