Forum Moderators: coopster

Message Too Old, No Replies

PHP manipulating results from other files

PHP manipulating results from other files

         

Imy_S3

12:35 am on Feb 15, 2004 (gmt 0)

10+ Year Member



Got two files

one is a .html
for example, this tells user to enter name

other is .php
this is the file that inserts the users name in the database and diplays the data.

got another .html file
i want to manipulate the disply results.
so for example i want to say if john was in the above resutls put it in to table blah.

problem being how do i manipulte the display results that were .php in my another.html file

Can anyone help?

Thanks in advance

mep00

8:52 am on Feb 15, 2004 (gmt 0)

10+ Year Member



Instead of using a .html file, have the .php dynamicly generate the HTML which is fed to the browser. With php there isn't a .html file, there's only a dynamicly created HTML document. The browser can't tell the difference.

Imy_S3

2:16 pm on Feb 15, 2004 (gmt 0)

10+ Year Member



how do i do this?

mep00

2:58 pm on Feb 15, 2004 (gmt 0)

10+ Year Member



There are many good tutorials on the Web. A good place to start, and also a good jumping off point is [php.net ]. That being said, I'll give you a very basic, if somewhat crude example.

index.php:


<html>
<head><title></title></head>
<body>
<?php
if (isset($_POST['submit']))
{
echo "<p>Name: {$_POST['name']}</p>\n";
} else
{
?>
<form action="index.php" method="post">
<label for="name">Name:</label>
<input type="text" id="name" />
<input type="submit" id="submit" value="submit />
</form>
<?php
}
?>
</body>
</html>

Like I said crude, but assuming I didn't make any typos, it should work. Everthing you need is there: HTML code, data collection, and data processing.

I'm not about to teach you php in a post, so if that's what you need, follow the link above. If you have a basic knowledge of php, follow the link above. If your understanding of php is more than basic (which I'm guessing it's not), then you wouldn't need me to tell you; you would already know to follow the link above. I assume you see the patern here; if not, you're in the wrong line of work.

If you have any more question, feel free to ask; we aim to please.

Imy_S3

2:34 pm on Feb 16, 2004 (gmt 0)

10+ Year Member



Your example does not seem to work.
All it does is takes the name, and then does not display anything.

jetboy_70

2:56 pm on Feb 16, 2004 (gmt 0)

10+ Year Member



Closing quote on value="submit possibly?

mep00

6:42 pm on Feb 16, 2004 (gmt 0)

10+ Year Member



Closing quote on value="submit possibly?
Thank you, I did say there could be typos; I didn't test it.

My point wasn't that it should be a used example, but rather to show the features which need to be implimented.

Imy_S3, if you're going to be doing any coding, even if it is just HTML, but even more so with php, you have to be ready to do debugging. While I don't consider myself a guru (though don't tell that to my clients ;)), I beleive I can say with confidence that I'm a good programer. If even in such a simple example an error snuk in, imagin how many errors there might be in a real world example. Even when I write something simple and stright forward there are always bugs. If it weren't for the fact I use a tool which highlights things like missing quotes, I would probibly spend more time debugging than coding. Even still, a large portion of my time is spent: fix a typo, save, test, find next typo, fix typo.... Then there are logic errors, typos which work (those can sometimes be the hardest to find), syntax errors, and so on.

In truth, there is no such thing as a trivial program, for by the time you can call any program trivial, you probibly have spent hundreds of hours to get to that point. I'm not saying programing is dificult, it's not, but it often take a lot of practice to be able to think properly. For most people, breaking a process down into minute logical steps without loosing sight of the big picture is very unnatural.

To put it another way: learing to program is easy; understanding how to program isn't. Until you understand programing, programing will seem incomprhensible.

To be honest, much of what I'm saying I learned from helping other people because for me program came naturally. However, there are many things which come naturally to most people forwhich I had to suffer. I suppose in the end it more or less balances out.

Philosopher

6:56 pm on Feb 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Amen mep00!

Imy_S3

9:10 am on Feb 17, 2004 (gmt 0)

10+ Year Member



I fixed that error soon after i told you it did not work. However this does not seem to be the problem, logic seems to be right, but still does not work, can you offer some more help please.

Thanks in advance.