Jump to content

Using a numer in a table for a loop


teknospr

Recommended Posts

Good day:

 

Im trying to get a numer from a table and use it to know how many pages are in the article so the script knows how many hyperlinks for the pages to generate (ex. links for pages 1 to 5). This is the script so far:

 


<?php
$aid = $_GET['aid'];
$sd = $_GET['sd'];
  $connection = mysql_connect("localhost",
        "username",
        "password");

    mysql_select_db("articles", $connection); 
$query="SELECT pages FROM articles_description WHERE articleid=$sd";

$result=mysql_query($query);

$num=$result;

mysql_close();


?>

<table width ="600" border="0" cellspacing="2" cellpadding="2" align="center">
<th><font face="Arial, Helvetica, sans-serif">pages</font></th>



<?php
$i=1;
while ($i <= $num) {

?>



<td align="center"><font face="Arial, Helvetica, sans-serif"><?php echo "<a href=\"$f3?aid=$aid&sd=$i\" target=\"_self\">$i</a>"; ?></font></td>
</td>




<?php
$i++;
}
?>

 

Any help will be appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/229917-using-a-numer-in-a-table-for-a-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.