Jump to content

Archived

This topic is now archived and is closed to further replies.

ltoto

Adding Image , Please Help Me :)

Recommended Posts

[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]

Share this post


Link to post
Share on other sites
would that not show the Image name e.g

1158573641admin_hotel.jpg

instead of the image

Share this post


Link to post
Share on other sites
[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 work

and 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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
tabCountry=

Id
countryName
countryImage


tabRegion=
Id
regionName
countryId


and this is the image code now

[code]<img src="../thumb/phpThumb.php?src=../images/country_<?php echo $row_rsCountry['countryImage']; ?>&amp;w=100&amp;h=100&amp;zc=1"  alt="Hotels">[/code]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
ahhh that is working now, i see what i was doing wrong now, thanks a lot

i just need to sort it out on this page now

[code]<?php
mysql_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]

Share this post


Link to post
Share on other sites
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 '<' in

and thisis the code from the whole page

[code]<?php
mysql_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]

Share this post


Link to post
Share on other sites
$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 ;

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Andy's is missing the closing curly

$image =  "<img src=../images/country_{$row['countryImage'][color=red]}[/color]>";

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.