Hi friends, I think PHP is the greatest language right now; I know BASIC and I wrote a simple program, and I want to compare the BASIC program with a PHP program to learn how to do that using PHP, my basic program is this:
rem Ask for the name
input "Name: ",name$
rem open the file fro reading
open "myfile.txt" for output as #1
rem loop to read the whole file
while #1 <> eof
rem read a line
read #1,name1$,line$
rem compare the line with the supplied name, if is the same, show it
if name$=name1$ then print name$, line$
rem end the loop
wend
rem close the file
close #1
Thanks in Advance,
Jean
BASIC to PHP sample
Moderator: General Moderators
I'd start on the PHP manual. It's really well organized and usually includes helpful examples. I'm sure a quick google search for php tutorials would be informative, too. I don't know of any good tutorials off the top of my head, maybe someone else can point you to a good one.
hope this helps you out...
Code: Select all
<!--
rem Ask for the name
input "Name: ",name$
-->
<form action="" method="get" name="name" id="name">
Name:
<input type="text" name="name">
<input type="submit" name="Submit" value="Submit">
</form><?php
if ( isset($_GET['name']) && $_GET['name'] != "" ) {
//rem open the file for reading
$fp = fopen("myfile.txt", "r"); // open "myfile.txt" for output as #1
//rem loop to read the whole file
while( ! feof($fp) ) { // while #1 <> eof
// rem read a line
$line = fgets($fp); // read #1,name1$,line$
//rem compare the line with the supplied name, if is the same, show it
if ( strstr($line, $_GET['name']) ) // if entered name is in line then
echo $line; // print name$, line$
} // rem end the loop (wend)
// rem close the file
fclose($fp); //close #1
}
?>-
jhendrickx
- Forum Newbie
- Posts: 3
- Joined: Mon Jun 16, 2003 3:24 pm