ajaxCRUD.com

» a PHP class to Create, Read, Update, & Delete from a mysql database table using AJAX

   by loud canvas media

AjaxCRUD Class Documentation / Reference Material

<< Reference overview
<< Home

addButtonToRow

adds a button to every row and sends the id (pk) of that item to any url
void addButtontoRow( String buttonValue, String URL, [ String $attach_params ], [ String $javascript_tags ], [ String $window_to_open ] )
Use this function to pass the primary key to another page (url) to do some other process. This function is very useful when your database has many-to-many relationships and you need to "attach" multiple items to an item.

By default the GET parameter for the primary key is passed to the page with the id being the primary key value. However, you can use the word "ALL" as an optional third parameter to have ALL fields and their values passed!

Details

Type function
Returns void
Default no button

Parameters

buttonValue
Value for the button
URL
a web script (eg a php, .asp, .jsp file)
attach_param (optional)
the field you want to pass to the URL. Can be "all" which means all fields
javascript_tags (optional)
any javascript you want added to the button
window_to_open (optional)
open this page in a "new" window (default is "same")

Example

$tblDemo->addButtonToRow("View", "myOwnDisplayPage.php");
OR
//this second example will pass ALL fields to the update form page
$tblDemo->addButtonToRow("Edit", "myOwnUpdateForm.php", "all");
OR
//this third example will pass only the "myDBField" variable (and value) to the update page
$tblDemo->addButtonToRow("Edit", "myOwnUpdateForm.php", "myDBField");
OR
//this fourth example will pass in the name of a user-defined JavaScript function which will allow the page to open up in specific window
<?php
$mytable->addButtonToRow("View", "", "", "myJavascriptFunctionToOpenInNewWindow");
?>
.
.
.
<script> function myJavascriptFunctionToOpenInNewWindow(id){ alert('opening new window'); window.open('test.php?courseid=' + id'); } </script>

See also

New, Edit

 

"OMG! This is just what I was looking for. Thanks so much. This is amazing!"
~Simone

What is a business/commercial website?

A commercial website is one created for a business, for which purpose is generating revenue or cash flow of any type (and that isn't under a non-profit organization). So if you're selling a product, selling advertisement, selling a service, or just marketing a commercial business, your site is commercial. A company website is also commercial even if it doesn't sell anything, as it's purpose is to front a commercial company.
Close