Jump to content

Looping Help


Sleeper

Recommended Posts

I am pulling data from an sql data base. I want it to displayed (Item # | Error button | Link) however as its looping with a while on the database info I cant seem to get it to loop on the item number so it shows 1, 2, 3,.... on each row.

 

Current coding is:

while ($info = mysql_fetch_array($data)){

Print '<tr>';
Print"<td style='width: 15px;' class='cat-list'>$D</td>";

if ($info['id']==""){
Print"<td class='cat-list'> </td>";
}else{
Print"<td class='cat-list' style='width: 20px;'><img border='0' src='images/error.png' width='16' height='16'></td>";
}

if ($info['link']==""){
Print"<td class='cat-list'> </td>";
}else{
Print"<td class='cat-list'><a target='_blank' href='".html_entity_decode(stripslashes($info[link]))."'>".substr(html_entity_decode(stripslashes($info[link])), 0, 85)."</a></td>";
}
}

 

How would I get the $D item to show 1 2 3... ect?

 

Thanks,

Jim

Link to comment
https://forums.phpfreaks.com/topic/227826-looping-help/
Share on other sites

while ($info = mysql_fetch_array($data)){

$D = $info['id'];

Print '<tr>';
Print"<td style='width: 15px;' class='cat-list'>$D</td>";

if ($info['id']==""){
Print"<td class='cat-list'> </td>";
}else{
Print"<td class='cat-list' style='width: 20px;'><img border='0' src='images/error.png' width='16' height='16'></td>";
}

if ($info['link']==""){
Print"<td class='cat-list'> </td>";
}else{
Print"<td class='cat-list'><a target='_blank' href='".html_entity_decode(stripslashes($info[link]))."'>".substr(html_entity_decode(stripslashes($info[link])), 0, 85)."</a></td>";
}
}

 

 

Link to comment
https://forums.phpfreaks.com/topic/227826-looping-help/#findComment-1174829
Share on other sites

$D = 1;
while ($info = mysql_fetch_array($data)){

Print '<tr>';
Print"<td style='width: 15px;' class='cat-list'>$D</td>";

if ($info['id']==""){
Print"<td class='cat-list'> </td>";
}else{
Print"<td class='cat-list' style='width: 20px;'><img border='0' src='images/error.png' width='16' height='16'></td>";
}

if ($info['link']==""){
Print"<td class='cat-list'> </td>";
}else{
Print"<td class='cat-list'><a target='_blank' href='".html_entity_decode(stripslashes($info[link]))."'>".substr(html_entity_decode(stripslashes($info[link])), 0, 85)."</a></td>";
}
$D++;
}

 

 

Link to comment
https://forums.phpfreaks.com/topic/227826-looping-help/#findComment-1174832
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.