SIDEBAR
»
S
I
D
E
B
A
R
«
Collapsing rows in HTML table
Aug 30th, 2009 by Mojtaba

If you want to collapse some rows in you HTML table you can use the following script in your HTML document!


<script type="text/javascript">
var rowVisible = true;
function toggleDisplay(tbl) {
var tblRows = tbl.rows;
for (i = 0; i < tblRows.length; i++) {
if (tblRows[i].className != "odd") {
tblRows[i].style.display = (rowVisible) ? "none" : "";
}
}
rowVisible = !rowVisible;
}
</script>

and here is a button for activating script:

<input type="button" value="Hide Details" onclick="toggleDisplay(document.getElementById('TheTable'))" />

Now each time you press the button all odd rows will collapse . Note that you have to set your table id to “TheTable” & also set classes of odd rows to “odd”.

Here is an example:

Row1 Row 1
Row2 Row2
Row3 Row3
Speed up MySQL connection
Aug 28th, 2009 by Mojtaba

If you want to run a MySQL server on you local network, you can disable name resolve feature in order to get faster connection (Up to 10x faster). Remember that after disabling name resolve you have to enter your server IP address each time you want to use it.

Ok, follow me if you want faster connection:

  1. Open your MySQL config file. /etc/my.cnf
  2. Find [mysqld] and insert following string below it
    • skip-name-resolve

Here is an example
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
skip-name-resolve

Creating Table from MySql
Aug 19th, 2009 by Mojtaba

Here is a PHP code in order to view table in HTML format from MySql database, As one knows you have to place this code in php tag (<?php … ?>) in order to execute it.

print "<TABLE BORDER=0 CELLPADDING=2>\n";
$fields = mysql_list_fields("DATABASENAME", "YOURSQLTABLENAME");
$columns = mysql_num_fields($fields);
print "<TR>";
for ($x = 0; $x < $columns;$x++ ) {
print "<TH>" . mysql_field_name($fields,$x) . "</TH>\n";
}
print "</TR>\n";
$sql = "SELECT * from YOURSQLTABLENAME";
$result = mysql_query($sql);
while ($obj = mysql_fetch_object($result,MYSQL_ASSOC)) {
print "<TR>";
foreach($obj as $val) {
print "<TD>" . $val . "</TD>";
}
print "</TR>\n";
}
echo "</TABLE>\n";

»  Substance:WordPress   »  Style:Ahren Ahimsa
© 2010 Mojtabacazi.com . All right reserved