Jump to content

Mysql Fetch array


abch624

Recommended Posts

Hi Guys,

 

I have a bit of code and I want to add an if statement so that a border is printed on the first row only.

 

$query2="SELECT * FROM products LIMIT 0,2";
$result2=mysql_query($query2);
$nume=mysql_num_rows($result2);

while($row = mysql_fetch_array($result2)) {
    $detail = $row['detail'];
    echo '
    <div style="float:left; width:380px; padding-left:15px; padding-top:10px; [u]border-bottom: dotted1px;[/u]"></div>
    ';
}

 

Help guys. I guess it is easy but just cant think of it :)

 

Cheers - Zahid

Link to comment
https://forums.phpfreaks.com/topic/162229-mysql-fetch-array/
Share on other sites

$query2="SELECT * FROM products LIMIT 0,2";
$result2=mysql_query($query2);
$nume=mysql_num_rows($result2);

for($n=1;$row = mysql_fetch_array($result2);$n++) {
    $detail = $row['detail'];
    $style = 'float:left; width:380px; padding-left:15px; padding-top:10px;';
    if($n === 1)
      $style .= 'border-bottom: dotted 1px;';
    echo '<div style="'.$style.'"></div>';
}

Link to comment
https://forums.phpfreaks.com/topic/162229-mysql-fetch-array/#findComment-856188
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.