Jump to content

posting echo values


shadiadiph

Recommended Posts

mmm I am having some problems with this piece of scripting. On this page I call the data base to show news headlines in a box.

Right now it is displaying them ok but what aI want is when I click on a certain news article it opens in news.php and displays only the article of the headline i clicked on. The problem right now is it shows the headlines i click on them it goes to news.php but always displays the last one in the list never the one i clicked on?

 

 

here is the code i have.

 

<table cellspacing="0" cellpadding="2" border="0">

<?

$sql = "SELECT * FROM tblnewsdetails order by intnewsID desc";

$result = mysql_query($sql);

while ($row = mysql_fetch_assoc($result)) {

$tradeaid = $row["intnewsID"];

$accountid = $row["intAccountID"];

$stitle = $row["newsshTit"];

$mtitle = $row["newsTit"];

$nmain = $row["newsMn"];

$updated = $row["dtAddedOn"];

?>

 

<form name="news" method="post" action="news.php">

 

 

<?

echo '<tr><td width="80% align=left"><a onclick="submit();">'. $stitle. '</a></td></tr>';

}

?>

 

<input name="mtitle" type="hidden" id="mtitle" value="<?=$mtitle?>">

<input name="nmain" type="hidden" id="nmain" value="<?=$nmain?>">

</table>

</form>

 

Link to comment
https://forums.phpfreaks.com/topic/106176-posting-echo-values/
Share on other sites

Firstly this shouldn't be in the OOP section.

 

Try this

 

<table cellspacing="0" cellpadding="2" border="0">
<form name="news" method="post" action="news.php">
<?php
$sql = "SELECT * FROM tblnewsdetails order by intnewsID desc";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
$tradeaid = $row["intnewsID"];
$accountid = $row["intAccountID"];
$stitle = $row["newsshTit"];
$mtitle = $row["newsTit"];
$nmain = $row["newsMn"];
$updated = $row["dtAddedOn"];
?>

<input name="mtitle" type="hidden" id="mtitle" value="<?=$mtitle?>">
<input name="nmain" type="hidden" id="nmain" value="<?=$nmain?>">

<?php
echo '<tr><td width="80% align=left"><a onclick="submit();">'. $stitle. '[/url]</td></tr>';
}
?>

</table>
</form>

Link to comment
https://forums.phpfreaks.com/topic/106176-posting-echo-values/#findComment-548058
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.