Jump to content

another problem i am trying to grasp , Please assist


presso

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]
Link to comment
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]
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.