Forum Moderators: coopster
I've got this simple problem where by I want to create an itemid from a DB and increment it by 1.
Essentially, I've got this query, which gets the first two itemid's in the DB order by date. I need to increment the second itemid by one.
For exmaple:
2283663
2282576
So I want to increment to 2282577.
I'm having trouble with this because its not incrementing itemid by 1, it just displays '1'.
Can anyone help?
See code:
// generate itemid number
$result=mysql_query("select itemid from newsfeed order by prop_date desc limit 2");
while ($row=mysql_fetch_row($result))
{
$itemid_1 = $row[0];
$itemid_2 = $row[1];
echo $itemid_1 . '<br>';
echo $itemid_2;
if ($itemid_2 < $itemid_1)
{
$itemid_2 = $itemid_2 + 1;
echo '<b>'.$itemid_2.'</b>' . '<br>';
}
}
Many Thanks
W.
$result=mysql_query("select itemid from newsfeed order by prop_date desc limit 2");
$itemid_1 = mysql_result($result, 0);
$itemid_2 = mysql_result($result, 1);
...