TV Show Table

Hi I want to create a page that consists of a submit page and then a page with a table that displays the submitted information such as:
Show: Star Wars Series
Season: 03
Episode: 24

then I want to submit that info to a action page of php to process it to a table of all the previous submissions and if the show names are the same it would overwrite the data with the most current version

My current code that I have is very basic but its:
[php]

TV Shows Adder *Show:

Season:

*Episode:

Time:

[/php]

Hi Arion with your permission, could I use your query for a tutorial on my stack ? If not I’ll try and assist you the normal way.

That’s just HTML, is there any php code to go along with it?

The problem presented here allowed me to test Tina4 to see how it would handle this task, below is a set of steps to replicate the solution I came up with. The database is an Sqlite3 database.

I made it pretty with Bootstrap, the core logic is in the HTML file.

After running the Tina4stack do the following

1.) Create a migration with http://localhost:12345/maggy/create,
[php]create table show (
show_id integer primary key,
show_name varchar (200) default ‘’,
show_season varchar (20) default ‘’,
show_episode integer default 1
)[/php]

Run the migration afterwards at http://localhost:12345/maggy

2.) Under the web_root/objects directory, create a file called Show.php, this will map the database.
[php]
class Show extends Olga
{
var $id = 0;
var $showName = “”;
var $season = “”;
var $episode = 1;

var $mapping =  ["table" => "show",
                    "fields" => [
                        "id" => ["field" => "show_id"],
                        "showName" => ["field" => "show_name"],
                        "season" => ["field" => "show_season"],
                        "episode" => ["field" => "show_episode"]
                    ]
                ];

}
[/php]

3.) Under the web_root/objects directory create a file called Shows.php, this will give us our list of shows.
[php]
class Shows extends Olga
{
var $mapping = [“table” => “show”, “object” => “Show”]; //maps to the Show object
}
[/php]

4.) Under the web_root/assets/pages directory create a file called shows.html
[php]

My TV Shows Tutorial in Tina4

{{if(!empty($_REQUEST[“showName”]))}}


Success! Added {$_REQUEST[“showName”]}.

{{ShowService:addShow?{$_REQUEST[“showName”]},{$_REQUEST[“showSeason”]},{$_REQUEST[“showEpisode”]}}}
{{endif}}
Show Name
Season
Episode
Add Show
{{ShowService:listShows}} {{/ShowService:listShows}}
Show Name Season Episode
{showName} {season} {episode}
[/php]

5.) Finally, under the web_root/project directory add a file called ShowService.php, this lists the shows and has some simple logic to replace a show if the name already exists.

[php]
class ShowService
{
/**
* List all the shows
* @return Array
*/
function listShows() {
$shows = (new Shows());
$shows->load();
return json_decode($shows->toJSON());
}

/**
 * Adding a new show
 * @param $showName
 * @param $season
 * @param $episode
 */
function addShow($showName, $season, $episode) {
    //see if show exists
    $show = (new Show())->getBy(["showName" => $showName]);

    //update the values
    $show->setShowName($showName);
    $show->setSeason($season);
    $show->setEpisode($episode);

    $show->save();
}

}

[/php]

That’s it, you should have a form with the grid on the side.

See the running sample at http://localhost:12345/shows

Ruth automatically routes to the shows.html file.

I must be missing something for all I see is HTML in the OP? :-\

If you guys are sharing the code via skype or some other means, it would had been nice post it here for others to see?

However, I guess if the OP doesn’t mind though then everything if find in programming land. ;D

Hi Strider, the full code is posted here, let me just say the above code will work 100% fine with the Tina4stack which I am writing so people don’t have to write so much code. Check it out at http://tina4.com

andrevanzuydam, this is not an ADVERTISEMENT site. If you and Arion are just advertising your plugin,
you should look for another place to post it. We assist in helping PHP programmers here, not to promote
code libraries… UNLESS, you post your code here and it is worth passing on.

Therefore, please post some code, or leave this thread!

Hi Ernie

:o I have no affiliation with Arion and I wasn’t aware that use of 3rd party libraries was forbidden in giving of solutions, I see many references given to other tools and libaraies. Please read the thread again, I gave a solution using a stack that I am familiar with.

I will upload a zip file of the solution for others to give a spin.

RE: The advertising, I am definitely here to advertise my skills!

Well, what I was saying is that Strider64 is correct. Neither of you posted any PHP code that you wish us to
help you with. All you did was point to a Tina4Stack GitHUB project which is basically a type of library system
and is not something for us to help with here. That is what the Tina4Stack Blog is for… Just not PHP…

The original poster of this thread was asking a simple question about posting forms thru PHP. But, of course,
he did not post any of the PHP code. So, here is a tutorial on how to do form handling. Just keep clicking on
the “Next Chapter” button at the bottom to go thru the tutorial…

http://www.w3schools.com/php/php_form_complete.asp

Sponsor our Newsletter | Privacy Policy | Terms of Service