Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Plz, help me with result of query

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Is it possible to put the results of a query in a variable (and not print them while you're in a loop)? The variables should be used after the query in html.
What I want to do is:
- select from table club
- put results in as many variables as there are results
- use results in html (32 clubs which are in the table)

My table clubs looks like this:
Club_id Club Poule
1 France A
2 Denmark A
3 Paraguay B
4 Senegal A
...

My select is: SELECT ploeg FROM club ORDER BY poule ASC
I know the results: clubs in the same poule are together in groups of 4 (1,2,3,4 – 5,6,7,8 – 9,10,11,12 - ...)

What I exactly want to do is make an table and fill in dynamicly the results, BUT they must be ordened like this:

Poule A Poule B
France Spain
Denmark Slovain
Urugay Paraguay
Senegal South-Africa

Poule C Poule D
...

What I want to do in the html is use the variables $v_club1 -> $v_club32 :

<html>
<body>
<table>
<tr><td>Poule A</td><td>Poule B</td></tr>
<tr><td>$v_club1</td><td>$v_club5</td></tr>
<tr><td>$v_club2</td><td>$v_club6</td></tr>
<tr><td>$v_club3</td><td>$v_club7</td></tr>
<tr><td>$v_club4</td><td>$v_club8</td></tr>

<tr><td>Poule C</td><td>Poule B</td></tr>
<tr><td>$v_club9</td><td>$v_club13</td></tr>
<tr><td>$v_club10</td><td>$v_club14</td></tr>
<tr><td>$v_club11</td><td>$v_club15</td></tr>
<tr><td>$v_club12</td><td>$v_club16</td></tr>
...
</table>
</body>
</html>

Can someone help me, plz? I’d really appreciate it!

Greetz,
Boogey Man
 
there's something called arrays...

you can do something like this:

$result=db_query($conn,$query);
$teams=array();
for($i=1;list($teams[$i])=db_fetch_row($result);$i++);

then

for ($r=1; $r<=($i/8);$r++){
echo &quot;<tr>&quot;;
for ($c=1; $c<=2 ; $c++){
echo &quot;<td>&quot;.$teams[$r*$i/8+$c].&quot;</td>&quot;;
}
}
Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top