Jump to content


Photo

Help in putting image in Table


  • Please log in to reply
4 replies to this topic

#1 Shadowbudz

Shadowbudz

    Newbie

  • New Members
  • Pip
  • 1 posts

Posted 17 March 2013 - 11:54 PM

Hi PHP Gurus,

 

I am newbie to HTML and PHP, i would like a help about how to properly put an image in my table. I have a table working properly that gets data(texts) and puts in the database and retrieves it and display it in a table. Now my main concern is to put images in a certain row but my problem is the image keeps on repeating in the rows. Sorry for my english. Here is a picture so you can see the table. 

 

http://img571.images...968/imagexf.png

 

Here is my code on the table.

 

//READ ALL POSTS
	$records = read_(0);

	?>
    <table style="width:100%; border: 1px solid #b7ddf2; background-color: black;">	
	<tr style='background-color: #A00000; height: 30px;'>
		<th>Team</th>
		<th>vs</th>
		<th>Team</th>
		<th>Date</th>
		<th>Venue</th>
		<th>Channel</th>
		<th width='100px'></th>
	</tr>
	<?php
	
	$count=0;
	$style1="style= 'background-color: blue'";
	$style2="style= 'background-color: blue'";
	
	//DISPLAY ALL POSTS
	while ($record = mysql_fetch_array($records)) {
		if ($count%2==0)
			$style = $style1;
		else
			$style = $style2;
			
		echo "<tr $style>";
		echo "<td><image src ='heat logo.jpg'/></td>"; //problem here
		echo "<td width ='30px'></td>";
		echo "<td width ='160px'><img src ='knicks logo.jpg'/></td>"; //problem here
		echo "<td>".$record['date']."</td>";
		echo "<td>".$record['venue']."</td>";
		echo "<td>".$record['channel']."</td>";
		echo "<td width='120px'><a href='edit.php?id=".$record["id"]."' class='button2'>edit</a> <a href='delete.php?id=".$record["id"]."' class='button2'>delete</a> </td>";		
		echo "</tr>";
		$count++;
	}
	?>
	</table>	

 

My problem is how to put different image in that specific row and avoid the repetition of the images.

 

i tried using echo "<td><image src ='heat logo.jpg'/> <image src ='lakers logo.jpg'/> </td>"; 

 

but the image just goes side by side instead of going to another row and the image still repeats every row. 

 

Here is the image http://img685.images...52/image2rc.png

 

 

Any help would be greatly appreciated.

 

Shadowbudz



#2 deadlyp99

deadlyp99

    Advanced Member

  • Members
  • PipPipPip
  • 124 posts

Posted 18 March 2013 - 04:51 PM

Your using the same images repeatedly. 

Your while loop repeats, and keeps using the static image url.

 

You can restructure your database to also contain the image url for a specific team.

 

echo "<td><image src ='".$record['teamOneImageUrl']."'/></td>"; //problem here
echo "<td><image src ='".$record['teamTwoImageUrl']."'/></td>"; //problem here

Edited by deadlyp99, 18 March 2013 - 04:52 PM.


#3 BuildMyWeb

BuildMyWeb

    Advanced Member

  • Members
  • PipPipPip
  • 82 posts
  • LocationNY

Posted 06 April 2013 - 10:07 PM

agree with deadly


Freelance Web Developer | Web Hosting | PHP Applications
Web Development, Hosting, Graphic Design, SEO


#4 TutorIndia

TutorIndia

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 29 April 2013 - 11:06 AM

Deadly You got the correct mistake. Well done :)



#5 noahwilson

noahwilson

    Member

  • Members
  • PipPip
  • 15 posts

Posted 07 May 2013 - 11:25 AM

its good topic, thank to sharing  your suggestion  , really its so helpful for me


if you need International Moving Companies and looking best relocation services to Moving To Europe just contact to Australian vanlines.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com