I have in my mysql this table .
I need that php (with a PDO Statement) will return every id where email "mrgamer751p@gmail.com" is contained. I tried with a LIKE statement (only to get rows number):
$stmt = $pdo->prepare("SELECT * FROM market WHERE buyers LIKE :email");
$needle = '%mrgamer751p@gmail.com%';
$stmt->bindValue(':email', $needle, PDO::PARAM_STR);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo $rows;
But it doesn't work.
try using concat for wildchar eg:
$stmt = $pdo->prepare("SELECT * FROM market WHERE buyers LIKE concat('%', :email, '%')");
$needle = 'mrgamer751p@gmail.com';
$stmt->bindValue(':email', $needle, PDO::PARAM_STR);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $key=> $value) {
echo $value['your_column_name'].'</br>';
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.