mercredi 22 juin 2016

PHP - Cannot Assign String Value to Input with Pattern

I want to assign mysql_result strings to text inputs, but I can't figure out how the pattern attribute messes it up.

$id = $_GET['id'];
$q = mysql_query("SELECT * FROM employees WHERE id=".$id);

if(mysql_num_rows($q)!=0)
{
    $address = mysql_num_result($q, 0, 3);
}

Sample result would be: 1034 Wildwood Street Stow, OH 44224. My pattern regex only accepts alpha-numeric characters, period, comma, pound sign, hyphen, and spaces.

echo "<input type='text' class='form-control' name='address' value=".$address." pattern='[a-zA-Z0-9.,#\- ]+' title='Letters, numbers, pound sign, period, and comma only' required>";

It will only display 1034. I don't know why it ignores the space and the characters after it.

Aucun commentaire:

Enregistrer un commentaire