Depending on if you have one or more states you could go with either an if () {} else {} construct, use an array() for the job or a switch statement might also be usable if you have multiple states that require the same class to be output.
for instance using an array:
$classes = array(
'sold' => 'date-two',
'...' => '...' //example values
);
// imagining that $data_available = 'SOLD'
echo '<span class="'. ($classes[strtolower($data_available)] || 'date') .'">';
or using a switch statement
$cls = 'date';
switch (strtolower($data_available)) {
case 'sold':
case 'sold2': // switch statements allow multiple 'cases' to be grouped for the same output.
$cls = 'date-two';
break;
case '...':
$cls = '...';
break;
default:
$cls = 'date';
break;
}
for the if example I'd look at Tobias' answer
Another option is instead of using a different class, simply know what the database can output and create prefixed classes for that.
e.g. sold, bought and negotiating are some states (example)
What you could do here is simply
$cls = 'date-' . strtolower($data_available); // if $data_available is sold it will output date-sold
echo '<span class=". $cls .">';
then in your CSS you could do something like:
.date-sold {
width: 420px;
background: green;
}
.date-bought {
width: 720px;
background: white;
}
.date-negotiating {
width: 30px;
background: transparent;
}
this way you'll always be safe and if your database input is consistent which it should be then all your divs will get the right class with the right CSS applied without too much PHP hassle.
Good luck!