Note that there are some explanatory texts on larger screens.

plurals
  1. POProgrammatic remove <td> from php generated HTML table
    primarykey
    data
    text
    <p>I would like to remove extraneous table cells that are generated from an html table in php. Please see end of table in this example:<a href="http://leobee.com/android/push/so/stdt3.php" rel="nofollow noreferrer">http://leobee.com/android/push/so/stdt3.php</a> **Note I have not updated the code to work in IE yet, please use a gecko browser. </p> <p>I've found this example in jQuery: <a href="http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_tr_deletecell" rel="nofollow noreferrer">http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_tr_deletecell</a>. However I need to remove the extra cells after the colspan cells are generated in php.</p> <p>Questions:</p> <ol> <li><p>Is it possible for php to manipulate the DOM to remove table cells after the colspan cells have been processed? if possible can you stipulate the process of figuring this out or what methods or libraries I should look into.</p></li> <li><p>Do you know of another example that is similar to my table that can programmatic create a schedule for a day broken down by hour, that can have an event expand over more than one hour?</p></li> </ol> <p>Code:</p> <pre><code>&lt;?php // events array $events = array( array('Atari', 'Hall D' , '10:00 PM'), array('Sonic the Hedgehog', 'Panel 4' , '11:00 AM'), array('Bleach', 'Video 3' , '4:00 PM'), array('Sailor Moon ', 'Panel 4' , '6:00 PM') ); $events_flat = array(); foreach($events as $event) { $events_flat[$event[0]] = $event[1] . $event[2]; } // location array $locations = array( 'Arena', 'Hall D', 'Video 1', 'Video 2', 'Video 3', 'Video 4', 'Video 5', 'Video 6', 'HD Theater', 'Panel 1', 'Panel 2', 'Panel 3', 'Panel 4', 'WorkShop 1', 'WorkShop 2', 'WorkShop 3', 'WorkShop 4', 'Autograph 1', 'Autograph 2' ); // event start time array $times = array( '9:00 AM', '10:00 AM', '11:00 AM','12:00 PM', '1:00 PM', '2:00 PM', '3:00 PM', '4:00 PM', '5:00 PM', '6:00 PM', '7:00 PM', '8:00 PM', '9:00 PM', '10:00 PM', '11:00 PM', '12:00 AM', '1:00 AM', '2:00 AM' ); $html = '&lt;table&gt;&lt;tr&gt;&lt;td bgcolor="green"&gt;&lt;table name="schedule" id="schedule" border="1" bordercolor="black"&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;'; foreach ($times as $time) { $html .= '&lt;td width="100" height="25" bgcolor="yellow"&gt;'; $html .= htmlspecialchars($time); $html .= '&lt;/td&gt;'; } foreach ($locations as $location) { $html .= '&lt;tr&gt;&lt;td width="100" height="25" bgcolor="pink"&gt;'; $html .= htmlspecialchars($location); $html .= '&lt;/td&gt;'; foreach ($times as $time) { $event = array_search($location . $time, $events_flat); if ($event === FALSE) { $html .= '&lt;td width="100" height="25" bgcolor="#70DBDB"&gt;'; $html .= ' '; } else { //http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_tr_deletecell //http://www.php.net/manual/en/function.array-pop.php //duration in hours // Todo detect ie and use colSpan $duration =3; $html .= '&lt;td colspan="'.$duration.'" width="100" height="25" bgcolor="orange"&gt;'; $html .= htmlspecialchars($event); //$event = array_pop($event-1); } $html .= '&lt;/td&gt;'; // $deletecell=document.getElementById("schedule").rows[this]; // $deletecell.deleteCell(-1); } $html .= ' &lt;/tr&gt;'; } $html .= '&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;'; echo $html; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload