By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,064 Members | 1,445 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,064 IT Pros & Developers. It's quick & easy.

Linking a

P: n/a
Hi - I am using this code

echo "<tr><td></td><td id=tablesdirhead>Property Information</td><td
id=tablesdirhead width='100'>Agent Name</td><td id=tablesdirhead
width='150'>Contact Info</td></tr>\n";
while ($myrow = mysql_fetch_row($result))
{
$row = 1-$row;
$color = ($row==0)?"#F5F5F5":"#F0F8FF";
printf("<tr bgcolor=$color><td>%s</td><td>%s</td><td>%s</td><td>%s</
td></tr>\n",
$myrow[5], $myrow[3], $myrow[0], $myrow[1]);
}
echo "</table>\n";
?>

But would like to give the fourth "$myrow[1]" a PHP link like

<a class="dir" href="processformImage.php?action=&ID=<?php echo
$row["StoreID"]; ?>">$myrow[1]</a>

But can't seem to find anywhere on the web that shows this can even be
done

May 18 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
On May 18, 2:47 pm, bokke <micr...@gmail.comwrote:
Hi - I am using this code

echo "<tr><td></td><td id=tablesdirhead>Property Information</td><td
id=tablesdirhead width='100'>Agent Name</td><td id=tablesdirhead
width='150'>Contact Info</td></tr>\n";
while ($myrow = mysql_fetch_row($result))
{
$row = 1-$row;
$color = ($row==0)?"#F5F5F5":"#F0F8FF";
printf("<tr bgcolor=$color><td>%s</td><td>%s</td><td>%s</td><td>%s</
td></tr>\n",
$myrow[5], $myrow[3], $myrow[0], $myrow[1]);}

echo "</table>\n";
?>

But would like to give the fourth "$myrow[1]" a PHP link like

<a class="dir" href="processformImage.php?action=&ID=<?php echo
$row["StoreID"]; ?>">$myrow[1]</a>

But can't seem to find anywhere on the web that shows this can even be
done
echo " <a class=\"dir\" href=\"processformImage.php?action=&ID=
$row["StoreID"]\">$myrow[1]</a>";

Flamer.

May 18 '07 #2

P: n/a
At Thu, 17 May 2007 20:25:13 -0700, flamer di******@hotmail.com let his
monkeys type:
On May 18, 2:47 pm, bokke <micr...@gmail.comwrote:
>Hi - I am using this code

echo "<tr><td></td><td id=tablesdirhead>Property Information</td><td
id=tablesdirhead width='100'>Agent Name</td><td id=tablesdirhead
width='150'>Contact Info</td></tr>\n";
while ($myrow = mysql_fetch_row($result))
{
$row = 1-$row;
$color = ($row==0)?"#F5F5F5":"#F0F8FF";
printf("<tr bgcolor=$color><td>%s</td><td>%s</td><td>%s</td><td>%s</
td></tr>\n",
$myrow[5], $myrow[3], $myrow[0], $myrow[1]);}

echo "</table>\n";
?>

But would like to give the fourth "$myrow[1]" a PHP link like

<a class="dir" href="processformImage.php?action=&ID=<?php echo
$row["StoreID"]; ?>">$myrow[1]</a>

But can't seem to find anywhere on the web that shows this can even be
done

echo " <a class=\"dir\" href=\"processformImage.php?action=&ID=
$row["StoreID"]\">$myrow[1]</a>";

Flamer.
Both array references need to be enclosed in braces for this to work.
Why not use heredoc syntax:

echo <<<END
<a class="dir"
href= "processformImage.php?action=&ID=$row['StoreID']">$myrow[1]</a>
END;

Sh.
May 18 '07 #3

P: n/a
bokke wrote:
$row = 1-$row;
$color = ($row==0)?"#F5F5F5":"#F0F8FF";
This is bizarre. It took me a couple of minutes to figure out how it
worked. A more usual method might be:

$color = (++$row%2 == 1)?'#F5F5F5':'#F0F8FF';

This would also allow you to count the rows in $row, which might be useful
for some reason.

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux
May 18 '07 #4

P: n/a
Message-ID: <1c************@ophelia.g5n.co.ukfrom Toby A Inkster
contained the following:
> $row = 1-$row;
$color = ($row==0)?"#F5F5F5":"#F0F8FF";

This is bizarre.
I like it. :-)
>$color = (++$row%2 == 1)?'#F5F5F5':'#F0F8FF';
I like that too. I must be easily pleased.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 18 '07 #5

P: n/a
Geoff Berrow wrote:
Toby A Inkster contained the following:
>bokke wrote:
>>$row = 1-$row;
$color = ($row==0)?"#F5F5F5":"#F0F8FF";

This is bizarre.

I like it. :-)
I don't doubt its genius -- just its legibility.

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux
May 18 '07 #6

P: n/a
Geoff Berrow wrote:
Message-ID: <1c************@ophelia.g5n.co.ukfrom Toby A Inkster
contained the following:
>> $row = 1-$row;
$color = ($row==0)?"#F5F5F5":"#F0F8FF";
This is bizarre.

I like it. :-)
So you will like this, I hope:

$color="#F5F5F5";
$delta="#F0F8FF"^$c;

while(...)
{
....
$color^=$delta;
....
}
May 19 '07 #7

P: n/a
On May 18, 7:47 am, bokke <micr...@gmail.comwrote:
Hi - I am using this code

echo "<tr><td></td><td id=tablesdirhead>Property Information</td><td
id=tablesdirhead width='100'>Agent Name</td><td id=tablesdirhead
width='150'>Contact Info</td></tr>\n";
while ($myrow = mysql_fetch_row($result))
{
$row = 1-$row;
$color = ($row==0)?"#F5F5F5":"#F0F8FF";
printf("<tr bgcolor=$color><td>%s</td><td>%s</td><td>%s</td><td>%s</
td></tr>\n",
$myrow[5], $myrow[3], $myrow[0], $myrow[1]);}

echo "</table>\n";
?>

But would like to give the fourth "$myrow[1]" a PHP link like

<a class="dir" href="processformImage.php?action=&ID=<?php echo
$row["StoreID"]; ?>">$myrow[1]</a>

But can't seem to find anywhere on the web that shows this can even be
done
And instead of writing printf();, you should write like this:

echo '<tr>
<td>'.$myrow[0].'</td>
<td>'.$myrow[1].'</td>
</tr>
';

Here you can easily format/add anything for any column.
echo '<tr>
<td>'.$myrow[0].'</td>
<td>'.$myrow[1].'</td>
<td>'.$myrow[2].'</td>
<td>'.$myrow[3].'</td>
<td>'."<a class='dir' href='/index.php?storeID=$row[9]'>
$myrow[4]</a>.'</td>
</tr>
';
satya61229.blogspot.com

May 21 '07 #8

P: n/a
At Sun, 20 May 2007 23:35:06 -0700, satyakaran let his monkeys type:
On May 18, 7:47 am, bokke <micr...@gmail.comwrote:
>Hi - I am using this code

echo "<tr><td></td><td id=tablesdirhead>Property Information</td><td
id=tablesdirhead width='100'>Agent Name</td><td id=tablesdirhead
width='150'>Contact Info</td></tr>\n"; while ($myrow =
mysql_fetch_row($result))
{
$row = 1-$row;
$color = ($row==0)?"#F5F5F5":"#F0F8FF";
printf("<tr
bgcolor=$color><td>%s</td><td>%s</td><td>%s</td><td>%s</
td></tr>\n",
$myrow[5], $myrow[3], $myrow[0], $myrow[1]);}

echo "</table>\n";
?>

But would like to give the fourth "$myrow[1]" a PHP link like

<a class="dir" href="processformImage.php?action=&ID=<?php echo
$row["StoreID"]; ?>">$myrow[1]</a>

But can't seem to find anywhere on the web that shows this can even be
done

And instead of writing printf();, you should write like this:

echo '<tr>
<td>'.$myrow[0].'</td>
<td>'.$myrow[1].'</td>
</tr>
';

Here you can easily format/add anything for any column. echo '<tr>
<td>'.$myrow[0].'</td>
<td>'.$myrow[1].'</td>
<td>'.$myrow[2].'</td>
<td>'.$myrow[3].'</td>
<td>'."<a class='dir' href='/index.php?storeID=$row[9]'>
$myrow[4]</a>.'</td>
</tr>
';
satya61229.blogspot.com
Which I personally find a surefire way of introducing many typos.
Using double quotes instead of concatenation and braces around the
$myrow[n] 's is a little less error-prone if you ask me, then sprintf() is
a candidate you may want to consider and better still imho is using
heredoc syntax in these cases. Stepping out of php and surrounding all the
array references with <?PHP ;?is over the top here.

echo <<<HTML_END
<tr>
<td>$myrow[0]</td>
<td>$myrow[1]</td>
<td>$myrow[2]</td>
<td>$myrow[3]</td>
<td><a class='dir'
href='/index.php?storeID=$row[9]'>$myrow[4]</a></td>
</tr>
HTML_END;

Sh.
May 21 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.