Hi, guys!
Need your help with sql query and php.
I have to pieces of code here:
1.
$sql = "SELECT SUBSTR(n.`title`, 1,1) FROM node n WHERE n.`type` = 'type1'";
$results = db_query($sql);
while ($fields = db_fetch_array($results)) {
foreach($fields as $key => $value) {
echo $value;
}
}
The code above returns first letters of my article titles (table - node, columns - type, title) like this - NHDKFLF...
2.
if (preg_match ('/A/i', $string)) {
echo ('Contains letter A'); //
}
else {
echo ('Nothing'); //
}
And the second part checks if the string contains certain letters.
Now, the question is how to combine these two pieces of code? I mean how to pull data from DB and check if it has certain letters.
Thanks in advance.