Such is the request

$month = $_GET['month']; $day = $_GET['day']; $sql = mysql_query('SELECT * FROM client WHERE month = "'.$month.'" and day = "'.$day.'"') or die (mysql_error()); while($r = mysql_fetch_array($sql)){ print"<br><b>Результат:</b> <a href=../index.php?option=content&task=view&id=".$r['url'].">".$r['name']."</a>"; } 

I think you understand the result. client.php?month=1&day=22 displays the names of clients for the month of January, the 22nd day, and also references from the url column of the client table. And how to make it so that in the absence of a link to the client, the code a href not set? So it was just a name without links?

    1 answer 1

    An elementary test for "emptiness" to do.

     while($r = mysql_fetch_array($sql)){ if($r['url'] != ''){ $link = '../index.php?option=content&task=view&id='.$r['url']; } else { $link = '#'; } echo '<p><strong>Результат:</strong><a href="'.$link.'">'.$r['name'].'</a></p>'; } 
    • I think in terms of usability, so as not to encourage the user with a link like <a href="#'> </a>, to fix: while ($ r = mysql_fetch_array ($ sql)) {echo '<p> <strong> Result: < / strong> '; if ($ r [' url ']! =' ') {$ link =' ../index.php?option=content&task=view&id='.$r['url ']; echo' < a href = "'. $ link.'"> '. $ r [' name '].' </a> </ p> ';} else {echo $ r [' name '].' </ p> ';}} - just495