Jump to content


Photo

How to make this work???


  • Please log in to reply
1 reply to this topic

#1 makexitxcount

makexitxcount
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 26 July 2006 - 10:34 AM

i´m trying to hide the values "NomTecnic" and the text "see" when "EstatTecnic" is different from A, but i just can do it with the "NomTecnic" value, does somebody knows how to make "see" to not show up when the value "EstatTecnic"  is different from A.
Thanks

<?php do { ?>
 
      <tr>

  <td><?php if($row_rstTecnic['EstatTecnic']=="A"){
echo $row_rstTecnic['NomTecnic'];} ?></td>
        <td> <a href="tecnic.php?tecnic=<?php echo $row_rstTecnic['NumTecnic']; ?>">see</a></td>
      </tr>
      <?php } while ($row_rstTecnic = mysql_fetch_assoc($rstTecnic)); ?>
    </table>

#2 ozPATT

ozPATT
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 26 July 2006 - 11:04 AM

not sure i understand entirely what you want to do... do you mean you ONLY want the link to show if "A" is present? The following code will only display the link if EstatTecnic is equal to "A".

<?php
	//build and run query
	$sql = "SELECT * FROM ...";
	$result = mysql_query($sql);
	
	//is something wrong?
	if(!$result) {
		echo mysql_error();
	}
	
	//count results
	$count = mysql_num_rows($result);
	
	//if no results, tell user, if results, display.
	if($count == 0) {
		$display = ('<p>There are no results.</p>'); //modify error message to be what you want.
	}
	else {
		//build array to pull data from db
		while($row = mysql_fetch_array) {
			//set vars
			$EstatTecnic = $row['NumTecnic'];
		}
		
		//build table, only display link if EstatTecnic is equal to "A"
		$display = ('<table><tr><td>');
		if($EstatTecnic == "A") {
			$display .= ('<a href="tecnic.php?tecnic=' . $EstatTecnic . '" title="see" target="_self">see</a>');
		}
		$display .= ('</td></tr></table>');
	}
	
	//echo everything
	echo($display);
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users