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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.