You probably should upgrade to a more recent Mandrake distribution, but the basics are the basics.
Get and unpack the current PHP distribution (source code).
Change to the directory where you unpacked it and follow the instructions in INSTALL, specifically:
./configure --with-mysql --with-apxs
make
make install
If you get an error message saying apxs is not found, you need to get the apache-devel RPM file for your version of Mandrake and install it.
After the install, you probably will need to edit your Web server's httpd.conf file, comment out any obsolete references to PHP3, and restart the server. As I recall, Mandrake 7 installed PHP3 and MySQL by default.