Jump to content

mysql - show items same as ebay!


farhad

Recommended Posts

Hi!

I'm using,

mysql ver: 5.1.36

php ver: 5.3.0

 

I would really need your help with this one.

I´m traying to show 2-3 item next to each other in the browser.

The problem is that i have no idea how to construct my while loop!

 

I´ll show u my code below, it shows only one item at a time. I´m trying to create somthing like the pic attached.

Thanks!  :confused:

function show_products(){
  $query = "SELECT * FROM pages LIMIT 5 ";
  $result = mysql_query($query);
  
  while ($row = mysql_fetch_array($result)){
	  //get the image size of the picture and load it into an array
	  $image = getimagesize("uploads/{$row['image_link']}");
	  $output = "<div class=\"index-prducts\">";
	  $output .= "<table class=\"index\">";
	  $output .= "<tr>";
	  $output .= "<th ><p><a href=\"index.php?page={$row['id']}\">{$row['menu_name']}</a></p></th>";
	  if($row['price'] !=0){
			  $output .= "<th class=\"price\"><a href=\"index.php?page={$row['id']}\"></a></th>";
			  $output .= "<th class=\"price\"><p><a href=\"index.php?page={$row['id']}\">Pris:</a></p></th>";
			  
		  }
	  $output .= "</tr>";	
	  $output .= "<td>"  . "<p><a href=\"index.php?page={$row['id']}\">{$row['description']}
					  <br/><br/><img src=\"images/ikoner/read_more.jpg\" border=\"0\" align=\"right\"><br/>
					  </a></p>" ."</td>";
	  $output .= "<td width=\"60\" >" . "<img src=\"uploads/" . $row['image_link'] . "\"";
	  $output .= imageResize($image[0],$image[1], 100);
	  $output .= ">";
	  if($row['price'] !=0){
			  $output .= "<td class=\"price\">" .$row['price'] . "kr";
		  }
	  $output .= "</td>";
	  $output .= "</tr>"; 
	  $output .= "</table>";						
	  $output .= "</div>";
	  echo $output;
  }	
}

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Pehaps it was to much to read, let me make it easier.

 

$query = "SELECT * FROM pages LIMIT 5 ";
  $result = mysql_query($query);
  
  while ($row = mysql_fetch_array($result)){

	  $output = "<div>";
	  $output .= "<table class=\"index\">";
	  $output .= "<tr>";
	  $output .= "<th ><p><a href=\"index.php?page={$row['id']}\">{$row['menu_name']}</a></p></th>";
	  $output .= "</tr>";
	  $output .= "<tr>";	
	  $output .= "<td><p><a href=\"index.php?page={$row['id']}\">{$row['description']}</a></td>";
	  $output .= "</tr>"; 
	  $output .= "</table>";						
	  $output .= "</div>";
	  echo $output;
  }	

 

 

Link to comment
Share on other sites

DIVs default to displaying in block form, which means that they fill the width of the page.  I assume that's what your problem is, that the entries are just displaying one on top of the other instead of side-by-side.  You're probably wanting to style the DIV in such a way that it allows two to be next to each other.  You could try "float: left" and a fixed width, or change your strategy to use tables and close/reopen the <tr> every second entry.

Link to comment
Share on other sites

I fixed my problem like 30 min before your post... after 6h of googling on the internet and same time traying to reconstruct my table "not a good day". Anyway

thanks for the help. I did resolve my problem with divs, I used "float to right". CSS is not my strongest side. perhaps block is a better option i don´t know.

 

Thanks :)

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.