?
Solved

displaying records next to each other in the same place

Posted on 2009-04-24
18
Medium Priority
?
168 Views
Last Modified: 2013-12-12
hi
i have a php function which loads data from database it display each record as one row i want to change the format i want to display record next to each other instead of typical tablei want to display each record next to each other without table
$sql = "SELECT uniq_id, artist, video_title, yt_views, added FROM pm_videos_comp" ; 
		// NEW ITEM //
			$result = mysql_query($sql); 
			$item = '';
			$j = '1';
			$alt = '0';
		 
			while ($row = mysql_fetch_array($result))
				{ 
					$col = ($alt % 2) ? 'row1' : 'row2';
					$alt++;
					$item .= "
			
			<form method=\"post\" action=\"compsvideo.php\">\n
					  <tr>
					  
					    <td align=\"center\" class=\"$col\" width=\"35\" ><a href=\"".makevideolinks($row['uniq_id'])."\"><img src=\"".show_thumbs($row['uniq_id'])."\" alt=\"".$row['video_title']."\" class=\"tinythumb\" width=\"172\" height=\"173\" align=\"left\" border=\"1\" /></a></td>
						<td class=\"$col\" width=\"250\">".$row['artist']."</td>
						<td class=\"$col\"><a href=\"".makevideolinks($row['uniq_id'])."\">".$row['video_title']."</a></td>
 
					<input type=\"hidden\" name=\"compid_{$row['id']}\" value=\"{$row['compid']}\" />
<input type=\"hidden\" name=\"userid_{$row['id']}\" value=\"{$row['userid']}\" />
					  </tr>
					 <td class=\"$col\"> <input type=\"radio\" name=\"Vote\" value=\"{$row['uniq_id']}\" />
					<input type=\"hidden\" name=\"compid_{$row['id']}\" value=\"{$row['userid']}\" />
					
					 
	";

Open in new window

0
Comment
Question by:mattibutt
  • 12
  • 4
  • 2
18 Comments
 
LVL 11

Author Comment

by:mattibutt
ID: 24228210
is everyone on holidays i am not getting response to my questions is there any problem with EE website?
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 24230691
Describe your desired format more explicitly.  Draw a picture if you can.
0
 
LVL 11

Author Comment

by:mattibutt
ID: 24235102
this is how it looks like currently
current.gif
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:Steve Bink
ID: 24235109
How do you want it to look?
0
 
LVL 11

Author Comment

by:mattibutt
ID: 24235119
this is how i want to do
desired.gif
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 24235120
What if there are more than 4?
0
 
LVL 11

Author Comment

by:mattibutt
ID: 24235126
in the current on there is a radio button but its not visible in the picture because of background
0
 
LVL 11

Author Comment

by:mattibutt
ID: 24235141
hi buddy
 they will  only going to be four
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 24235214
Try something like this:
<style>
  div#container {
    width:550px;
    height:140px;
    border:solid black 1px;
    padding:6px;
  }
  div.item {
    width:90px;
    min-width:90px;
    height:80px;
    min-height:80px;
    border:dotted black 2px;
    margin:12px;
    float:left;
  }
  div.itemwindow {
    width:66px;
    height:53px;
    border:solid black 1px;
  }
  div.clearfix { clear:both; }
</style>
 
<div id="container">
  <div class="item">
    <center><div class="itemwindow">#1</div><input type="radio" /></center>
  </div>
  <div class="item">
    <center><div class="itemwindow">#2</div><input type="radio" /></center>
  </div>
  <div class="item">
    <center><div class="itemwindow">#3</div><input type="radio" /></center>
  </div>
  <div class="item">
    <center><div class="itemwindow">#4</div><input type="radio" /></center>
  </div>
  <div class="clearfix">&nbsp;</div>
  Other stuff down here
</div>

Open in new window

0
 
LVL 11

Author Comment

by:mattibutt
ID: 24235284
hi buddy
thanks for that thing is all the data is coming from the database how do i apply your code on the following some guideline would be much appreciated

$sql = "SELECT uniq_id, artist, video_title, yt_views, added FROM pm_videos_comp" ;
                // NEW ITEM //
                        $result = mysql_query($sql);
                        $item = '';
                        $j = '1';
                        $alt = '0';
                 
                        while ($row = mysql_fetch_array($result))
                                {
                                        $col = ($alt % 2) ? 'row1' : 'row2';
                                        $alt++;
                                        $item .= "
                       
                        <form method=\"post\" action=\"compsvideo.php\">\n
                                          <tr>
                                         
                                            <td align=\"center\" class=\"$col\" width=\"35\" ><a href=\"".makevideolinks($row['uniq_id'])."\"><img src=\"".show_thumbs($row['uniq_id'])."\" alt=\"".$row['video_title']."\" class=\"tinythumb\" width=\"172\" height=\"173\" align=\"left\" border=\"1\" /></a></td>
                                                <td class=\"$col\" width=\"250\">".$row['artist']."</td>
                                                <td class=\"$col\"><a href=\"".makevideolinks($row['uniq_id'])."\">".$row['video_title']."</a></td>
 
                                        <input type=\"hidden\" name=\"compid_{$row['id']}\" value=\"{$row['compid']}\" />
<input type=\"hidden\" name=\"userid_{$row['id']}\" value=\"{$row['userid']}\" />
                                          </tr>
                                         <td class=\"$col\"> <input type=\"radio\" name=\"Vote\" value=\"{$row['uniq_id']}\" />
                                        <input type=\"hidden\" name=\"compid_{$row['id']}\" value=\"{$row['userid']}\" />
                                       
                                         
        ";
0
 
LVL 11

Author Comment

by:mattibutt
ID: 24235294
i mean the current structure is like a table transforming it to your code i dont know where to begin
0
 
LVL 20

Expert Comment

by:NerdsOfTech
ID: 24235295
Try this
$sql = "SELECT uniq_id, artist, video_title, yt_views, added FROM pm_videos_comp" ; 
// NEW ITEM //
$result = mysql_query($sql); 
$item = '';
$j = '1';
$alt = '1';
 
$item .= "<form method=\"post\" action=\"compsvideo.php\">";
$item .= "<table><tr>";
while ($row = mysql_fetch_array($result))
{ 
 $col = ($alt % 2) ? 'row1' : 'row2';
 $item .= "
  <td>
  \n
                                           
  <div align=\"center\" class=\"$col\" width=\"35\" ><a href=\"".makevideolinks($row['uniq_id'])."\"><img src=\"".show_thumbs($row['uniq_id'])."\" alt=\"".$row['video_title']."\" class=\"tinythumb\" width=\"172\" height=\"173\" align=\"left\" border=\"1\" /></a></div>
  <br />
  <div class=\"$col\" width=\"250\">".$row['artist']."</div>
  <br />
  <div class=\"$col\"><a href=\"".makevideolinks($row['uniq_id'])."\">".$row['video_title']."</a></div>
  <br />
  <div class=\"$col\"> <input type=\"radio\" name=\"Vote\" value=\"{$row['uniq_id']}\" /></div> 
 
  <input type=\"hidden\" name=\"compid_{$row['id']}\" value=\"{$row['compid']}\" />
  <input type=\"hidden\" name=\"userid_{$row['id']}\" value=\"{$row['userid']}\" />
  </td>                                                                                
 ";
 $alt++;
}
$item .= "<td><input type="submit" value="Vote"></td>";
$item .= "</tr></table>";
 
echo $item;

Open in new window

0
 
LVL 11

Author Comment

by:mattibutt
ID: 24235470
thanks buddy it looks promising not the last though however the previous one you sent me i have sat down and tried to make it work problem is thought i am using the smarty templates as well this is fucking with my head but it seems promising this is what i done i put your css in my main css class then put the following codes videos are displayed next to each other although i need to clean the format but the goal has been met
$sql = "SELECT uniq_id, artist, video_title, yt_views, added FROM pm_videos_comp" ;
// NEW ITEM //
$result = mysql_query($sql);
$item = '';
$j = '1';
$alt = '1';
 
$item .= "<form method=\"post\" action=\"compsvideo.php\">";
$item .= "<table><tr>";
while ($row = mysql_fetch_array($result))
{
 $col = ($alt % 2) ? 'row1' : 'row2';
 $item .= "
  <td>
  \n
                  
                  <form method=\"post\" action=\"compsvideo.php\">\n
                                <tr>
                                <div class=\"container\">
                                 <div class=\"item\">
                                 <div class=\"itemwindow\">
                                  <div align=\"center\" class=\"$col\" width=\"35\" ><a href=\"".makevideolinks($row['uniq_id'])."\"><img src=\"".show_thumbs($row['uniq_id'])."\" alt=\"".$row['video_title']."\" class=\"tinythumb\" width=\"172\" height=\"173\" align=\"left\" border=\"1\" /></a></div>
  <br />
  <div class=\"$col\" width=\"250\">".$row['artist']."</div>
  <br />
  <div class=\"$col\"><a href=\"".makevideolinks($row['uniq_id'])."\">".$row['video_title']."</a></div>
  <br />
  <div class=\"$col\"> <input type=\"radio\" name=\"Vote\" value=\"{$row['uniq_id']}\" /></div>
 
  <input type=\"hidden\" name=\"compid_{$row['id']}\" value=\"{$row['compid']}\" />
  <input type=\"hidden\" name=\"userid_{$row['id']}\" value=\"{$row['userid']}\" />
                              
      </div>                        
      ";
      
      
      
                              $j++;
                              "</form>";
                        }
0
 
LVL 11

Author Closing Comment

by:mattibutt
ID: 31574234
thank you so much i really appreciate your help
0
 
LVL 11

Author Comment

by:mattibutt
ID: 24235481
hi NerdsOfTech

you always come like a commando in the end to rescue i have been looking for you i have one problem which i cant seem to ressolve if i can paste a link after creating the question if you kindly look at it. thanks

0
 
LVL 11

Author Comment

by:mattibutt
ID: 24235490
before i create the question i will need your approval
0
 
LVL 20

Expert Comment

by:NerdsOfTech
ID: 24235683
Sure
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question