AND Anweisung möglich?
Verfasst: Di 20.Nov, 2007 17:07
Hallo Leute,
ich versuche gerade die Polls etwas aufzubohren, jetzt stellt sich mir die Frage ob ich eine/mehrere AND Anweisung/en so in die posting.php hineinpacken kann, ohne hier gnadenlos einen Logikbug verbaut zu haben?
cu Overhead
ich versuche gerade die Polls etwas aufzubohren, jetzt stellt sich mir die Frage ob ich eine/mehrere AND Anweisung/en so in die posting.php hineinpacken kann, ohne hier gnadenlos einen Logikbug verbaut zu haben?
Code: Alles auswählen
$vote_id = $vote_info['vote_id'];
AND $id_vote = $vote_info['vote_id'];
} $sql = "SELECT *
FROM " . VOTE_USERS_TABLE . " WHERE vote_id = $vote_id
AND "WHERE id_vote = $vote_id
AND vote_user_id = " . $userdata['user_id'];
if ( !($result2 = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain user vote data for this topic', '', __LINE__, __FILE__, $sql);
}
$prev_vote = $db->sql_numrows();
$counter = 0;
$row = $db->sql_fetchrowset($result2);
$vbn = array();
for ($i = 0; $i < count($vote_id); $i++)
{
// check if already voted on certain options
$flag = false;
for ($j = 0; $j < $prev_vote; $j++)
{
if ($vote_id[$i] == $row[$j]['vote_option_id'])
{
$flag = true;
break;
}
}
if (!$flag)
{
$vbn[$counter] = $vote_id[$i];
$counter++;
}
}
$db->sql_freeresult($result2);
$sql = "SELECT vd.vote_id
FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
WHERE vd.topic_id = $topic_id
AND vr.vote_id = vd.vote_id
AND vr.vote_option_id = $vote_option_id
GROUP BY vd.vote_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain vote data for this topic', '', __LINE__, __FILE__, $sql);
}
if ( $vote_info = $db->sql_fetchrow($result) )
{
$vote_id = $vote_info['vote_id'];
$sql = "SELECT *
FROM " . VOTE_USERS_TABLE . "
WHERE vote_id = $vote_id
AND vote_user_id = " . $userdata['user_id'];
if ( !($result2 = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain user vote data for this topic', '', __LINE__, __FILE__, $sql);
}
if ( $max_vote >= (count($vbn) + $prev_vote) ) // Modded
{
foreach ($vbn as $vote_option_id)
{
$sql = "UPDATE " . VOTE_RESULTS_TABLE . "
SET vote_result = vote_result + 1
WHERE vote_id = $vote_id
AND vote_option_id = $vote_option_id";
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not update poll result', '', __LINE__, __FILE__, $sql);
}