Jump to content

Recommended Posts

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.imageshack.us/img571/4968/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.imageshack.us/img685/7452/image2rc.png

 

 

Any help would be greatly appreciated.

 

Shadowbudz

Link to comment
https://forums.phpfreaks.com/topic/275798-help-in-putting-image-in-table/
Share on other sites

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