Hi,
I have written a script that is listing articles from my article table
and displaying the titles ten on each page.
As I need to calculate and print other stuff in between the extracting
and the displaying of article titles, I use an array to catchj the data.
The mysql query just grabs the first ten
thats because $start = 0 and #last = 9
Later on in the same script I print these out:
This is fine, except that when I hit my "next page" link
and come back to the same script with new values for start and last,
my array is causing problems !
Maybe I need to delete it or empty it before filling it up again ?
This a multi-dimension array
As I don't pass the array with the href link, I thought that it would be
deleted anyway, but I get these errors on the second page:
Notice: Undefined variable: tute_list in /home/chosy/public_html/mem_tutes.php on line 205
Notice: Undefined variable: tute_list in /home/chosy/public_html/mem_tutes.php on line 210
Notice: Undefined variable: tute_list in /home/chosy/public_html/mem_tutes.php on line 210
Notice: Undefined variable: tute_list in /home/chosy/public_html/mem_tutes.php on line 210
These lines of code are the array display section
My test print print_r($tute_l ist); shows a good array on the first page, but nothing on
the second page, i.e. when I re-run the script with the "next page" href link
Can anyone see what I've done wrong ?
I have written a script that is listing articles from my article table
and displaying the titles ten on each page.
As I need to calculate and print other stuff in between the extracting
and the displaying of article titles, I use an array to catchj the data.
The mysql query just grabs the first ten
thats because $start = 0 and #last = 9
Code:
$sql = "SELECT tute_id,tute_head,tutes.user_id,clients.sc_name FROM tutes,clients WHERE cat_cd = '$N_cat_cd' AND live = 'y' AND tutes.user_id = clients.user_id LIMIT $start,$last";
$result = mysql_query($sql) or die("could not execute find TUTORIALS query". mysql_error());
while($row = mysql_fetch_assoc($result)){
extract($row);
$Rctr =$row_ctr+1;
$scn = strtolower(trim($sc_name));
$link1 = "something.html";
$link2 = "something_else.html";
$tute_list[] = array('num' => $Rctr, 't_head' => $tute_head, 'scn' => $scn, 'link1' => $link1, 'link2' => $link2, 's_nm' => $sc_name);
$row_ctr = $row_ctr + 1;
$ad_ctr = $ad_ctr + 1;
} // end while
} // end else
Code:
print_r($tute_list); // test print
for($i = 0; $i < 10; $i++){
echo <<<EOD
<div class="listerdiv">
<h2>{$tute_list[$i]['num']}) <a href="{$tute_list[$i]['link1']}">{$tute_list[$i]['t_head']}</a></h2>
<h3>By <a href="{$tute_list[$i]['link2']}">{$tute_list[$i]['s_nm']}</a></h3>
</div>
EOD;
} // end for loop
echo "</div>";
This is fine, except that when I hit my "next page" link
and come back to the same script with new values for start and last,
my array is causing problems !
Maybe I need to delete it or empty it before filling it up again ?
This a multi-dimension array
As I don't pass the array with the href link, I thought that it would be
deleted anyway, but I get these errors on the second page:
Notice: Undefined variable: tute_list in /home/chosy/public_html/mem_tutes.php on line 205
Notice: Undefined variable: tute_list in /home/chosy/public_html/mem_tutes.php on line 210
Notice: Undefined variable: tute_list in /home/chosy/public_html/mem_tutes.php on line 210
Notice: Undefined variable: tute_list in /home/chosy/public_html/mem_tutes.php on line 210
These lines of code are the array display section
My test print print_r($tute_l ist); shows a good array on the first page, but nothing on
the second page, i.e. when I re-run the script with the "next page" href link
Can anyone see what I've done wrong ?
Comment