I have what looks to be a very simple problem but I can't seem to see the issue
$q = "SELECT * FROM subscriptions WHERE userID = '".$_SESSION['userid']."'";
$result = $database->query($q);
/* Error occurred, return given name by default */
$num_rows = mysql_numrows($result);
if(!$result || ($num_rows < 0)){
echo "Error displaying info";
return;
}
if($num_rows == 0){
echo "You currently have no promotions running, see available <a href=\"promotions.php\">promotions</a> here.";
return;
}
for($i=0; $i<$num_rows; $i++){
$promoPk = mysql_result($result,$i,"subPK");
$user = mysql_result($result,$i,"userID");
$promoCode = mysql_result($result,$i,"promoCode");
}echo $num_rows;
Now, when I echo num_rows the value is 2 but when I echo promoCode there is only one value when there should be 2...
Why would this be?
$q = "SELECT * FROM subscriptions WHERE userID = '".$_SESSION['userid']."'";
$result = $database->query($q);
/* Error occurred, return given name by default */
$num_rows = mysql_numrows($result);
if(!$result || ($num_rows < 0)){
echo "Error displaying info";
return;
}
if($num_rows == 0){
echo "You currently have no promotions running, see available <a href=\"promotions.php\">promotions</a> here.";
return;
}
for($i=0; $i<$num_rows; $i++){
$promoPk = mysql_result($result,$i,"subPK");
$user = mysql_result($result,$i,"userID");
$promoCode = mysql_result($result,$i,"promoCode");
}echo $num_rows;
Now, when I echo num_rows the value is 2 but when I echo promoCode there is only one value when there should be 2...
Why would this be?