Jump to content


Photo

Adding Image , Please Help Me :)


  • Please log in to reply
12 replies to this topic

#1 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 18 September 2006 - 09:20 AM

<?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;
}
?>

I basically just want to add the code the the country image into this code, the image code is:

<img src="../images/country_<?php echo $row_rsCountry['countryImage']; ?>"


#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 18 September 2006 - 10:09 AM

Add c.countryImage to your query SELECT clause.

Use $row['countryImage']
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 18 September 2006 - 10:14 AM

would that not show the Image name e.g

1158573641admin_hotel.jpg

instead of the image

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 18 September 2006 - 10:18 AM

Not if you put it in img src instead of "$row_rsCountry['countryImage']"
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 18 September 2006 - 12:23 PM

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";
}

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

<?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;
}
?>


#6 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 18 September 2006 - 12:46 PM

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.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#7 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 18 September 2006 - 12:48 PM

tabCountry=

Id
countryName
countryImage


tabRegion=
Id
regionName
countryId


and this is the image code now

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


#8 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 18 September 2006 - 12:59 PM

It will be something like this (however I don't know your dir structure or image naming conventions)

<?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;
}
?>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#9 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 18 September 2006 - 01:20 PM

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

<?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);
?>


#10 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 18 September 2006 - 03:09 PM

Im trying not to double post, although i just did, this is the image code now

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


#11 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 18 September 2006 - 03:27 PM

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

Your code omitted the opening and closing quotes to the construction of the $image string, and left out the closing ;
Legend has it that reading the manual never killed anyone.
My site

#12 karthikeyan_coder

karthikeyan_coder
  • Members
  • PipPipPip
  • Advanced Member
  • 201 posts

Posted 18 September 2006 - 07:15 PM

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.


www.karthi.us

#13 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 18 September 2006 - 07:26 PM

Andy's is missing the closing curly

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


If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users