need help with foreach

This is a discussion on need help with foreach within the PHP General forums, part of the PHP Programming Forums category; I want to tell the server to do 2 things when I click on the "jobType" link. This ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-31-2006
melinem@earthlink.net
 
Posts: n/a
Default need help with foreach

I want to tell the server to do 2 things when I click on the
"jobType" link.

This is the code that I have now which displays the "art" when I
click on "jobType"

foreach($row as $jobType)
{
$row = mysql_fetch_array($result2,MYSQL_ASSOC);
echo "<a href=client.php?art=".$row['pix']." border='0'>{$row
['jobType']}</a>\n";
}

I now want to, with the same click, also show the url if I have a url
for that "jobType" in my database column called "url".

Thank you for any help.
Reply With Quote
  #2 (permalink)  
Old 10-31-2006
Dave Hamber
 
Posts: n/a
Default Re: [PHP] need help with foreach

Its not very clear what you want to achieve with that code snippet.

If you are pulling database rows out of your database with
mysql_fetch_array(), then you do not need a foreach loop.

I think you may want something like this, but without knowing your
database table structure and the query you have used it is only a guess.

while($row = mysql_fetch_array($result2,MYSQL_ASSOC)){

echo "<a href=client.php?art=".$row['pix']."
border='0'>{$row['jobType']}</a>\n";
if($row['url']!='')echo "html to use with ".$row['url'];

}


On 31/10/2006 10:09 melinem@earthlink.net wrote:
> I want to tell the server to do 2 things when I click on the "jobType"
> link.
>
> This is the code that I have now which displays the "art" when I click
> on "jobType"
>
> foreach($row as $jobType)
> {
> $row = mysql_fetch_array($result2,MYSQL_ASSOC);
> echo "<a href=client.php?art=".$row['pix']."
> border='0'>{$row['jobType']}</a>\n";
> }
>
> I now want to, with the same click, also show the url if I have a url
> for that "jobType" in my database column called "url".
>
> Thank you for any help.
>
> --PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

Reply With Quote
  #3 (permalink)  
Old 10-31-2006
Richard Lynch
 
Posts: n/a
Default Re: [PHP] need help with foreach

On Tue, October 31, 2006 4:09 am, melinem@earthlink.net wrote:
> I want to tell the server to do 2 things when I click on the
> "jobType" link.
>
> This is the code that I have now which displays the "art" when I
> click on "jobType"
>
> foreach($row as $jobType)
> {
> $row = mysql_fetch_array($result2,MYSQL_ASSOC);
> echo "<a href=client.php?art=".$row['pix']." border='0'>{$row
> ['jobType']}</a>\n";


echo "<a href=\"$row[url]\">$row[url]</a>\n";

> I now want to, with the same click, also show the url if I have a url
> for that "jobType" in my database column called "url".


I'm assuming you don't mean that you want the user to see the image
and then be auto-forwarded to the 'url' from the db...

That's a fish of a different color.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:44 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0