Jump to content

Adding Image , Please Help Me :)


ltoto

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]
Link to comment
https://forums.phpfreaks.com/topic/21137-adding-image-please-help-me/
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]
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]
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]
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]

Archived

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

×
×
  • Create New...

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.