Search code examples
phpconcatenationstring-concatenation

How to concatenate between two variables?


I need to include the - to my database whenever I select the year, but only, 2006 2008 are saving in my database. How is this guys?

('<option value="'.$year2. " " . $i .'" '.$selected.'> '.$year2.' - '.$i.'</option>'."\n");

Solution

  • Put it in the value attribute, like this:

    ('<option value="'.$year2. " - " . $i .'" '.$selected.'> '.$year2.' - '.$i.'</option>'."\n");