Jump to content

Archived

This topic is now archived and is closed to further replies.

presso

another problem i am trying to grasp , Please assist

Recommended Posts

i am using the following code , which seems to work fine at pulling the info the problem is that it is only displaying one line of the result , how or what is the best way for it to display all 10 lines of info as per the amount of results the query has returned.
[code]$query = $DB->query("SELECT name, date, location FROM table ORDER BY name DESC LIMIT 10");
while ($info = $DB->fetch_row($query))
$id = $info['name'];
$date = $info['date'];
$loc = $info['location'];
{
$content .= "
<tr>
<td width=\"100%\" nowrap=\"nowrap\"  <div class=\"smallfont\" style=\"text-decoration: none;\">$name</a></div></td>
<td align=\"right\" nowrap=\"nowrap\"<div class=\"smallfont\"> $date</div></td>
<td align=\"right\" nowrap=\"nowrap\"<div class=\"smallfont\"> $location</div></td>
</tr>
     
  ";
} [/code]

Share this post


Link to post
Share on other sites
Your syntax is a little whack and your using undeclared variables.

[code=php:0]
$query = $DB->query("SELECT name, date, location FROM table ORDER BY name DESC LIMIT 10");
while ($info = $DB->fetch_row($query)) {
  $id = $info['name'];
  $date = $info['date'];
  $loc = $info['location'];
  $content .= "
  <tr>
  <td width=\"100%\" nowrap=\"nowrap\"  <div class=\"smallfont\" style=\"text-decoration: none;\">$id</a></div></td>
  <td align=\"right\" nowrap=\"nowrap\"<div class=\"smallfont\"> $date</div></td>
  <td align=\"right\" nowrap=\"nowrap\"<div class=\"smallfont\"> $loc</div></td>
  </tr>";
}
echo $content;
[/code]

Share this post


Link to post
Share on other sites
lol , yeah i know its out of whack , thats because its comming within a module , i cannot believe though that i missed having the curly bracket in the wrong postion thats all the problem was. I don't need to output it via echo $content; as $content is being passed to output by something else. Thanks for pointing out how stupid i was at not looking at my coding abit better,  :) ;D

Share this post


Link to post
Share on other sites

×

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.