Im trying to get td fields from a table with the id sid-120390923 or sid-38737122 ignoring any other id value in the table, however the problem is that I can not get these td fields because they all have a slightly different id but with the same start ('sid').
what I want is to be able to grab all the td fields with the starting id sid-, would there be a way to incorporate regex?
here is an example
html
<table>
<tr>
<td id='9sd'></td>
<td id='10sd'></td>
<td id='sid-1239812983'></td>
<td id='sid-1454345345'></td>
<td id='sid-2342345234'></td>
<td id='sid-5656433455'></td>
<td id='sid-1231235664'></td>
<td id='sid-8986757575'></td>
<td id='sid-1232134551'></td>
</tr>
</table>
simple_html_dom
$table = $con->find('table');
foreach($table->find('td#sid-1232134551') as $field){
echo $field."<br>";
}
You can use attribute filters (the 5. tab),
$table->find('td[id^=sid-]');
Related
I have a page that displays about 12 tables that are filled from database values. These values correspond with a single record but some of these fields are based off of queries I'm making so that if something's wrong in the query, it will display red text.
I'm only doing this for a few different fields but I want an option to edit and fix those fields and then save them to the database with an UPDATE.
Basically, I don't want to wrap the whole page in a form since only a few fields in a few of the tables will need to be editable. Is there a way to do this so that I can edit only the few fields that need to be fixed?
Here's a table as example:
<div class="testResults" style=" width: 30%; clear:both; float: left;">
<!--Test Results Table-->
<table style="width: 100%;">
<tr>
<th colspan="2">Test Results</th>
</tr>
<tr>
<td style="text-align: left;">Tested Within AWWA Standards</td>
<td><? echo $row['standards'];?> </td>
</tr>
<tr>
<td style="text-align: left;">Meter Failed on Low Side</td>
<td><? echo $row['lowFail'];?> </td>
</tr>
<tr>
<td style="text-align: left;">Meter Failed on High Side</td>
<td><? echo $row['highFail'];?> </td>
</tr>
<tr>
<td style="text-align: left;">Meter Failed Low and High Side</td>
<td><? echo $row['bothFail'];?> </td>
</tr>
<tr>
<td style="text-align: left;">Unable To Test</td>
<td><? echo $row['unableTest'];?> </td>
</tr>
</table>
So, for example, say I want to edit the data for just standards row and lowFail row.
I know once this is done I'll need to have a submit button that attaches to a query to update with the input name, but right NOw i'm trying to find the best way to edit.
Is it easiest to just wrap the whole page in a form and just create the few inputs where I need?
I have a basic table and need to change a word if one of the other cells in that row contains a word.
<table>
<tr class="veh-row">
<td class="vehicle_desc">RED CAR</td>
<td>4000 miles</td>
<td class="veh-trans">Manual</td>
<td>Petrol</td>
</tr>
<tr class="veh-row">
<td class="vehicle_desc">RED CAR</td>
<td>4000 miles</td>
<td class="veh-trans">Manual</td>
<td>Petrol</td>
</tr>
<tr class="veh-row">
<td class="vehicle_desc">RED CAR AUTO</td>
<td>4000 miles</td>
<td class="veh-trans">Manual</td>
<td>Petrol</td>
</tr>
</table>
So I need if td.vehicle_desc contains the word AUTO then Manual will change to Automatic in td.veh-trans. How can I do this and only effect that row and not all other rows?
You can use :contains
$('td.vehicle_desc:contains(AUTO)').siblings('.veh-trans').text('Automatic')
I used jquery data table for sorting. It works fine under normal condition. If i changed the value in run time, the sorting is not working.
This is my table data
<table width="94%" cellpadding="2" cellspacing="1" class="tablehead" id="pls-batting">
<thead>
<tr class="tab_head" align="right" id="pls-play" >
<th width="44" align="center" ># No </th>
</tr>
</thead>
<tbody>
<tr id="116706">
<td align="left" id='1' >test</td>
</tr>
<tr id="116707">
<td align="left" id='2'>bbb</td>
</tr>
<tr id="116708">
<td align="left" id='3' >xxx</td>
</tr>
</tbody>
</table>
Jquery method used for sorting is :
$(document).ready(function() {
$('#pls-batting').dataTable( {
} );
} );
By clicking the '# No' head the corresponding column displayed in asc and desc order respectively. These TD values will be changed onload by using
document.getElementById(3).innerHTML = 'something';
So as a result the 3rd column value is 'something'. So sorting will be done by this values. But it is not working.
It takes the old values. Please help me. Thanks
In DataTables, you should not update content of HTML cell. DT uses internal JavaScript array structure for searching/sorting and this cell is only a display value.
To update some cell you will need to use DT fnUpdate function see http://datatables.net/api#fnUpdate. Example of updating cell in the table is:
var oTable = $('#example').dataTable();
oTable.fnUpdate( 'New content', 10, 3 );
Note that cells are referenced by row/cell positions. If you don't know row/cell position then you can use http://datatables.net/api#fnGetPosition function to find position of TR with id 3 and use this info to update cell data using the fnGetData function (you can find example on the http://datatables.net/api#fnGetPosition)
Jovan
I made some images which i need, currently i have :
$output .= "
<tr>
<td align='center'><b>{$name}</b></td> </tr>
<tr>
<td align='center'><img src='$avatar'/></td> </tr>
<td align='center'><b>Points</b>: {$points}</td> </tr>
<tr>
<td align='center'><b>Status</b>:<b><font color='green'> {$misc['text_status']}</font></b></td> </tr>
<tr>
<td align='center'><a href='".$link."'><font color='red'><b>See more statistics</b></font></a><hr></td></tr>
";
with script i get this(ie image) http://img717.imageshack.us/img717/7885/thisdn.png .
Now i need to output something like this http://img703.imageshack.us/img703/171/thatq.png (ie image) without mysql. May i have some examples of yours?
move <tr> before your for loop and </tr> after you for loop
or better one, place individual tables with float:left for each member
You could try to wrap every profile information (photo, points etc) in a div and not use tables at all. Then float these div-s to the right or left. Note that every div must have the same class.
Hi
I have a table in which my row contains the text which i retrieve from the database.But i have a small width of row and the data i retrieve is large.And the text exceeds the width of my row so i want to break the data i retrieve into multi lines inside the table row.How can i do it.
My code is here:
$list = $mfidao1->fetchMfi($_GET['id']);
//print_r($list);
//die;
if(!empty($list))
{
foreach($list as $menu)
{
?>
<tr style="border:none; background-color:#FBFBFB;" >
<td class="topv">Social Mission</td>
<td class="topm" ><div class="txt"><?php echo $menu->mfi_1_a;?></div></td>
</tr>
<tr bgcolor="#E8E8E8">
<td class="topv">Address</td>
<td class="topm"><?php echo $menu->mfi_ii_c;?></td>
</tr>
<tr bgcolor="#FBFBFB">
<td class="topv">Phone</td>
<td class="topm"><?php echo $menu->mfi_ii_e;?></td>
</tr>
<tr bgcolor="#E8E8E8">
<td class="topv">Email</td>
<td class="topm"><?php echo $menu->mfi_ii_d;?></td>
</tr>
<tr bgcolor="#FBFBFB">
<td class="topv">Year Established</td>
<td class="topm"><?php echo $menu->mfi_i_c;?></td>
</tr>
<tr bgcolor="#E8E8E8">
<td class="topv">Current Legal Status</td>
<td class="topm"><?php echo $menu->mfi_i_d;?></td>
</tr>
<tr bgcolor="#FBFBFB">
<td class="topv">Respondent</td>
<td class="topm"><?php echo $menu->mfi_ii_a;?></td>
</tr>
<?php
}
}
?>
</table>
Set width of <td>. I think this is the best way to do this rather than word_wrap().
In your css for the table, use "table-layout:fixed" - This fixes the td elements width according to the way you want.
" word-wrap: break-word; " - this breaks the text in it so that it doesnt go beyond the boundary of the box.
You need to wrap the text in your td tags. Here is a link to a similar question
You could use the function wordwrap().
It wraps a string to a given number of characters using a string break character.
you can either use the php function
php wordwrap
or styling the td with css so that it uses the word-wrap attribute
css wordwrap
Not sure if this is what you want, but sound like you could use chunk_split()