Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 I got some php questions...
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

SkinnyJ
Starting Member

21 Posts

Posted - 19 May 2002 :  01:36:40  Show Profile  Visit SkinnyJ's Homepage  Send SkinnyJ an AOL message
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  Show Profile  Visit Nathan's Homepage
includes in php are easy. Much nicer than asp

<?php include("file.txt") ?>

Nathan Bales
Snitz Exchange | Do's and Dont's
Go to Top of Page

SkinnyJ
Starting Member

21 Posts

Posted - 19 May 2002 :  10:31:28  Show Profile  Visit SkinnyJ's Homepage  Send SkinnyJ an AOL message
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>

Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 19 May 2002 :  15:29:59  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
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
Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 19 May 2002 :  15:48:06  Show Profile
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
Go to Top of Page

SkinnyJ
Starting Member

21 Posts

Posted - 19 May 2002 :  23:43:55  Show Profile  Visit SkinnyJ's Homepage  Send SkinnyJ an AOL message
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?

Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 20 May 2002 :  00:01:52  Show Profile  Visit Nathan's Homepage
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
Go to Top of Page

SkinnyJ
Starting Member

21 Posts

Posted - 20 May 2002 :  02:35:26  Show Profile  Visit SkinnyJ's Homepage  Send SkinnyJ an AOL message
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?

Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 20 May 2002 :  02:48:16  Show Profile  Visit Nathan's Homepage
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
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 20 May 2002 :  02:50:38  Show Profile  Visit Nathan's Homepage
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
Go to Top of Page

SkinnyJ
Starting Member

21 Posts

Posted - 20 May 2002 :  03:25:30  Show Profile  Visit SkinnyJ's Homepage  Send SkinnyJ an AOL message
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.

Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 20 May 2002 :  03:35:05  Show Profile  Visit Nathan's Homepage
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
Go to Top of Page

SkinnyJ
Starting Member

21 Posts

Posted - 20 May 2002 :  04:13:11  Show Profile  Visit SkinnyJ's Homepage  Send SkinnyJ an AOL message
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?

Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 20 May 2002 :  09:57:08  Show Profile  Visit Nathan's Homepage
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 1.2 seconds. Powered By: Snitz Forums 2000 Version 3.4.07