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 . '"> ' . ";</td>\n</tr>\n\n";
$output .= "</table>\n\n";
$output .= "</DT></P>";
$output .= '</BODY>
</HTML>';
echo $output;
?>
Add link to table matrix
Moderator: General Moderators
-
scottwater
- Forum Newbie
- Posts: 18
- Joined: Tue Nov 11, 2008 9:07 pm
- Location: Richmond, VA
Re: Add link to table matrix
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
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
Re: Add link to table matrix
That's not what I was saying, If you break it there's always control Z
Try this though
Then read this http://us.php.net/strings
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
-
scottwater
- Forum Newbie
- Posts: 18
- Joined: Tue Nov 11, 2008 9:07 pm
- Location: Richmond, VA
Re: Add link to table matrix
Sweet! -Thanks -Scott