Jump to content


Photo

What´s wrong on this script?


  • Please log in to reply
21 replies to this topic

#1 makexitxcount

makexitxcount
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 01 August 2006 - 08:20 AM

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:
Posted Image
thnxs

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


#2 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 01 August 2006 - 10:02 AM

Get rid of the semi colons after the closing accolades (twice):
};

Ronald  ;D
RTFM is an almost extinct art form, it should be subsidized.

#3 makexitxcount

makexitxcount
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 01 August 2006 - 10:08 AM

thnxs, but it keeps without working

#4 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 01 August 2006 - 10:09 AM

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.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#5 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 01 August 2006 - 10:12 AM

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
<?
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>
*bumped*
I am a PHP Guru, ask me questions if you want to

#6 makexitxcount

makexitxcount
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 01 August 2006 - 10:13 AM

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.
<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>';
?>


#7 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 01 August 2006 - 10:17 AM

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.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#8 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 01 August 2006 - 10:19 AM

I thik its a php mistake cause all the extra it displays is in PHP and not HTML

<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>

I am a PHP Guru, ask me questions if you want to

#9 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 01 August 2006 - 10:20 AM

Why did you replace all the concatenation dots by comma's ?
The following works fine:
<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>';
?>

Ronald  ;D
RTFM is an almost extinct art form, it should be subsidized.

#10 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 01 August 2006 - 10:21 AM

I only replaced that part :) for him
I am a PHP Guru, ask me questions if you want to

#11 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 01 August 2006 - 10:22 AM

Sorry, the 2nd echo <table>  must go out.

Ronald

RTFM is an almost extinct art form, it should be subsidized.

#12 makexitxcount

makexitxcount
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 01 August 2006 - 10:35 AM

Sorry, the 2nd echo <table>  must go out.

Ronald

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 :)

#13 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 01 August 2006 - 10:39 AM

names on the left side, watcha mean
I am a PHP Guru, ask me questions if you want to

#14 makexitxcount

makexitxcount
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 01 August 2006 - 10:43 AM

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
Posted Image

thnxs

#15 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 01 August 2006 - 10:48 AM

Then why don't you take the following statement out?

echo '<tr><td>'.$row_rstTecnic['NomTecnic'].'</td>'; 

Ronald  ;D
RTFM is an almost extinct art form, it should be subsidized.

#16 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 01 August 2006 - 10:51 AM

u meen to say that if EstatTecnic is different from A then the row should not be displayed? the here is wat 2 do
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>'; 
   }
}

to

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>'; 
   }
}

or this incase you dont want to display names at all

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>'; 
   }
}

I am a PHP Guru, ask me questions if you want to

#17 makexitxcount

makexitxcount
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 01 August 2006 - 10:52 AM

done now, thnxs for yout help!

#18 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 01 August 2006 - 10:56 AM

Now you make me curious, because I am still guessing what you really wanted! What solution did you use?

Ronald  ;D
RTFM is an almost extinct art form, it should be subsidized.

#19 makexitxcount

makexitxcount
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 01 August 2006 - 10:59 AM

i did it like the second script that you post up there, and now it works fine

#20 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 01 August 2006 - 11:07 AM

u mean the one which dos not show at all?
I am a PHP Guru, ask me questions if you want to




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users