PHP Classes

Use in PHP 4

Recommend this page to a friend!

      DrasticTools  >  All threads  >  Use in PHP 4  >  (Un) Subscribe thread alerts  
Subject:Use in PHP 4
Summary:Is it possible to use this grid in PHP 4
Messages:14
Author:Pankaj Singh
Date:2006-10-19 12:07:19
Update:2007-02-22 12:05:14
 
  1 - 10   11 - 14  

  1. Use in PHP 4   Reply   Report abuse  
Picture of Pankaj Singh Pankaj Singh - 2006-10-19 12:07:19
My hoster still uses the PHP 4(4.2) but I liked this grid. Let me know if it possible using PHP4.

Pankaj

  2. Re: Use in PHP 4   Reply   Report abuse  
Picture of dd dd - 2006-10-19 20:45:59 - In reply to message 1 from Pankaj Singh
I really don't know if it works in PHP4, as it was developed and tested in PHP5. I suppose the changes in object orientation between PHP4 and PHP5 may cause troubles, but I'm not sure. If you have PHP4 installed, you could try it out easily, I suppose.

regards, Olav

  3. Re: Use in PHP 4   Reply   Report abuse  
Picture of Sushil Agrawal Sushil Agrawal - 2006-10-21 11:08:10 - In reply to message 1 from Pankaj Singh
I have made it work on 4.4.4. Following is the patch.

Regards,


--- mysqlphpgrid.class.php 2006-10-22 21:44:59.000000000 +0530
+++ mysqlphpgrid.class.php.PHP4 2006-10-22 21:44:59.000000000 +0530
@@ -18,15 +18,15 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class mysqlphpgrid {
- protected $server, $user, $pw, $db, $table;
- protected $connection;
- protected $orderbystr;
- protected $ordstr;
- private $ord, $desc;
- private $idname = "";
- private $idcolnr;
+ var $server, $user, $pw, $db, $table;
+ var $connection;
+ var $orderbystr;
+ var $ordstr;
+ var $ord, $desc;
+ var $idname = "";
+ var $idcolnr;

- function __construct($server, $user, $pw, $db, $table) {
+ function mysqlphpgrid($server, $user, $pw, $db, $table) {
$this->server = $server;
$this->user = $user;
$this->pw = $pw;
@@ -115,7 +115,8 @@
$str .= "<tr>\n";
if ($editable) $str .= "<th/>\n";
for($i=0; $i < mysql_num_fields($result); $i++) {
- $fldname = mysql_fetch_field($result)->name;
+ $tmpfldname = mysql_fetch_field($result);
+ $fldname = $tmpfldname->name;
$str .= "<th class=\"th\" nowrap ";
if (($this->ord == $fldname) && (!$this->desc)) {
$str .= "onclick=\"td_sort(this)\" id=\"" . $fldname . ",d\"";
@@ -147,7 +148,8 @@
"onmouseover=\"this.src='del2.gif'\" onmouseout=\"this.src='del.gif'\" alt=\"delete\"/>" .
"</td>\n";
for($j=0; $j < mysql_num_fields($result); $j++) {
- $fldname = mysql_fetch_field($result, $j)->name;
+ $tmpfldname = mysql_fetch_field($result, $j);
+ $fldname = $tmpfldname->name;
$data = trim($row[$j]);
if ($editable)
$str .= "<td class=\"$class\" nowrap onclick=\"td_input(this)\" " .
@@ -198,7 +200,7 @@
}

// Effectuate changes in database
- private function update_data(){
+ function update_data(){
$op = $_REQUEST["op"];
$id = $_REQUEST["id"];
$value = $_REQUEST["value"];
@@ -212,15 +214,15 @@
}
}

- protected function select(){
+ function select(){
$str = "SELECT * FROM $this->table";
$res = mysql_query($str . $this->orderbystr, $this->conn) or die(mysql_error());
return ($res);
}
- protected function add(){
+ function add(){
mysql_query("INSERT INTO $this->table () VALUES()", $this->conn) or die(mysql_error());
}
- private function exists($id, $fld = "") {
+ function exists($id, $fld = "") {
$res = $this -> select();
// check field
if ($fld != "") {
@@ -240,17 +242,17 @@
}
return(false);
}
- private function delete($id){
+ function delete($id){
if ($this->exists($id))
mysql_query("DELETE FROM $this->table WHERE $this->idname='$id'", $this->conn) or die(mysql_error());
}
- private function update($id, $fld, $value){
+ function update($id, $fld, $value){
if ($this->exists($id, $fld))
mysql_query("UPDATE $this->table SET $fld='$value' WHERE $this->idname='$id'", $this->conn) or die(mysql_error());
}

// Do the sorting
- private function do_orderby(){
+ function do_orderby(){
if ($_REQUEST["ord"] != "")
$this->ordstr = mysql_real_escape_string($_REQUEST["ord"]);
else

  4. Re: Use in PHP 4   Reply   Report abuse  
Picture of kd kelly kd kelly - 2006-10-31 04:09:51 - In reply to message 3 from Sushil Agrawal
Is the patch cut off in this page? it stops at "else", and it's not immediately obvious to me where that would work into the existing code.

This is just such an awesome class, I use it on my local machine and it is just such a valuable tool, I'd love to get it running on my hosted server as well.

Is there any way you could mail me the code, or some instructions? you can send to my gmail account, which is dotlizard :)



  5. Re: Use in PHP 4   Reply   Report abuse  
Picture of Sushil Agrawal Sushil Agrawal - 2006-11-01 20:18:44 - In reply to message 4 from kd kelly
I have sent this mysqlphpgrid.class.php to your gmail account "dotlizard".

  6. Re: Use in PHP 4   Reply   Report abuse  
Picture of Jack Hagouel Jack Hagouel - 2006-11-09 02:08:56 - In reply to message 5 from Sushil Agrawal
It would be nice if you could share it with the rest of us - I'm interested too.

Thank you.

  7. Re: Use in PHP 4   Reply   Report abuse  
Picture of Matthew Beirn Matthew Beirn - 2006-11-09 13:56:16 - In reply to message 6 from Jack Hagouel
Yes, can I please have a copy? I would love to use this class.

Thanks,

Matt

  8. Re: Use in PHP 4   Reply   Report abuse  
Picture of kd kelly kd kelly - 2006-11-09 23:25:12 - In reply to message 7 from Matthew Beirn
I uploaded the copy (tested in PHP 4.4 I believe) he sent me to a free file sharing place, I hope that's an ok thing to do, I just wanted to help.

If it's not ok please delete my comment or let me know and i'll ... delete it if i can?

4shared.com/file/5697941/23f46748/m ...

  9. Re: Use in PHP 4   Reply   Report abuse  
Picture of Michael Bett Michael Bett - 2007-01-09 20:25:30 - In reply to message 8 from kd kelly

Could you send me the file to mbett at cs.cmu.edu ? The link http://www.4shared.com/file/5697941/23f46748/mysqlphpgridclass1.html is no longer valid. Thanks!

Michael

  10. Re: Use in PHP 4   Reply   Report abuse  
Picture of Sushil Agrawal Sushil Agrawal - 2007-01-11 09:49:11 - In reply to message 9 from Michael Bett
It can be downloaded from:
w3software.co.in/downloads/mysqlphp ...

 
  1 - 10   11 - 14