Jump to content

showing link if results ==1


runnerjp

Recommended Posts

i cant get my head round this lol

 

<?php $sql = "SELECT * FROM events WHERE date='$d-$m-$y'";
	echo $sql;
$postsresult = mysql_query($sql);
$row = mysql_fetch_array($postsresult);
$num = mysql_num_rows($postsresult);
	if($row['event'] == 1)
    { echo "<td class='tcell'>";
        echo "<a href=\"http://www.runningprofiles.com/test2.php?month=$d-$m-$y\" rel=\"facebox\" onClick=\"document.f.eventdate.value='$m-$d-$y';\">$d</a>";
        echo "</td>\n";

}

else {echo "<td class='tcell'>";
        echo "<a href=\"1\" rel=\"facebox\" onClick=\"document.f.eventdate.value='$m-$d-$y';\">$d</a>";
        echo "</td>\n";}?>

 

baiscly if $row['event'] has a event under it during that date then i want to display i link.. but if not the just text $d....

 

i canty figure out this part though lol if($row['event'] == 1)  how would i find number of results for that row?

Link to comment
https://forums.phpfreaks.com/topic/154417-showing-link-if-results-1/
Share on other sites

The HTML code you're echoing includes a link so if all you want to do is display the $d in the table cell when no events occur then replace:

echo "<a href=\"1\" rel=\"facebox\" onClick=\"document.f.eventdate.value='$m-$d-$y';\">$d</a>";

with:

echo $d;

 

I'm not sure what you mean by your second question. Can you be more specific and include example data if possible?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.