If you want a random number using php,
this is all yo need:
<? $variable = rand(0,6); ?>
Random takes two arguments:
First, the number to start at.
Second, the max number to be used.
As far as incorporation JS variables and php, I know it can be done, but I cant say how.