Forum Moderators: coopster
I'm still a newbies but enjoy very much php/MySQL. Here's the situation.
I want to improve the display of my $result3. I'm sure I need to use another
"while" statement inside this one but I don't want to create a infinite loop.
The $result3 look's like that:
-------------------------------------------------------
¦norisk¦descris ¦nomesur ¦descmes ¦
-------------------------------------------------------
¦A ¦high ¦1 ¦use harness ¦
-------------------------------------------------------
¦A ¦high ¦7 ¦be carefull ¦
-------------------------------------------------------
¦B ¦wet ¦3 ¦use boot ¦
-------------------------------------------------------
¦B ¦wet ¦7 ¦be carefull ¦
--------------------------------------------------------
I'dont want to had another query( thise one involve already 3 tables). Here's the code I wrote:
$result3 = mysql_query($sql2) or die("9err");
while ($array2 = mysql_fetch_array($result3))
{
print ("<tr><td>");
print ($array2['descris']) or die("err17");
print ("</td><td>");
print ($array2['descmes']) or die("err17");
print ("</td></tr>");
}
Of course, I don't want to see twice "high" and twice "wet" in the display but want to see all the measures
for each risk.
Thank you for answering, all this php/MySQL stuff is very exiting. I came from far.
Spaciane
[edited by: jatar_k at 2:28 am (utc) on Feb. 25, 2004]
[edit reason] no sigs thanks [/edit]
a) The query result must be sorted by descris and
b) descris must never be the empty string.
$result3 = mysql_query($sql2) or die("9err");
$old = "";
while ($array2 = mysql_fetch_array($result3))
{
if( $old!= $array2['descris'] )
{
if( $old ) {
print( "</tr>$ );
}
$old = $array2['descris'];
print ("<tr><td>");
print ($old) or die("err17");
}
print ("</td><td>");
print ($array2['descmes']) or die("err17");
}
if( $old ) {
print( "</td></tr>$ );
}
1)Yes condition a) and b) are met.
2)I'm still trying to sort it out. But I don't understand the use of $ in the html stuff like:
{
print( "</td></tr>$ );
}
3)Here is the message I got
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in ...submit_ec_dev.php on line 71
How can I find those line, right now I'm finding them by try and misstake?
$result3 = mysql_query($sql2) or die("9err");
$old = "";
while ($array2 = mysql_fetch_array($result3)) {
if ($old!= $array2['descris']) {
if ($old) {
print( "</tr>" );
}
$old = $array2['descris'];
print ("<tr><td>");
print ($old) or die("err17");
}
print ("</td><td>");
print ($array2['descmes']) or die("err17");
}
if ($old) {
print ("</td></tr>");
}
here's the results :
$result3 = mysql_query($sql2) or die("9err");
$old = "";
while ($array2 = mysql_fetch_array($result3)) {
if ($old!= $array2['descris']) {
$old = $array2['descris'];
print ("<tr><td>");
print ($old) or die("err17");
print ("</td><td>");
}
print ($array2['descmes']) or die("err17");
print ("<br>");
}
if ($old) {
print ("</td></tr>");
}
very clean and simple
Thank you very much Hanu
Spaciane
[edited by: jatar_k at 2:28 am (utc) on Feb. 25, 2004]
[edit reason] no sigs thanks [/edit]