makexitxcount Posted August 1, 2006 Share Posted August 1, 2006 I´m trying to do a table linked with a mysql db, but i got a problem, i want the values only to appear when they´re tag "EstatTecnic" is different from "A".First i couldn´t make the link "see" dissapear with their chained named on the left cell, the named dissapear but the "see" didn´t. They told me to change the code to what i post below, but it doesn´t work, somebody have a clue of what is going wrong? i uploaded a picture of what i want to have and what i have right now:[img]http://img155.imageshack.us/img155/1210/sinttulo1ql5.jpg[/img]thnxs[code=php:0]<?while ($row_rstTecnic = mysql_fetch_assoc($rstTecnic)){ if($row_rstTecnic['EstatTecnic']=="A"){echo $row_rstTecnic['NomTecnic'].'</td><td><a href="tecnic.php?tecnic='.$row_rstTecnic['NumTecnic'].'">see</a></td>';}else{echo '</td><td></td>';};?></tr><?};?> </table>[/code] Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted August 1, 2006 Share Posted August 1, 2006 Get rid of the semi colons after the closing accolades (twice):[code]};[/code]Ronald ;D Quote Link to comment Share on other sites More sharing options...
makexitxcount Posted August 1, 2006 Author Share Posted August 1, 2006 thnxs, but it keeps without working Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 1, 2006 Share Posted August 1, 2006 You don't have any opening row or cell tags inside your while loop. Look at the code inside the loop - the first tag is a </td> - there is no corresponding opening <td> tag or even an opening <tr> tag. So your table is not complete, that's why it looks the way it does. Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 There is a chance he might have a script above this, dun u thinkbut ther is no sarting for the TD in the beginning of the while, check thatand this is a php place where he made the mistake not html[code]<?while ($row_rstTecnic = mysql_fetch_assoc($rstTecnic)){ if($row_rstTecnic['EstatTecnic']=="A"){echo $row_rstTecnic['NomTecnic']."</td><td><a href=\"tecnic.php?tecnic=".$row_rstTecnic['NumTecnic']."\">see</a></td>";}else{echo "</td><td></td>";}echo "</tr>";}?></table>[/code]*bumped* Quote Link to comment Share on other sites More sharing options...
makexitxcount Posted August 1, 2006 Author Share Posted August 1, 2006 my problem was that when i tried to put a <table> or a <tr> tag between the php code didn´t recognized as html, so i put them at the top but it wasn´t working.right now i´m working with an other script, but it keeps with the same problem.[code=php:0]<table align="center"width="400" border="4" cellpadding="2" cellspacing="0" bordercolor="#FF3300" bgcolor="#FF6600" summary="Un Listado de todos los Tecnicos almacenados en la base de datos"> <caption align="center" class="TEXTO2"> Técnicos Base de Datos </caption><?phpecho '<table>' ;while ($row_rstTecnic = mysql_fetch_assoc($rstTecnic)){ echo '<tr> <td>', $row_rstTecnic['NomTecnic'] ,'</td>'; if($row_rstTecnic['EstatTecnic']=="A"){ echo '<td><a href="tecnic.php?tecnic=', $row_rstTecnic['NumTecnic'] ,'" title="View details for ', $row_rstTecnic['NomTecnic'] ,'">see</a></td>'; }else{ echo '</td> <td>'; } echo '</tr>';}echo '</table>';?>[/code] Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 1, 2006 Share Posted August 1, 2006 What you need to do is look at the source HTML that this code outputs, and then you will see where you are missing opening <tr> and <td> tags. Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 I thik its a php mistake cause all the extra it displays is in PHP and not HTML[code]<table align="center"width="400" border="4" cellpadding="2" cellspacing="0" bordercolor="#FF3300" bgcolor="#FF6600" summary="Un Listado de todos los Tecnicos almacenados en la base de datos"> <caption align="center" class="TEXTO2"> Técnicos Base de Datos </caption><table><?phpwhile ($row_rstTecnic = mysql_fetch_assoc($rstTecnic)){ echo ('<tr> <td>'. $row_rstTecnic['NomTecnic'] .'</td>'); if($row_rstTecnic['EstatTecnic']=="A"){ echo ('<td><a href="tecnic.php?tecnic='. $row_rstTecnic['NumTecnic'] .'" title="View details for '. $row_rstTecnic['NomTecnic'] .'">see</a></td>'); }else{ echo '</td> <td>'; } echo '</tr>';}?></table>[/code] Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted August 1, 2006 Share Posted August 1, 2006 Why did you replace all the concatenation dots by comma's ?The following works fine:[code]<table align="center"width="400" border="4" cellpadding="2" cellspacing="0" bordercolor="#FF3300" bgcolor="#FF6600" summary="Un Listado de todos los Tecnicos almacenados en la base de datos"> <caption align="center" class="TEXTO2"> Técnicos Base de Datos </caption><?phpecho '<table>' ;while ($row_rstTecnic = mysql_fetch_assoc($rstTecnic)){ echo '<tr><td>'.$row_rstTecnic['NomTecnic'].'</td>'; if($row_rstTecnic['EstatTecnic']=="A"){ echo '<td><a href="tecnic.php?tecnic='.$row_rstTecnic['NumTecnic'].'" title="View details for '.$row_rstTecnic['NomTecnic'].'">see</a></td></tr>'; } else { echo '<td> </td></tr>'; }}echo '</table>';?>[/code]Ronald ;D Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 I only replaced that part :) for him Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted August 1, 2006 Share Posted August 1, 2006 Sorry, the 2nd echo <table> must go out.Ronald Quote Link to comment Share on other sites More sharing options...
makexitxcount Posted August 1, 2006 Author Share Posted August 1, 2006 [quote author=ronverdonk link=topic=102545.msg407125#msg407125 date=1154427748]Sorry, the 2nd echo <table> must go out.Ronald[/quote]hey,thanks, that´s nearly what i wanted to do, now i only need the names on the left side to dissapear with the see too, if you can help me you´ll be my hero :) Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 names on the left side, watcha mean Quote Link to comment Share on other sites More sharing options...
makexitxcount Posted August 1, 2006 Author Share Posted August 1, 2006 The right side is the page that i have right now, i want the names on the left side of the table to dissapear too, as the image on the left, they disappear when the 'EstatTecnic' from the mysql db is different from A[URL=http://img101.imageshack.us/my.php?image=sinttulo3jw3.jpg][IMG]http://img101.imageshack.us/img101/6936/sinttulo3jw3.th.jpg[/img][/URL]thnxs Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted August 1, 2006 Share Posted August 1, 2006 Then why don't you take the following statement out?[code]echo '<tr><td>'.$row_rstTecnic['NomTecnic'].'</td>'; [/code]Ronald ;D Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 u meen to say that if EstatTecnic is different from A then the row should not be displayed? the here is wat 2 do[code]while ($row_rstTecnic = mysql_fetch_assoc($rstTecnic)){ echo '<tr><td>'.$row_rstTecnic['NomTecnic'].'</td>'; if($row_rstTecnic['EstatTecnic']=="A"){ echo '<td><a href="tecnic.php?tecnic='.$row_rstTecnic['NumTecnic'].'" title="View details for '.$row_rstTecnic['NomTecnic'].'">see</a></td></tr>'; } else { echo '<td> </td></tr>'; }}[/code]to[code]while ($row_rstTecnic = mysql_fetch_assoc($rstTecnic)){ if($row_rstTecnic['EstatTecnic']=="A"){ echo '<tr><td>'.$row_rstTecnic['NomTecnic'].'</td>'; echo '<td><a href="tecnic.php?tecnic='.$row_rstTecnic['NumTecnic'].'" title="View details for '.$row_rstTecnic['NomTecnic'].'">see</a></td></tr>'; } else { echo '<td> </td></tr>'; }}[/code]or this incase you dont want to display names at all[code]while ($row_rstTecnic = mysql_fetch_assoc($rstTecnic)){ if($row_rstTecnic['EstatTecnic']=="A"){ echo '<td><a href="tecnic.php?tecnic='.$row_rstTecnic['NumTecnic'].'" title="View details for '.$row_rstTecnic['NomTecnic'].'">see</a></td></tr>'; } else { echo '<td> </td></tr>'; }}[/code] Quote Link to comment Share on other sites More sharing options...
makexitxcount Posted August 1, 2006 Author Share Posted August 1, 2006 done now, thnxs for yout help! Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted August 1, 2006 Share Posted August 1, 2006 Now you make me curious, because I am still guessing what you really wanted! What solution did you use?Ronald ;D Quote Link to comment Share on other sites More sharing options...
makexitxcount Posted August 1, 2006 Author Share Posted August 1, 2006 i did it like the second script that you post up there, and now it works fine Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 u mean the one which dos not show at all? Quote Link to comment Share on other sites More sharing options...
makexitxcount Posted August 1, 2006 Author Share Posted August 1, 2006 that´s what i did, maybe it has nothing to do with the one that you post, but when i saw it before, i thought it was the same (i need more sleep ;D)Here´s what i´ve finally done:[code=php:0] <?phpwhile ($row_rstTecnic = mysql_fetch_assoc($rstTecnic)){ if($row_rstTecnic['EstatTecnic']=="A"){ echo '<tr><td>'.$row_rstTecnic['NomTecnic'].'</td>'; echo '<td><a href="tecnic.php?tecnic='.$row_rstTecnic['NumTecnic'].'" title="View details for '.$row_rstTecnic['NomTecnic'].'">see</a></td></tr>'; } else { echo '<td> </td></tr>'; }}echo '</table>';?>[/code] Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 2, 2006 Share Posted August 2, 2006 its same Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.