Jump to content


Photo

BaaGrid - editable records


  • Please log in to reply
3 replies to this topic

#1 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 27 September 2006 - 03:08 PM

Good Morning!

I have downloaded and begun to experiment with baaGrid (great 'script'! and easy to make it do most of what I need).

Retrieving and display the data desired is quick and easy; however, I have a need to be able to display the grid as editable 'records/fields' [ie add/edit/delete].

I was hoping our mentor Barand (who tho he may be approaching senility is still younger than me) might shed some light (no pun on my name intended) in the fashion of the '** For Dummies' series.

(btw this is for a project to be used to encourage children k - 12 to read)

Thanks Much,

Lite
(nick)

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 27 September 2006 - 03:14 PM

I'm not quite sure why you're posting instead of emailing him.  Also, if you want to make the grid editable, I'm not sure how that has anything to do with his scripts.  That is functionality beyond what he has provided and should be directed to those who can help with code you might have already begun to work with.

Info: PHP Manual


#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 09 October 2006 - 09:16 PM

I've just seen this post. There is an example using checkboxes with class. Currently it's not an inbuilt feature but you could do

<?php
include 'db.php';
include 'baagrid.php';

if (isset ($_GET['action'])) {
    echo '<pre>', print_r($_GET, true), '</pre>';
}

$sql = "SELECT id, locname, qty FROM baagriddata";
$grid = new baaGrid($sql);
echo '<form>';
$grid->setGPCol (1, "<input type='text' size = '15' name='locname[#0]' value='#1'>");
$grid->setGPCol (2, "<input type='text' size = '5' name='qty[#0]' value='#2'>");
$grid->display();
echo '<input type="submit" name="action" value="Submit">' ;
echo '</form>';
?>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 10 October 2006 - 08:14 PM

... or this, which lets you select an individual line to edit

<?php
include 'db.php';
include 'baagrid.php';

if (isset ($_GET['action'])) {
    echo '<pre>', print_r($_GET, true), '</pre>';
}

function formField ($name, $size, $value, $id) {
    if ($id == $_GET['editid'])
        return "<input type='hidden' name='id' value='$id'>
                 <input type='text' size = '$size' name='$name' value='$value'>";
    else
        return $value;
}

$sql = "SELECT id, locname, qty, 'edit' as Edit FROM baagriddata";
$grid = new baaGrid($sql);
echo '<form>';
$grid->setGPCol (1, "formField('locname',15,#1, #0)");
$grid->setGPCol (2, "formField('qty',5,#2, #0)");
$grid->setLink(3,"$_SERVER[PHP_SELF]?editid=#0");
$grid->showErrors();
$grid->display();
echo '<input type="submit" name="action" value="Submit">' ;
echo '</form>';

?>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users