Originally posted by ednark
note:
i am unfamiliar with useing $row{'col'} syntax, i thought it was $row['col'] syntax
i know you can use $string{$i} syntax to access and individual character in that position in the string...
does your code actually work like that... if so i would like to remember i can use that syntax [/B]
ednark,
Thanks so much for your help. I have successfully implemented your code with the additional help you provided in your last post.
Below is the URL to the results page and the code I am using to achieve those results. I used the search "bob" and received 13 results so you can see how it handles the blank cells.
http://www.rhodemap.com/rm/datafeeds/casablanca6.php
<?php
$link = mysql_connect("host", "name", "pwd")
or die("Could not connect");
mysql_select_db("posters") or die("Could not select database");
$query = "SELECT * FROM movies WHERE CategoryName LIKE '%bob%' OR Title LIKE '%bob%' ";
$result = mysql_query($query) or die("Query failed");
$array = array( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' );
$columns = 3;
echo "<table align=center width=100% border=0>\n";
while ($row = mysql_fetch_array($result)) {
echo "\t<tr>\n";
echo "\t<td align=center width=33%><br><A HREF=\"http://affiliates.allposters.com/link/redirect.asp?aid=781144&item=" .$row['ProductNumber']. "\"><IMG SRC=\"http://images.allposters.com/images/" .$row['Directory']. "/" .$row['FileName']. "\" WIDTH=" .$row['ThumbWidth']. " HEIGHT=" .$row['ThumbHeight']. " BORDER=0></A>\n";
echo "\t<br><A HREF=\"http://affiliates.allposters.com/link/redirect.asp?aid=781144&item=" .$row['ProductNumber']. "\">" .$row['Title']. "</A>\n";
echo "\t<br>" .$row['ProductType']. "\n";
echo "\t<br>" .$row['PosterHeight']. " x " .$row['PosterWidth']. "<br></td>\n";
for ( $i=1; $i<$columns; $i++ ) {
if ($row = mysql_fetch_array($result)) {
echo "\t<td align=center width=33%><br><A HREF=\"http://affiliates.allposters.com/link/redirect.asp?aid=781144&item=" .$row['ProductNumber']. "\"><IMG SRC=\"http://images.allposters.com/images/" .$row['Directory']. "/" .$row['FileName']. "\" WIDTH=" .$row['ThumbWidth']. " HEIGHT=" .$row['ThumbHeight']. " BORDER=0></A>\n";
echo "\t<br><A HREF=\"http://affiliates.allposters.com/link/redirect.asp?aid=781144&item=" .$row['ProductNumber']. "\">" .$row['Title']. "</A>\n";
echo "\t<br>" .$row['ProductType']. "\n";
echo "\t<br>" .$row['PosterHeight']. " x " .$row['PosterWidth']. "<br></td>\n";
} else {
echo "\t\t<td><br /></td>\n";
}
}
echo "\t<tr>\n";
}
echo "</table>\n";
mysql_free_result($result);
mysql_close($link);
?>
The $row{'col'} syntax seemed to be working fine but I changed it to the $row['col'] syntax you mentioned just in case.
Just out of curiosity and an attempt to learn this stuff better, what does the line $array = array 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' ); accomplish? I can't even see where the variable "array" is even called again.
Thanks again for your detailed and friendly help.
Keith