Error with code.. Please check it out
I have two tables and I want to show a list items of particular table as hyperlink only if its value exist in another table. Otherwise it show value as plain text not hyperlink.
Considering example...
$result= mysql_query("select * from tbl_songlist_info order by song_title") or die(mysql_error());
$resultpoet= mysql_query("select * from tbl_poet_info") or die(mysql_error());
$rowpoet= mysql_fetch_array($resultpoet);
while($row = mysql_fetch_array($result))
Now I have to show values of $row
as hyperlink only if its value exist in $rowpoet
.. I have used in array function. please chk it out...
<? if (in_array($row['poet_name'],$rowpoet)) { ?>
<a href="poet.php?title=<?=$row['poet_name'] ?&开发者_开发问答gt;"><? } ?>
<?=$row['poet_name'] ?> </a>
please check this code. All value are showing as plain text if value exist in other table than also...
I think you want something like :
<? if (in_array($row['poet_name'],$rowpoet)) { ?>
<a href="poet.php?title=<?=$row['poet_name'] ?>"><?=$row['poet_name'] ?></a>
<? } else { ?>
<?=$row['poet_name'] ?>
<? } ?>
unless i misunderstand that will check for 'poet_name' field inside $rowpoet array and if it exists put a link, otherwise if not in array then put plain text.
Hope that helps
精彩评论