Author |
Topic  |
|
SkinnyJ
Starting Member
21 Posts |
Posted - 19 May 2002 : 01:36:40
|
Hey I am writing my first dynamic site with php and I need to be able to load a text file into an html/php document. I know the code for loading an image
echo '<img src="images/moo.jpg">';
but is there something similar for a text file?
|
|
Nathan
Help Moderator
    
USA
7664 Posts |
Posted - 19 May 2002 : 02:12:59
|
includes in php are easy. Much nicer than asp
<?php include("file.txt") ?>
Nathan Bales Snitz Exchange | Do's and Dont's |
 |
|
SkinnyJ
Starting Member
21 Posts |
Posted - 19 May 2002 : 10:31:28
|
Thank you very much. But I have one more question. If I want that text to word wrap and come in preformated what would I do? I have this currently on the page and it doesn't word wrap.
<pre class="mainText"><?php include("20020331.txt") ?></pre>
|
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 19 May 2002 : 15:29:59
|
when using the html tag pre, it will display the file just as it appears. if you want it to wrap then just remove the pre tags. you can use <font class="blah"> or <div class="blah"> instead of the pre to keep the same text style.
Brad Web Hosting with SQL Server @ $24.95 per month
|
 |
|
Roland
Advanced Member
    
Netherlands
9335 Posts |
Posted - 19 May 2002 : 15:48:06
|
Brad is right. Pre tags don't know automatic word wrap. The [code] and [/code] tags on the forums are actually pre tags so look at some of the coding examples shown in some posts and you'll see what pre tags really do.
Each line break like this will be shown as a line break, but if you type one long string of text it'll show the same way on your page. The problem with that is that if you design the site for a higher resolution than what your users have, they'll end up with a horizontal scroll bar.

http://www.frutzle.com
Snitz Exchange | Do's and Dont's |
 |
|
SkinnyJ
Starting Member
21 Posts |
Posted - 19 May 2002 : 23:43:55
|
Ok Thank you I got that working now I have another question. I am trying to get this code to work
<?php echo '<a href=$link><img src="Images/backward-up.jpg" width="150" height="35" border="0"></a>' ?>
The $link variable changes depending on the data of the page. Its a nav button to go back or forward. And I cant get the contents of that varible to come out in the url that the a href produces.
I use the same idea in this code so I thought it would work the same.
<?php
echo "<img src=$strip>";
?>
Any ideas?
|
 |
|
Nathan
Help Moderator
    
USA
7664 Posts |
Posted - 20 May 2002 : 00:01:52
|
In the post above you have two different echo statments, both containing variables.
The first one uses the single ' quotation mark to terminate the string, the second uses the double "
In php, when you use a single quote it designates a litteral string. In other words, the string will be taken as is, and not processed before being outputted, so the variable name does not get replaced with its value. A doubly quoted string however, is processed before being 'echoed' so when you use " to terminate a string variable names will be replaced with the variable value.
So, chage that line to this.
<?php echo "<a href=$link><img src='Images/backward-up.jpg' width='150' height='35' border='0'></a>" ?>
Nathan Bales Snitz Exchange | Do's and Dont's |
 |
|
SkinnyJ
Starting Member
21 Posts |
Posted - 20 May 2002 : 02:35:26
|
Thank you again. Since this seems to be getting me answers I will ask another question. This one seems odd to me.
I have the following code on a page.
<?php
if ($nav == 1) { $linkfor = "view.php?comic=" + $nav + 1; $linkback = $nav + "#"; $linkstar = $nav + "#"; } elseif ($nav > 1) { $linkfor = "view.php?comic=$nav" + 1; $linkback = "view.php?comic=$nav" - 1; $linkstar = 1; } elseif ($nav == 23) { $linkfor = $nav + "#"; $linkback = "view.php?comic=$nav" - 1; $linkstar = 1; } ?>
The first if statement is fine but then the second one when I type elseif ($nav > 1) anything after the > doesnt show up blue anymore in dreamweaver it just shows up black. Then nothing in that part of the statement works. I don't see what the problem is.
Any ideas?
|
 |
|
Nathan
Help Moderator
    
USA
7664 Posts |
Posted - 20 May 2002 : 02:48:16
|
I dont know if its what is causing your problems, but those lines are incorrect.
<?php
if ($nav == 1) { $linkfor = "view.php?comic=" + $nav + 1; $linkback = $nav + "#"; $linkstar = $nav + "#"; } elseif ($nav > 1) { $linkfor = "view.php?comic=" + $nav + 1; $linkback = "view.php?comic=" + $nav - 1; $linkstar = 1; } elseif ($nav == 23) { $linkfor = $nav + "#"; $linkback = "view.php?comic=" + $nav - 1; $linkstar = 1; } ?>
Nathan Bales Snitz Exchange | Do's and Dont's |
 |
|
Nathan
Help Moderator
    
USA
7664 Posts |
Posted - 20 May 2002 : 02:50:38
|
Also, in that format, ($nav == 23) will never happen because when $nav = 23 ($nav > 1) will be true, so the third part of the strcture will never be used, rearrage it like this.
<?php
if ($nav == 1) { $linkfor = "view.php?comic=" + $nav + 1; $linkback = $nav + "#"; $linkstar = $nav + "#"; } elseif ($nav == 23) { $linkfor = $nav + "#"; $linkback = "view.php?comic=" + $nav - 1; $linkstar = 1; } elseif ($nav > 1) { $linkfor = "view.php?comic=" + $nav + 1; $linkback = "view.php?comic=" + $nav - 1; $linkstar = 1; }
?>
Edited by - Nathan on 20 May 2002 02:51:12 |
 |
|
SkinnyJ
Starting Member
21 Posts |
Posted - 20 May 2002 : 03:25:30
|
Thank you Nathan. I realized the first one right after posting and the other problem I fixed by using elseif ($nav > 1 and $nav <22)
But I still dont know why the color of the text changes after that first >. It works now but the color is still off.
I would like to again thank everyone who helped me here. I was able to in 2 days teach myself enough php to make my site dynamic. Its a work in progress but check out the results so far.
http://www.rwwr.com
http://www.rwwr.com/archive.htm choose one of the comics and see what I did... Yea its nothing special but I am happy with it. Now I only have to upload a text file and a jpeg and change 4 variable to update the comic, instead of a whole new html doc.
|
 |
|
Nathan
Help Moderator
    
USA
7664 Posts |
Posted - 20 May 2002 : 03:35:05
|
Its been my experience that dreamweaver's php support is very lame, so I'm not supprised your having difficutly with the color parser.
May I recomend though, to keep your site simpel that you stay with either asp or php by either using a php forum or shifting the other over to asp. The reason I recomend this is that if you ever want to tie your site together, integraing the forum login stuff into your site or such, it will be much nicer if its all in the same language.
Nathan Bales Snitz Exchange | Do's and Dont's |
 |
|
SkinnyJ
Starting Member
21 Posts |
Posted - 20 May 2002 : 04:13:11
|
OK I will keep that in mind. I plan on writing my own forum in the future when I get more programing savy. Right now I am just trying to make my site easier to update and work with. I was wondering can I make my homepage index.php instead of index.htm or .html?
|
 |
|
Nathan
Help Moderator
    
USA
7664 Posts |
Posted - 20 May 2002 : 09:57:08
|
You have to open a readyhosting support ticket and request index.php to be added to your sites index list.
Nathan Bales Snitz Exchange | Do's and Dont's |
 |
|
|
Topic  |
|