one click - two actions?

From: Date: Mon, 13 Nov 2006 09:28:00 +0000
Subject: one click - two actions?
Groups: php.general 
Request: Send a blank email to php-general+get-244543@lists.php.net to get a copy of this message
Could someone please help me figure out how to show some description (where applicable) at the same time as I show an image, when I click on a link, without repeating the entire query? The image and the description are both in the same table in my database. I now show the image when I click on the link which is good, but the description stays on at all times instead of appearing only when active. http://www.squareinch.net/single_page.php This is the code I have for the image area: /* query 1 from client */ $query = "SELECT * FROM client where status='active' or status='old' order by companyName"; $result = mysql_query($query) or die ("Couldn't execute query"); while ($aaa = mysql_fetch_array($result,MYSQL_ASSOC)) { echo "<span class='navCompany'>{$aaa['companyName']}</span><span class='navArrow'> > </span>\n"; /* query 2 from job */ $query = "SELECT * FROM job WHERE companyId='{$aaa['companyId']}'"; $result2 = mysql_query($query) or die ("Couldn't execute query2"); foreach($aaa as $jobType) { $bbb = mysql_fetch_array($result2,MYSQL_ASSOC); echo "<span class='navText'><a href='single_page.php?art=".$bbb['pix']."'>{$bbb['jobType']}</a></span>\n"; } echo "<br>"; } ?> </div> <div class="navbox3"><?php $image = $_GET['art']; ?> <img src="images/<?php print ($image) ?>" alt="Portfolio Item" border="0" width="285" height="285"></div> This is the code I have for the description area: /* query 1 from client */ $query = "SELECT * FROM client where status='active' or status='old' order by companyName"; $result = mysql_query($query) or die ("Couldn't execute query"); while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { /* query 2 from job */ $query = "SELECT * FROM job WHERE companyId='{$row['companyId']}'"; $result2 = mysql_query($query) or die ("Couldn't execute query2"); $url = mysql_query($result2); foreach($row as $url) { $row = mysql_fetch_array($result2,MYSQL_ASSOC); if ("url={$row['url']}") echo "<span class='navText'><a href='{$row['url']}'>{$row['web']}</a></span>"; } echo "<br>"; } ?>

« previous php.general (#244543) next »