Jump to content

php echo two html tables side by side.


sayedsohail

Recommended Posts

Hi everyone, I am trying to print two html tables side by side, one table will have 2-4 columns and values from mysql_query, and the second table will just display few small icons.   The reaon i am trying this, so i can link two separate tr onlick events.

 

table 1               table 2

--------------|------------

echo'$name';  | <INPUT type='button' value='edit'>

.                 

.

.

.

--------------|------------

 

here is my code which works perfectly fine to display records horizontally, but i want to display as above.

 

$result = mysql_query($sql); 
$display = 2; 
$cols = 0; 
echo "<table>"; 
while($fetched = mysql_fetch_array($result)){ 
   if($cols == 0){ 
       echo "<tr>\n"; 
   } 
   // put what you would like to display within each cell here, 
if you noticed at the moment i am able to display button side by side for the record,
but i want to display this in the iind table side by side.

   echo "<td>".$fetched['id']."<br />".$fetched['name']."</td><td><input type='button' value='Delete'></td><td>Insert</td><td>Print</td>\n"; 
   $cols++; 
   if($cols == $display){ 
       echo "</tr>\n"; 
       $cols = 0; 
   } 
} 
// added the following so it would display the correct html 
if($cols != $display && $cols != 0){ 
   $neededtds = $display - $cols; 
   for($i=0;$i<$neededtds;$i++){ 
       echo "<td></td>\n"; 
   } 
     echo "</tr></table>"; 
   } else { 
   echo "</table>"; 
} 

 

Any suggestions is greatly apprecaited.

 

Thanks

   

 

 

Link to comment
Share on other sites

This is what i am trying to achieve, but onlick and onmouseover non of the functions are working?

 

print "<tr ><COLGROUP name=\"high\" onmouseover=\"flyOver(this)\" onmouseout=\"flyOut(this)\"

onclick=\"selectMe(this);\">";

print "<td> $Service_Summary</td><td>$name</td></COLGROUP>";

print "<td>Delete</td><td>Insert</td></tr>";

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.