Jump to content


Photo

another problem i am trying to grasp , Please assist


  • Please log in to reply
2 replies to this topic

#1 presso

presso
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 22 October 2006 - 10:35 PM

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.
$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>
       
  ";
}


#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 22 October 2006 - 11:12 PM

Your syntax is a little whack and your using undeclared variables.

$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;


#3 presso

presso
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 22 October 2006 - 11:22 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users