Add link to table matrix

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
scottwater
Forum Newbie
Posts: 18
Joined: Tue Nov 11, 2008 9:07 pm
Location: Richmond, VA

Add link to table matrix

Post by scottwater »

This code creates, basically a matrix of data. I found it here. It displays pictures and caption(s) and works great. I'm trying to add a link and can't get it to work of course. I'm real new at php.. and all internet programming.. and becomming addicted. Thanks -Scott

<?php
$retid = mysql_query($query_Recordset1, $SQLConnect) or die(mysql_error());

# display results
$output .= "<P><DT><B>$category</B><BR>\n\n";
$output .= "<table>\n\n";
$howmany = mysql_num_rows($retid);
$rowmax = 5;
for($x = 0; $row = mysql_fetch_array($retid); $x++)
{
if($x % $rowmax == 0)
$output .= "<tr>\n";
$id = $row["id"];
$username = $row["username"]; // <?php echo substr_replace($row_Recordset1['image_front'],'thumb_',6,0);
$name = $row["name"];
$image_front = substr_replace($row['image_front'],'thumb_',6,0);
$image_back = $row["image_back"];
$material = $row["material"];
//$photographer = $row["username"];

$output .= "<td><img src =\"$image_front\"><br>$name $material </td>"; // this works


$output .= "<td><a href="blowup.php?recordID=<?php echo $row['id']?><img src =\"$image_front\"><br>$name $material </a></td>"; // this does not work



if($x % $rowmax == $rowmax - 1)
$output .= "\r</tr>\n\n";
}

if($left = (($howmany + $rowmax - 1) % $rowmax))
$output .= '<td colspan="' . $left . '">&nbsp' . ";</td>\n</tr>\n\n";

$output .= "</table>\n\n";

$output .= "</DT></P>";

$output .= '</BODY>
</HTML>';

echo $output;

?>
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Add link to table matrix

Post by josh »

You're probably going to want to learn string handling and string concatenation in PHP, the manual is a nice starting point ( and the grocery store for some caffeine )
scottwater
Forum Newbie
Posts: 18
Joined: Tue Nov 11, 2008 9:07 pm
Location: Richmond, VA

Re: Add link to table matrix

Post by scottwater »

I know, I started with php about 2 weeks ago and spend every extra minute with it - so you're right on with the coffee and code, and that I have no business messing with this great piece of code, but I'm curious to see the right syntax. -Scott
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Add link to table matrix

Post by josh »

That's not what I was saying, If you break it there's always control Z

Try this though

Code: Select all

 
$output .= "<td><a href="blowup.php?recordID=<?php echo $row['id']?><img src =\"$image_front\"><br>$name $material </a></td>"; // yours
$output .= "<td><a href=\"blowup.php?recordID=" . $row['id'] . "\"><img src =\"$image_front\"><br>" . $name . " " . $material . "</a></td>"; // mine
 
Then read this http://us.php.net/strings
scottwater
Forum Newbie
Posts: 18
Joined: Tue Nov 11, 2008 9:07 pm
Location: Richmond, VA

Re: Add link to table matrix

Post by scottwater »

Sweet! -Thanks -Scott
Post Reply