5 Replies - 681 Views - Last Post: 23 June 2010 - 11:03 PM Rate Topic: -----

#1 jasper199069  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 19-August 08

create a table from a mysql query

Posted 22 June 2010 - 07:25 AM

hello goor people,

i am trying to make a nice list from a mysql query but at the moment i can only display one list while i'd like to display three different results next to each other.

this is the code i already have:
<?php
$sql = "SELECT * FROM tbl_users WHERE `school`='".$w_user->user_school."' AND `group`='".$w_user->user_group."' AND `function`='student'";

$result = mysql_query( $sql );

echo("<table border=\"1\">");
while( $row = mysql_fetch_array( $result ) )
{
  ?>
  <tr>
  <td><input type="checkbox" name="check[<?php echo( $num ); ?>]" value="<?php echo( $row["ID"] ); ?>"></td><td><?php echo( $row["name"]." ".$row["a_naam"]." ".$row["last_name"] ); ?></td>
  </tr>
  <?php
  $num++;
}
echo("</table>");

?>



can someone help me with this

greets japie

Is This A Good Question/Topic? 0
  • +

Replies To: create a table from a mysql query

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2486
  • View blog
  • Posts: 8,533
  • Joined: 08-August 08

Re: create a table from a mysql query

Posted 22 June 2010 - 07:40 AM

If you echo $sql, does the query look like you intended?
Was This Post Helpful? 0
  • +
  • -

#3 jasper199069  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 19-August 08

Re: create a table from a mysql query

Posted 23 June 2010 - 04:25 AM

View PostCTphpnwb, on 22 June 2010 - 06:40 AM, said:

If you echo $sql, does the query look like you intended?


Yes the sql is exactly what i intended

the only thing is that i want is a table with different results im more colums.

thanks in advance
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 2899
  • View blog
  • Posts: 7,555
  • Joined: 08-June 10

Re: create a table from a mysql query

Posted 23 June 2010 - 05:31 AM

you mean like 3 times [ID, name, last_name] in a row?
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is offline

  • Original Digital Gansta
  • member icon

Reputation: 4466
  • View blog
  • Posts: 24,916
  • Joined: 10-May 07

Re: create a table from a mysql query

Posted 23 June 2010 - 07:59 PM

Try passing MYSQL_ASSOC to the mysql_fetch_array function. If that doesn't work, then use looping integers rather than ID, name, a_naam, & last_name.
Was This Post Helpful? 0
  • +
  • -

#6 Guest_D-2010*


Reputation:

Re: create a table from a mysql query

Posted 23 June 2010 - 11:03 PM

hey, are u sure ur returning more than one results?

what does
echo mysql_num_rows($result);
tells you?
Was This Post Helpful? 0

Page 1 of 1