You can get to Zwardoń, and catch a train to Zilina from there. The trains to Zwardoń go from Katowice.
Another option is through Cieszyn. You take a train to Cieszyn (from Katowice you must change in Czechowice-Dziedzice), walk about 2 km to the station in Cesky Tesin (the Czech part of Cieszyn) and catch there a direct train to Zilina. But the train to Cieszyn doesn't reach Cieszyn in the time to the end of September, there is a replacement bus service on the section between the last station before Cieszyn (Cieszyn Marklowice) and Cieszyn.
There are also trains between the station in the Polish and Czech part of Cieszyn, but their timetable doesn't make much sense when you want to get there from Katowice, it's better to walk.
There is also an option through Bohumin.
I will try to compare the prices. Assuming local trains in the Polish part. You can take an EIC from Katowice to Bohumin, and it will be faster, but also much more expensive.
1. Through Zwardoń.
Gliwice-Zwardoń with a train change in Katowice - Koleje Śląskie - 23 zł (= 5 euro)
Skalite-Zilina - ZSSK - 2,45 euro (train from Zwardoń)
+ maybe a surcharge for buying the ticket on the board, sth like 2 euro, but rather not
It seems that when you board the train in Zwardoń and ask the conductor for a ticket to Zilina, you will get a ticket from Skalite, the first station in Slovakia. So crossing the border is "unofficially" free of charge. You can buy an international ticket from Zwardoń to Zilina, but it doesn't make any sense, as it's much more expensive.
-> 7,5 euro together, around 6 hours
2. Through Bohumin.
Gliwice-Chałupki - Koleje Śląskie - 21 zł (= 5 euro)
Chałupki-Bohumin - Koleje Śląskie - 2 zł (= 0,5 euro) (trans-border ticket)
Bohumin-Zilina - CD - 138 CZK (= 5 euro)
But on weekends you can buy a ticket from the Silesia Weekend offer. It gives you 15% discount from Gliwice to Chałupki and allows unlimited travels in a big part of Czech Republic. With this ticket, on the train to Zilina you can get to Mosty u Jablunkova:
So when you change trains in Bohumin, it's enough to buy a ticket from Navsi to Zilina. The trains from Bohumin to Zilina don't stop in Mosty, so I am not sure if you could do it with a ticket from Mosty, but for sure you can do it with a ticket from Navsi, where the train stops, and it's still in the area covered by the Silesia Weekend ticket.
Then the ticket for the Slovak-Czech part will cost only 127 CZK (= 4,7 euro) + the Polish ticket will be cheaper.
If you buy a return ticket for the Polish part, the discount will be 20%, and the rules for Czech Republic are the same.
3 The same rules as through Bohumin and similar prices are through Cieszyn.
And, by the way, you can also buy a daily network ticket of Koleje Śląskie for 34 zł, which works in the same way as the Silesia Weekend ticket in terms of Czech Republic, but allows to travel on all the Koleje Śląskie trains for a single day, so you can use it as a return ticket if you return on the same day.
Of course, you can also use EIC trains, which are fast, but it will be more expensive.