Code: Select all
<?php
fetch_rows(......)
echo " table info... $rows[1]... $rows[2] etc";
?>any help would be great!
Moderator: General Moderators
Code: Select all
<?php
fetch_rows(......)
echo " table info... $rows[1]... $rows[2] etc";
?>Code: Select all
<?php
<?
$connect = mysql_connect("*****", "*****", "")
or die("Error! Could not connect: " . mysql_error());
$db = mysql_select_db("venturer" , $connect);
$query = "SELECT * FROM news ORDER BY id DESC LIMIT 5";
$result = mysql_query($query);
while ($rows = mysql_fetch_row ($result)) {
echo (" <table width="449" border="0" align="center" cellpadding="5" cellspacing="0" class="news"><tr><td valign="top"><p><span class="newstitle"> $rows[5] </span><span class="newstop"> <br>posted by <a href="index.php?page=profiles&profile=$row[3]" class="link">$rows[3]</a> on $rows[1]</span><blockquote class="bodytext"><p class="newstext">$rows[6]</p></blockquote></td></tr></table><p> </p> ");
};
?>
?>Code: Select all
<?php
$connect = mysql_connect("*****", "*****", "")
or die("Error! Could not connect: " . mysql_error());
$db = mysql_select_db("venturer" , $connect);
$query = "SELECT * FROM news ORDER BY id DESC LIMIT 5";
$result = mysql_query($query);
// it's generally better to use mysql_fetch_assoc() because then you can reference
// things like $row['column_name'] and don't have to worry if a column is deleted
// or a new one added in the middle messing up all the numbering
while ($rows = mysql_fetch_row($result)) {
// splitting out the echo statements using something like heredoc format can make
// it a lot easier to debug your HTML
// NB. With here doc (the <<<END ... END; stuff) you have to make sure that there are
// no spaces, characters, or tabs before or after END; or after <<<END otherwise you
// get errors
// Bonus of here doc - don't have to escape any quotes
echo <<<END
<table width="449" border="0" align="center" cellpadding="5" cellspacing="0" class="news">
<tr>
<td valign="top">
<p><span class="newstitle">{$rows[5]}</span><br />
<span class="newstop">posted by <a href="index.php?page=profiles&profile={$row[3]}" class="link">{$rows[3]}</a> on {$rows[1]}</span></p>
<blockquote class="bodytext"><p class="newstext">{$rows[6]}</p></blockquote>
</td>
</tr>
</table>
<br />
END;
};
?>Code: Select all
<?php
$connect = mysql_connect("*****", "*****", "")
or die("Error! Could not connect: " . mysql_error());
$db = mysql_select_db("venturer" , $connect);
$query = "SELECT * FROM news ORDER BY id DESC LIMIT 5";
$result = mysql_query($query);
while ($rows = mysql_fetch_row ($result))
{
?>
<table width="449" border="0" align="center" cellpadding="5" cellspacing="0" class="news">
<tr>
<td valign="top">
<p>
<span class="newstitle"><?php echo $rows[5]; ?></span>
<span class="newstop">
<br />
posted by
<a href="index.php?page=profiles&profile=<?php echo $row[3];?>" class="link">
<?php echo $rows[3]; ?>
</a>
on <?php echo $rows[1];?>
</span>
<blockquote class="bodytext">
<p class="newstext">
<?php echo $rows[6]; ?>
</p>
</blockquote>
</p><!-- added -->
</td>
</tr>
</table>
<p> </p>
<?php
}
?>Code: Select all
<?php
$connect = mysql_connect("*****", "*****", "")
or die("Error! Could not connect: " . mysql_error());
$db = mysql_select_db("venturer" , $connect);
$query = "SELECT * FROM news ORDER BY id DESC LIMIT 5";
$result = mysql_query($query);
while ($rows = mysql_fetch_row ($result))
{
?>
<table width="449" border="0" align="center" cellpadding="5" cellspacing="0" class="news">
<tr>
<td valign="top">
<p>
<span class="newstitle"><?php echo htmlentities($rows[5]); ?></span>
<span class="newstop">
<br />
posted by
<a href="index.php?page=profiles&profile=<?php echo urlencode($row[3]);?>" class="link">
<?php echo htmlentities($rows[3]); ?>
</a>
on <?php echo htmlentities($rows[1]);?>
</span>
<blockquote class="bodytext">
<p class="newstext">
<?php echo htmlentities($rows[6]); ?>
</p>
</blockquote>
</p>
</td>
</tr>
</table>
<p> </p>
<?php
}
?>