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] Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/ 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 Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66915 Share on other sites More sharing options...
makexitxcount Posted August 1, 2006 Author Share Posted August 1, 2006 thnxs, but it keeps without working Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66918 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. Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66919 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* Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66923 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] Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66924 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. Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66927 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] Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66930 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 Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66933 Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 I only replaced that part :) for him Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66934 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 Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66936 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 :) Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66945 Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 names on the left side, watcha mean Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66947 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 Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66949 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 Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66952 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] Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66954 Share on other sites More sharing options...
makexitxcount Posted August 1, 2006 Author Share Posted August 1, 2006 done now, thnxs for yout help! Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66955 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 Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66959 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 Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66961 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? Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-66965 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] Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-67020 Share on other sites More sharing options...
Chetan Posted August 2, 2006 Share Posted August 2, 2006 its same Link to comment https://forums.phpfreaks.com/topic/16184-what%C2%B4s-wrong-on-this-script/#findComment-67704 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.