0

I created two separated pages that are for example

www.sodamachine.com/sodaView
www.sodamachine.com/soda

So in my sodaView file there are different types of images from the soda I want that are clickable in an array.

  $soda= array
  (
  array('Cola',1,2,'Cola.png'),
  array('Pepsi',3,4,'Pepsi.png'),
  array('Sprite',5,6,'Sprite.png')
  );

Now when I click the cola image i want the url to be

www.sodamachine.com/soda/Cola

And give me information from the array to that specific page. How can i achieve this without creating different pages, so one for cola one for pepsi and one for sprite.

I created an href from the images and it will redirect me to the desired page, but now it is looking for /soda/cola while i only have /soda

I want 1 page that can handle them all but still the url needs to be /soda/cola

I am new to php and just trying out some stuff but couldn't find an answer I was statisfied with. I am not even sure if this is possible.

Proliges
  • 371
  • 4
  • 26
  • This is a common issue in Web Development. Many PHP frameworks handle this out of the box, but developing your own requires a fair amount of work; mainly with the `.htaccess` file associated with your PHP server. Do some research on Google for URL rewriting, friendly URLs, URL parameters, etc etc. – Tim Lewis Jan 16 '18 at 21:37
  • First of all you will need a single page that handles Cola, Pepsi, Sprite, etc by receiving a parameter, something like `soda.php?brand=thebrand`. Then you need to do some url rewrites to point `/soda/pepsi` to `/soda.php?brand=pepsi`. – James Jan 16 '18 at 21:44

0 Answers0