I have a little (for you) question, that make me crazy!
I would begin to make class in php. I know the base of php5 class, but i never use it on a project. I think that the big problem in my mind is how I have to implement the method.
Let's see an example. Now, if I want to make a form to insert i new, I write something like it
Code: Select all
<form name='newsForm' id='newsForm' method='post' action='page.php'>
<input type='hidden' name='newsId' id='newsId' value='<?php echo $newsId; ?>' />
Title: <input type='text' name='newsTitle' id='newsTitle' value='<?php echo $newsTitle; ?>' />
...
<input type='submit' name='newsSave' id='newsSave' value='Save it!' />
</form>Then i write a function like it
Code: Select all
if(isset($_POST['newsSave'])){
$newsId = $_POST['newsId'];
$newsTitle = $_POST['newsTitle'];
...
$sqlUpdate = "UPDATE news SET title = '$newsTitle', ... WHERE idNews = '$newsId'";
}But how should I write this little thing in object? I really don't understand it! I have to write a method like printForm() where i write the code to print the form that i wrote before?
And then in page.php create a new object and call the method?
And to save? I have to do the same! And so, where is the power of the object? In this way is like lot of include!
I'm sure that there is somethink that i can't understand... Can anybody help me?
Thanks!!!!