ltoto Posted September 18, 2006 Share Posted September 18, 2006 [code]<?php$sql="SELECT c.countryName, r.regionName, r.Id FROM tabCountry c, tabRegion r WHERE c.Id = r.countryId";$result = mysql_query($sql);if (!$result) { die('Invalid query: ' . mysql_error());}$country = "null";while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $cheader = $row['countryName']; if (is_null($country) || strcmp($country,$cheader) !=0){ $country = $row['countryName']; echo <<<HTML <br> <div class="homebar2"><h1>$country</h1></div>HTML; }echo <<<HTML <a href="index.php?Id=16&id={$row['Id']}">{$row['regionName']}</a><br>HTML;}?>[/code]I basically just want to add the code the the country image into this code, the image code is:[code] <img src="../images/country_<?php echo $row_rsCountry['countryImage']; ?>" [/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted September 18, 2006 Share Posted September 18, 2006 Add c.countryImage to your query SELECT clause. Use $row['countryImage'] Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 18, 2006 Author Share Posted September 18, 2006 would that not show the Image name e.g1158573641admin_hotel.jpg instead of the image Quote Link to comment Share on other sites More sharing options...
Barand Posted September 18, 2006 Share Posted September 18, 2006 Not if you put it in img src instead of "$row_rsCountry['countryImage']" Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 18, 2006 Author Share Posted September 18, 2006 [code]while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $name = $row['hotelName']; $description = $row['hotelDescription']; $rating = $row['hotelRating']; $image = $row "<img src="../images/country_ <?php echo $row_rsCountryedit ['countryImage']; ?>">"; // List the hotels echo "$name - $rating - $description<br>\n";}[/code]what do i need to change in the in the img bit to get it to workand also i did the image thing in this code and it didnt work[code]<?php$sql="SELECT c.countryName,c.countryImage, r.regionName, r.Id FROM tabCountry c, tabRegion r WHERE c.Id = r.countryId";$result = mysql_query($sql);if (!$result) { die('Invalid query: ' . mysql_error());}$country = "null";while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $cheader = $row['countryName']; if (is_null($country) || strcmp($country,$cheader) !=0){ $country = $row['countryName']; echo <<<HTML <br> <div class="homebar2"><h1>$country</h1></div> <img src="../images/country_<?php echo $row_rsCountryedit['countryImage']; ?>">HTML; }echo <<<HTML <a href="index.php?Id=16&id={$row['Id']}">{$row['regionName']}</a><br>HTML;}?> [/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted September 18, 2006 Share Posted September 18, 2006 Before it goes any further, it would be better if you post the structure of each of the relevant tables so which know which columns are in which table. Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 18, 2006 Author Share Posted September 18, 2006 tabCountry=IdcountryNamecountryImagetabRegion=IdregionNamecountryIdand this is the image code now[code]<img src="../thumb/phpThumb.php?src=../images/country_<?php echo $row_rsCountry['countryImage']; ?>&w=100&h=100&zc=1" alt="Hotels">[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted September 18, 2006 Share Posted September 18, 2006 It will be something like this (however I don't know your dir structure or image naming conventions)[code]<?php$sql="SELECT c.countryName, c.countryImage, r.regionName, r.Id FROM tabCountry c, tabRegion r WHERE c.Id = r.countryId";$result = mysql_query($sql);if (!$result) { die('Invalid query: ' . mysql_error());}$country = "null";while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $cheader = $row['countryName']; if (strcmp($country,$cheader) !=0){ $country = $row['countryName']; echo <<<HTML <br> <div class="homebar2"><h1>$cheader</h1> <img src="../images/country_{$row['countryImage']}" > </div> HTML; }echo <<<HTML <a href="index.php?Id=16&id={$row['Id']}">{$row['regionName']}</a><br>HTML;}?>[/code] Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 18, 2006 Author Share Posted September 18, 2006 ahhh that is working now, i see what i was doing wrong now, thanks a loti just need to sort it out on this page now[code]<?phpmysql_select_db($database_conTotal, $conTotal);$query_rsHotels = "SELECT * FROM tabHotel";$rsHotels = mysql_query($query_rsHotels, $conTotal) or die(mysql_error());$row_rsHotels = mysql_fetch_assoc($rsHotels);$totalRows_rsHotels = mysql_num_rows($rsHotels);$sql="SELECT * FROM tabHotel WHERE regionId = $id";$result = mysql_query($sql);if (!$result) { die('Invalid query: ' . mysql_error());}while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $name = $row['hotelName']; $description = $row['hotelDescription']; $rating = $row['hotelRating']; <img src="../images/hotel_{$row['hotelImage']}" > // List the hotels echo "$name - $rating - $description<br> \n";}mysql_free_result($rsHotels);?>[/code] Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 18, 2006 Author Share Posted September 18, 2006 Im trying not to double post, although i just did, this is the image code now [code]<img src=../images/country_{$row['countryImage']>[code]and this is the error Parse error: parse error, unexpected '<' inand thisis the code from the whole page[code]<?phpmysql_select_db($database_conTotal, $conTotal);$query_rsHotels = "SELECT * FROM tabHotel";$rsHotels = mysql_query($query_rsHotels, $conTotal) or die(mysql_error());$row_rsHotels = mysql_fetch_assoc($rsHotels);$totalRows_rsHotels = mysql_num_rows($rsHotels);$sql="SELECT * FROM tabHotel WHERE regionId = $id";$result = mysql_query($sql);if (!$result) { die('Invalid query: ' . mysql_error());}while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $name = $row['hotelName']; $description = $row['hotelDescription']; $rating = $row['hotelRating']; $image = <img src=../images/country_{$row['countryImage']> // List the hotels echo "$name $image $rating $description<br> \n";}mysql_free_result($rsHotels);?>[/code]sorry that i keep updating this topic just that it is quite Urgent now[/code][/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 18, 2006 Share Posted September 18, 2006 $image = [b]"[/b]<img src=../images/country_{$row['countryImage']>[b]";[/b] Your code omitted the opening and closing quotes to the construction of the $image string, and left out the closing ; Quote Link to comment Share on other sites More sharing options...
karthikeyan_coder Posted September 18, 2006 Share Posted September 18, 2006 Try AndyB's solution as well as mine too...Find:$image = <img src=../images/country_{$row['countryImage']> Replace with:$image = "<img src=../images/country_{".$row['countryImage']."}>";Thank you. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 18, 2006 Share Posted September 18, 2006 Andy's is missing the closing curly$image = "<img src=../images/country_{$row['countryImage'][color=red]}[/color]>"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.