PDA

View Full Version : mysql_fetch_array problem


Roost3r
09-19-2002, 04:21 PM
yes this is a php question

Hi,
My website is at http://www.xtremehw.com and I want to add a banner spanning the height of the first 2 news articles.

im using..

while ($myrow = mysql_fetch_array($news)) {

newsinfo

}

i tried adding a if statement to add another cell for the adv like this.
$newsadv = 0;
if ($newsadv = 0) {
echo " <td rowspan\"2\"> adv here</td>";
}
$newsadv++;

but that didnt work; i tried other ways but still cant get a adv in that spot....
any suggestions? thanks

craigh@mac.com
09-19-2002, 09:43 PM
you have a logic problem.

$newsadv = 0;
while ($myrow= mysql_fetch_array($news)) {
if ($newsadv < 2) {
echo " <td rowspan\"2\"> adv here</td>";
} else {
//do something else to shift the articles around
}
$newsadv++;
}

try that

mordred
09-19-2002, 10:38 PM
And there's a HTML problem too:

echo " <td rowspan\"2\"> adv here</td>";

shouldn't that read as:

echo " <td rowspan=\"2\"> adv here</td>";

Roost3r
09-20-2002, 01:52 AM
i have the html right; i just typed it wrong here in the forum :)

also craig you wrote i have a logic error but if i used:

if ($newsadv < 2) then the <td rowspan=2></td> part will be done twice;

it has to work so that the first news is outputted, then the <td rowspan=2></td> followed by another news

ive tried

$newsadv = 0;
while ($myrow= mysql_fetch_array($news)) {
while ($newsadv < 2) {
echo "<td> do my news </td>";

if ($newsadv = 0) {
echo " <td rowspan=\"2\"> adv here</td>"; for adv
}
$newsadv++;
}
}

thats just a simple version of what i tried

Roost3r
09-20-2002, 02:01 AM
... double post

craigh@mac.com
09-20-2002, 02:41 AM
why don't you post an example of what the final HTML output should look like.

Roost3r
09-20-2002, 04:51 AM
heres the simple version; the html im using would be too long to post here


<table>
<tr>
<td>news</td>
<td rowspan=2>adv</td>
</tr>
<tr>
<td>news</td>
</tr>
</table>