Jump to content

How to implement this?


raysefo
Go to solution Solved by boompa,

Recommended Posts

Hi,

I am new to PHP.So any help would be great. I would like to display a drop down list and a textbox on a page. This dropdown data will be populated from a textbox. What I would like to know is, 

how to:

  • parse a file and extact some data from a txt file which is on a server.
  • populate this dropdown on the page with the data
  • also I would like to display another data on the textbox according to the data selected on the drop down list 

and of couse how to test this script etc.

Best Regards.

Link to comment
Share on other sites

http://bit.ly/16FVsoK

http://bit.ly/16FVKvJ

 

No idea what you mean for the last one.

 

I appreciate your new but this applies to life. Go and do your own research and put the effort in yourself and you'll learn a lot more. Come back with a specific problem and we can assist.

 

If you want to know what a specific PHP function does, go to http://php.net/function_name where function_name is any function or even something similar and it'll explain everything.

 

To get you started on your first task:

  1. http://php.net/read
  2. http://php.net/fopen
  3. http://php.net/file_get_contents

Lots of options and ways you can do it. Each one will essentially get you to 1) Open the file, 2) Loop through its contents populating the dropdown.

Edited by cpd
Link to comment
Share on other sites

If you want to develop locally, which is generally what I do, you'll need to install a web server, PHP and potentially MySQL.

 

Just get the latest releases for each; each can be found at their respective home sites. Alternatively, you can install a package such as WAMP or XAMPP although they often take a while to update so you wont necessarily have the most recent version.

Edited by cpd
Link to comment
Share on other sites

hi cpd,

 

I installed WAMP and wrote some script like below;

<?php
$homepage = file_get_contents('d:\php\test.txt');


$kw = explode("\n", $homepage);
$totalNumRow = 0;
$totalAmount = 0;
 
for($i=0;$i<count($kw);$i++){
	
	
	if(substr($kw[$i], 0, 1) == "5")
	{
		echo $kw[$i];
		// echo "<br>";
		$totalNumRow = $totalNumRow + 1;
		
		$originalstring = $kw[$i];
        $delimiter = ",";
        if(strpos($originalstring,$delimiter) > 0){
                $outarray = explode($delimiter,$originalstring);
                // $variable1 = $outarray[0];
                $amount = $outarray[1];
				echo $amount;
				$totalAmount = $totalAmount + $amount;
        }
		
		echo "<br>";
	}
	
	
}
echo "<br>";
echo "Total records: ".$totalNumRow;
echo "<br>";
echo "Total amount: ".$totalAmount;

?>

It works OK for local file. But the problem is I couldn't manage to get the contents of the file which is on FTP. Is there a way to use file_get_contents on ftp files? 

 

Best Regards.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.