php - Multiple array results in a variable -
i've php code:
$categories = mysql_query("select category_id, category_name categories categories"); while ($row = mysql_fetch_assoc($categories)){ $columnvalues[] = $row['categories']; } $catlist = $columnvalues[0]; $catchq = mysql_query("select message message box lower(message) '".$catlist."'"); $catchr = mysql_fetch_array($catchq); $catchx = $catchr['message']; echo $catchx."\n";
the above code works intended, [0] match , if message contains name of category [0]. trying accomplish have second query of 4 categories found in first query.
how match against [1], [2], [3] well? tried or operator, doesn't work think (eg. $catlist = $columnvalues[0] or $columnvalues[1];
)
you loop on $columnvalues
:
$query = "select message message box lower(message)" foreach ($columnvalues $key => $value) { if ($key) { $query .= " or "; } $query .= " '%$value%' "; } $catchq = mysql_query($query);
your code vulnerable injection. should use parameterized queries pdo or mysqli.
Comments
Post a Comment