hi - i've just discovered variable variables (with help of the articles section and php.net) and have not been able to get it to work for me in my current situation.
$query = "SELECT DISTINCT firstname, lastname, q1, q2, q3, q4,
q5, q6, q7, q8, q9, q10, q11, q12, q13, q14,
q15, q16, q17, q18
FROM vday WHERE q1!='$row->q1' AND id!='$row->id'";
$result1 = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
if (mysql_num_rows($result1) > 0)
{
while($row2 = mysql_fetch_object($result1))
{
$matches = 0;
if ($row->q2==$row2->q2)
{
$matches++;
$matches++;
}
if (abs($row->q2 - $row2->q2) == 1)
{
$matches++;
}
for ($i = 3; $i <= 18; $i++)
{
$one = ${"row->q".$i};
$two = ${"row2->q".$i};
if($one == $two)
$matches++;
}
inside the for loop is where im trying to get this to work for me. it isnt giving me any parse errors or anything, but instead it is doing the $matches++ statement for every loop when it is not supposed to....