-2

I'm developing a PHP site. There I'm loading an image to my home page like this.

img src="?php  echo"css/images/".$Vid_arr[count($Vid_arr)-5]."/front.jpg" ?" alt="Product Image 9"

Now I need to pass only this part $Vid_arr[count($Vid_arr)-5] to my details.php file. How can I do this?

Roham Rafii
  • 2,929
  • 7
  • 35
  • 49
Thilina H
  • 217
  • 1
  • 3
  • 19

3 Answers3

1

They are several ways to do it, first you can use a GET method, or simply use sessions: session_start(); $_SESSION['foo'] = $Vid_arr[count($Vid_arr)-5];

torr
  • 1,256
  • 3
  • 11
  • 20
1

if it's one variable, and this variable was available in one of the pervious pages. you can use $_SESSION. However, if it's not available from one of the previous pages. use include_once('details.php');

Vincent Savard
  • 34,979
  • 10
  • 68
  • 73
Othman
  • 2,942
  • 3
  • 22
  • 31
0

You can use include_once('path_to_details.php'); just after the <img> line you have there and in the details.php script just use$Vid_arr[count($Vid_arr)-5] normally.

include_once will call the script you want. This way you can have many pieces of code separated in many files and you can merge them all into one by using the include and include_once functions.

Nicolás Torres
  • 1,385
  • 8
  • 13