Jump to content

What´s wrong on this script?


makexitxcount

Recommended Posts

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
Share on other sites

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
Share on other sites

There is a chance he might have a script above this, dun u think
but ther is no sarting for the TD in the beginning of the while, check that
and 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
Share on other sites

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>
<?php
echo '<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>&nbsp;<td>';
  }
  echo '</tr>';
}
echo '</table>';
?>[/code]
Link to comment
Share on other sites

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>
<?php
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>&nbsp;<td>';
  }
  echo '</tr>';
}
?>
</table>
[/code]
Link to comment
Share on other sites

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>
<?php
echo '<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>&nbsp;</td></tr>';
  }
}
echo '</table>';
?>[/code]

Ronald  ;D
Link to comment
Share on other sites

[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
Share on other sites

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
Share on other sites

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>&nbsp;</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>&nbsp;</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>&nbsp;</td></tr>';
  }
}
[/code]
Link to comment
Share on other sites

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]  <?php

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>&nbsp;</td></tr>';
  }
}
echo '</table>';
?>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.