Link to home
Start Free TrialLog in
Avatar of mattibutt
mattibuttFlag for United States of America

asked on

displaying records next to each other in the same place

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

Avatar of mattibutt
mattibutt
Flag of United States of America image

ASKER

is everyone on holidays i am not getting response to my questions is there any problem with EE website?
Avatar of Steve Bink
Describe your desired format more explicitly.  Draw a picture if you can.
this is how it looks like currently
current.gif
How do you want it to look?
this is how i want to do
desired.gif
What if there are more than 4?
in the current on there is a radio button but its not visible in the picture because of background
hi buddy
 they will  only going to be four
ASKER CERTIFIED SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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']}\" />
                                       
                                         
        ";
i mean the current structure is like a table transforming it to your code i dont know where to begin
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

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>";
                        }
thank you so much i really appreciate your help
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

before i create the question i will need your approval