jeddi
04-30-2011, 07:44 AM
Hi,
I am using the LIMIT to grab just 2 rows from my table,
but I am not sure how I should get the data into my variables.
In the code below you can see that I am trying to get the
product code, title and description in to the variables.
But I don't know how to take thr first row and then afterwards the second row :confused:
I also need to check that there IS a second row.
Would appreciate some help. :)
This is the code I have :
$sql = "SELECT id, prod_id, prod_title, prod_desc From pdc_promos WHERE promo_id = '$the_cntr' ORDER BY promo_id LIMIT 2";
$result = mysql_query($sql) or die("could not select pdc_promos");
if(mysql_num_rows($result) > 0 ){
$row = mysql_fetch_assoc($result); //
$promo1 = $row['prod_id'];
$pro_title_1 = $row['prod_title'];
$pro_desc_1 $row['prod_desc'];
$promo2 = $row['prod_id'];
$pro_title_2 = $row['prod_title'];
$pro_desc_2 $row['prod_desc'];
.
I am using the LIMIT to grab just 2 rows from my table,
but I am not sure how I should get the data into my variables.
In the code below you can see that I am trying to get the
product code, title and description in to the variables.
But I don't know how to take thr first row and then afterwards the second row :confused:
I also need to check that there IS a second row.
Would appreciate some help. :)
This is the code I have :
$sql = "SELECT id, prod_id, prod_title, prod_desc From pdc_promos WHERE promo_id = '$the_cntr' ORDER BY promo_id LIMIT 2";
$result = mysql_query($sql) or die("could not select pdc_promos");
if(mysql_num_rows($result) > 0 ){
$row = mysql_fetch_assoc($result); //
$promo1 = $row['prod_id'];
$pro_title_1 = $row['prod_title'];
$pro_desc_1 $row['prod_desc'];
$promo2 = $row['prod_id'];
$pro_title_2 = $row['prod_title'];
$pro_desc_2 $row['prod_desc'];
.