Forum Moderators: coopster
once i print the list of contacts i want to be able to click a name and see the contact details for that person pop up IF they have said yes to letting there info be seen.
i started with the code below and can't seem to get past the if $detail if section, any suggestions are welcome
$query1="SELECT `icontact_id`, CONCAT(`icfname`,' ',`iclname`) AS `names`, `ictitle`, `icmember`
FROM icontacts ";
$result1 = mysql_query($query1);
while($row = mysql_fetch_array($result1, MYSQL_ASSOC))
$detail= "if(`icmember` == yes)";
{"<a href=`details8.php`>($row[`icmember`])</a>";}
else
{"$row[`icmember`]";}
echo "ID :{$row['icontact_id']}"." "."NAME :{$row['names']}"." - "."TITLE :{$row['ictitle']}"." "."$detail <br>";
The syntax you are using will not work. Try the following:
$detail = (icmember` == 'yes') ? '<a href="details8.php">('.$row['icmember'].')</a>' : $row['icmember'];
This is called a ternary conditional operator [us2.php.net].
after your reply d40sithui i got ( see below) and it doesn't show the id, name title or the yes no link to the details, but i am getting closer and had no error messages, , i'll keep trying
CONTACT DETAILS
ID : NAME : - TITLE :
check out my top post and see if you can help me out, thanks for any help you can give me
$query1="SELECT `icontact_id`, CONCAT(`icfname`,' ',`iclname`) AS `names`, `ictitle`, `icmember`
FROM icontacts ORDER BY `icontact_id`";
$result1 = mysql_query($query1);
while($row = mysql_fetch_array($result1, MYSQL_ASSOC))
{
echo "<center>";
echo "ID :{$row['icontact_id']}"." "."NAME :{$row['names']}"." - "."TITLE :{$row['ictitle']}"." ";
if ($row['icmember'] == "yes")
echo "show detail {$row['icmember']}";
else
echo "no detail {$row['icmember']}";
echo "<br><br>";
echo "</center>";
}
if ([url=http://www.php.net/strtolower]strtolower[/url]($row['icmember']) == "yes")
if ($row['icmember'] == "yes")
echo "show detail {$row['icmember']}";
else
echo "no detail {$row['icmember']}";
my output is like this, the no after mixer should be a show detail
ID :33 NAME :roy rogers - TITLE :Audio Mixer no detail Yes
ID :34 NAME :lou ralls - TITLE :Gaffer no detail No
no detail [b]Yes[/b]
The "Yes" is capital, like I assumed. Try the code that I gave you in my last post.
{
echo "ID :{$row['icontact_id']}"." "."NAME :{$row['names']}"." - "."TITLE :{$row['ictitle']}"." ";
if (strtolower($row['icmember']) == "yes")
{echo "<a href=`details1.php`>Contact Info{$row['icmember']}</a>";
7echo "<form method==`post` action==`details1.php`>";
8echo "<select name == ($row['icontact_id']) >";
9echo "<input type==`submit` value==`Contact Details`>";
echo "</form>";}
else
{echo "{$row['icmember']} Contact Info";}
echo "<br><br>";
}