Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok dito

Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Tangong lang po tunkol sa sql

Halimbawa pong may 2 field ung database ko tapos may lamang 5 records

? f1 f2
1. 123 a
2. 123 b
3. 321 c
4. 321 d
5. abc e

Ang gusto ko pong mag output ay

123, 321, abc

yang 3 lang
ang nagagawa ko lang po ay palabasin ung 5 records
123, 123, 321, 321, abc

help po thxx...
Code:
SELECT DISTINCT f1 FROM table;

OR

Code:
SELECT f1 FROM table GROUP BY f1;
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

@hakuna_matata_hm

thx po ok na konti na lang problema :)

Bagong tanong po..

panu po pag may error na ganito

mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in.....

ito po ung code

$sql="SELECT DISTINCT tbl_salesstorename tbl_basket WHERE tbl_customername= '$usern'" . " LIMIT " . $_GET['p'] . "," . $perpage;

$query=mysql_query($sql);
$fetch= mysql_fetch_assoc( $query );
 
Last edited:
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

You invoke mysql functions nang wala man lang connection between your php and mysql database. Be sure to connect to your database bago ka mag.execute ng mga mysql functions. Observe mo yong paggamit ng $connection. :)

$connection = mysql_connect('localhost', 'user', 'password');

$query = mysql_query("SELECT * FROM table", $connection);
$result = mysql_fetch_assoc($query);
 
Last edited:
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

@hakuna_matata_hm

Ginawa ko na po yun pinakita ko lang po kung saan nageeror ung code.

ok na po di ko lang pala nabura ung tbl_basket (stupid).

thx po..
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

help naman po..

EXAMPLE po: meron akong profile page.. syempre po nakalist po dun ung mga data info ng isang member tapos po hindi xa nakatexbox..

tapos po sa ilalim po merong edit button.. kapag pinindot po ung edit button mappnta po ung mga info sa loob textbox po tapos ung edit button

magiging save button naman po.. paano ko po gagawin un?? help po mga master..

patulong po..
 
Last edited:
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Pwde mo gawan yan ng javascript if your using jquery use something about toggle() lang yan.

Code:
<table>
    <tr>
        <td><label>Name</label></td>
        <td>
            <label id="your-name-label">Your name</label>
            <input type="text" style="display:hidden" id="your-name" value="Your name" />
        </td>
    </tr>
</table>
<script>
    function toggle()
    {
        //Gawa kang script something to modify the style that will show and hide the labels and input boxes
    }
</script>
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Pwde mo gawan yan ng javascript if your using jquery use something about toggle() lang yan.

Code:
<table>
    <tr>
        <td><label>Name</label></td>
        <td>
            <label id="your-name-label">Your name</label>
            <input type="text" style="display:hidden" id="your-name" value="Your name" />
        </td>
    </tr>
</table>
<script>
    function toggle()
    {
        //Gawa kang script something to modify the style that will show and hide the labels and input boxes
    }
</script>

un nga po sir hndi po ako marunong ng javascript..

baka po meron kaung script..
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

un nga po sir hndi po ako marunong ng javascript..

baka po meron kaung script..

Code:
<script type='text/javascript'>
$(document).ready(function(){
   $('#id_of_toggle_button').click(function(){
       $('#id_of_element_to_toggle').toggle(); //this toggles visibility on and off
   });
})
</script>
include mo nalang yung jquery.js sa code mo.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

help naman po wala kasi ako kaalam alam sa php sa paggawa ng election system..pang thesis ko kasi to meron po ba kayo mairerecommend na site or if ever source code sa akin..salamat po mga master kung ako inyong matutulungan
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Post mo daw yong script. I guess sa access scope to ng class mo.

try using only mysql_select_db($database, $this-> conn_id); to display the errors. Just revert it back after you have known the cause.

be sure also to set your error_reporting to all so that you can see errors while developing. Turn it off nalang on deployment at live.

eto na po error nya boss...I also attach the script...


<?php

// return types
define("DB_RT_ARRAY",0); // return row as an assoc aray where fieldnames are keys
define("DB_RT_OBJECT",1); // return row as an object where fieldnames are properties

class CDatabase{
/**
* database type
*
* @var string
*
* @access private
*/
var $type;

/**
* database connection id
*
* @var resource
*
* @access private
*/
var $conn_id;

/**
* name of the current selected database
*
* @var string
*
* @access private
*/
var $current_db;

/**
* number of queries per session
*
* @var int
*
* @access private
*/
var $num_queries;

/**
* specifies if there were any modifications to the database [write queries]
*
* @var bool
*
* @access private
*/
var $modif = FALSE;

/**
* initializes module and connects to the database
*
* @param array $connect_params connection parameters
*
* @return void
*
* @acces public
*
* @see Connect
*/
function CDatabase($connect_params = "") {
$this->name = "database";

//$this->type = $type;

if ($connect_params != "")
$this->Connect($connect_params);
}

/**
* connects to the database
*
* @param array $connect_params connection parameters
*
* @return void
*
* @access public
*/
function Connect($params = array()) {

$this->conn_id = mysql_connect(@$params['server'], @$params['login'], @$params['password'], TRUE) or die("CDatabase::Connect() error " . mysql_error($this->conn_id));

$this->SelectDB(@$params['default']);
}

/**
* closes the database connection
*
* @return void
*
* @access public
*/
function Close() {
mysql_close($this->conn_id);
}

/**
* selects and sets the current database
*
* @param string $database
*
* @return void
*
* @access public
*/
function SelectDB($database) {
mysql_select_db($database,$this->conn_id);
$this->current_db = $database;
}

/**
* queries the database
*
* @param string $query actual sql query
*
* @return resource or NULL
*
* @access public
*/
function Query($query,$db = "") {//debug($query);
$this->num_queries++;
//$this->SelectDB($this->current_db);
//echo "<br>$query";
if ($db)
$result = mysql_db_query($db ,$query,$this->conn_id);// or die(mysql_error());
else
$result = mysql_query($query,$this->conn_id) or die($query . mysql_error());

if (in_array(substr($query,0,strpos($query," ")),array("INSERT", "UPDATE", "DELETE")))
$this->modif = TRUE;

return $result;
}

function FetchObject($result) {
return mysql_fetch_object($result);
}

function FetchRow($result) {
$data = mysql_fetch_row($result);
if (is_array($data)) {
foreach ($data as $key => $val)
$data[$key] = stripslashes($val);
}
return $data;

}

function FetchArray($result,$result_type = MYSQL_ASSOC) {
$data = mysql_fetch_array($result,$result_type);
if (is_array($data)) {
foreach ($data as $key => $val)
$data[$key] = stripslashes($val);
}
return $data;
}

function NumRows($result) {
return mysql_num_rows($result);
}

function AffectedRows() {
return mysql_affected_rows($this->conn_id);
}

function InsertID() {
return mysql_insert_id($this->conn_id);
}

function NumQueries() {
return $this->num_queries;
}

function QFetchObject($query) {
return $this->FetchObject($this->Query($query));
}

function QFetchRow($query) {
$data = $this->FetchRow($this->Query($query));
if (is_array($data)) {
foreach ($data as $key => $val)
$data[$key] = stripslashes($val);
}
return $data;
}

function QFetchArray($query) {
$data = $this->FetchArray($this->Query($query));
if (is_array($data)) {
foreach ($data as $key => $val)
$data[$key] = stripslashes($val);
}
return $data;
}

/**
* returns the number of rows from a table based on a certain [optional]
* where clause
*
* @param string $table table in which to count rows
* @param string $where_clause optional where clause [see sql WHERE clause]
*
* @return int row count
*
* @access public
*/
function RowCount($table,$where_clause = "") {
$result = $this->FetchRow($this->Query("SELECT COUNT(*) FROM $table $where_clause;"));
return $result[0];
}

/**
* fetch an array w/ rows from the database
*
* @param resource $result sql query result
* @param int $return_type row return type [can be DB_RT_ARRAY or DB_RT_OBJECT]
* @param string $key key the returned array by a certain row field [defaults to ""]
*
* @return array with rows or NULL if none fetched
*
* @access public
*/
function FetchRowArray($result,$return_type = DB_RT_ARRAY,$key = "") {
$ret_val = array();
$i = 0;

// dont panic. its just ternary operators in action :]
while ($row = (($return_type == DB_RT_ARRAY) ? $this->FetchArray($result) : $this->FetchObject($result)))
$ret_val[(($key == "") ? $i++ : (($return_type == DB_RT_ARRAY) ? $row["$key"] : $row->$key))] = $row;

// see if any rows were fetched and return accordingly
return (count($ret_val) != 0) ? $ret_val : NULL;
}

/**
* FetchRowArray wrapper
*
* @param string $query sql query to send to FetchRowArray
* @param int $return_type
* @param string $key
*
* @return array
*
* @access public
*
* @see CDatabase::FetchRowArray
*/
function QFetchRowArray($query,$return_type = DB_RT_ARRAY,$key = "") {
return $this->FetchRowArray($this->Query($query),$return_type,$key);
}

/**
* returns an array w/ the tables fields
*
* @param $table database table from which to get rows
*
* @return array
*
* @access public
*/
function GetTableFields($table) {
$fields = $this->QFetchRowArray("SHOW FIELDS FROM `$table`");
$ret_val = array();

foreach ($fields as $field)
$ret_val[] = $field["Field"];

return $ret_val;
}

/**
* fetches a row from a table based on a certain id using the SELECT SQL query
*
* @param string $table table in which to perform select
* @param int $id row id to fetch
* @param string $fields comma separated list of row fields to fetch [defaults to `*' all]
* @param int $return_type row return type DB_RT_ARRAY|DB_RT_OBJECT [defaults to DB_RT_ARRAY]
*
* @return array w/ the fetched data or NULL if id not found
*
* @access public
*/
function QuerySelectByID($table,$id,$fields = "*",$return_type = DB_RT_ARRAY) {
// build query
$query = "SELECT $fields FROM `$table` WHERE `id` = '$id'";

// fetch row
return ($return_type == DB_RT_ARRAY) ? $this->QFetchArray($query) : $this->QFetchObject($query);
}

/**
* complex fetch row array w/ WHERE/LIMIT/ORDER SQL clauses and page modifier
*
* @param string $table table to fetch rows from
* @param string $fields comma separated list of row fields to fetch
* @param string $where_clause SQL WHERE clause [use empty to ignore]
* @param int $start limit start
* @param int $count number of rows to fetch
* @param bool $pm page modifier. if set to TRUE [default] $start becomes the page
* @param string $order_by field to order the result by [defaults to void]
* @param string $order_dir order direction. can be ASC or DESC [defaults to ASC]
* @param int $return_type row return type [DB_RT_ARRAY(default)|DB_RT_OBJECT]
*
* @return array w/ fetched rows or NULL
*
* @access public
*/
function QuerySelectLimit($table,$fields,$where_clause,$start,$count,$pm = TRUE,$order_by = "",$order_dir = "ASC",$return_type = DB_RT_ARRAY) {
// check if $count is empty just to be safe
$count = ($count == "") ? 0 : $count;

// recompute $start if page modifier set
$_start = ($pm == TRUE) ? ((($start == 0) ? 1 : $start) * $count - $count) : $start;

// setup order clause
$order_clause = ($order_by != "") ? "ORDER BY $order_by " . (in_array($order_dir,array("ASC","DESC")) ? "$order_dir " : "") : "";

// setup where clause
$where_clause = ($where_clause != "") ? "WHERE $where_clause " : "";

// limit clause
$limit_clause = ($start >= 0) ? "LIMIT $_start,$count" : "";

// build query
$query = "SELECT $fields FROM `$table` {$where_clause}{$order_clause}{$limit_clause}";

// fetch rows
return $this->QFetchRowArray($query,$return_type);
}

/**
* builds and performes a SQL INSERT query based on the user data
*
* @param string $table table in which to perform insert
* @param array $fields associative array w/ the row fields to be inserted
*
* @return void
*
* @access public
*/
function QueryInsert($table,$fields) {
// first get the tables fields
$table_fields = $this->GetTableFields($table);

if (count($fields) == 0) {
$names[] = "id";
$values[] = "''";
} else
// prepare field names and values
foreach ($fields as $field => $value)
// check for valid fields
if (in_array($field,$table_fields)) {
$names[] = "`$field`";
$values[] = is_numeric($value) ? $value : "'" . (stripslashes($value) == addslashes($value) ? addslashes($value) : $value) . "'";
}

// build field names and values
$names = implode(",",$names);
$values = implode(",",$values);

// perform query
$this->Query("INSERT INTO `$table` ($names) VALUES($values)");

return $this->InsertID();
}

/**
* builds and performs a SQL UPDATE query based on the user data
*
* @param string $table table in which to perform update
* @param array $fields associative array w/ the fields to be updated
* @param string $where_clause update where clause [see SQL WHERE clause]
*
* @return void
*
* @access public
*/
function QueryUpdate($table,$fields,$where_clause) {
if (is_array($fields)) {
// first get the tables fields
$table_fields = $this->GetTableFields($table);

// prepare query
foreach ($fields as $field => $value)
// check for valid fields
if (in_array($field,$table_fields))
$pairs[] = "`$field` = " . (is_numeric($value) ? $value : "'" . (stripslashes($value) == addslashes($value) ? addslashes($value) : $value) . "'");
// $values[] = ;

// build and perform query
if (is_array($pairs))
$this->Query("UPDATE `$table` SET " . implode(", ",$pairs) . " WHERE($where_clause)");
}
}

/**
* builds and performs a SQL UPDATE query based on the user data
*
* @param string $table table in which to perform update
* @param array $fields associative array w/ the fields to be updated
*
* @return void
*
* @access public
*/
function QueryUpdateByID($table,$fields) {
$id = $fields["id"];
unset($fields["id"]);

$this->QueryUpdate($table,$fields,"`id` = '$id'");
}
}
?>
 

Attachments

  • error2_DB.JPG
    error2_DB.JPG
    22.7 KB · Views: 2
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Code:
<script type='text/javascript'>
$(document).ready(function(){
   $('#id_of_toggle_button').click(function(){
       $('#id_of_element_to_toggle').toggle(); //this toggles visibility on and off
   });
})
</script>
include mo nalang yung jquery.js sa code mo.

salamat po.. bka pwede nyo po ako turuan..
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Sir,

I guess this is what happen in this line.

Code:
$this->conn_id = mysql_connect(@$params['server'], @$params['login'], @$params['password'], TRUE) or die("CDatabase::Connect() error " . mysql_error($this->conn_id));

When you run your connection, you provided invalid parameters.
Try to remove @ on your parameters. Debug it by removing the OR die() and remove the @. After you determine the errors just put it back again.
Then you put $this -> conn_id into mysql_error(), which is not yet assigned with a resource. This will happen if you have invalid parameters. In which the $this -> conn_id will be assigned only after the 2 logical statement will be executed. Yet you use it even if you haven't assigned it yet.

Just remove the $this -> conn_id in mysql_error(), PHP will automatically determine the last connection made to your server. There's no need to specify it. Unless you have persistent connections that you need to disconnect a certain connection.

I discourage you to use @ on your functions and variables. Don't suppress the errors instead let them out and fix it. I suffer from it before. I wonder why I don't have any errors when update. Hahaha the thing was the other programmer put @ on it. I took me days just to understand and debug. Waste of time.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

pwede ba magtanong tungkol sa fully attributed data model ng class scheduler? yun po kasi yung thesis ko. salamat :)
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

panu if <table> gagamitin? pwede hingi ng sample code?panu e insert yun sa table

<table>
<tr>
<td style="height: 100px; width:750px;background:url('//path/to/file.jpg');"></td>
</tr>
</table>


Remember that in the near future, the use of <table> element will be limited/ obsolete. So try to use div instead.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

@hakuna_matata_hm

thx po ok na konti na lang problema :)

Bagong tanong po..

panu po pag may error na ganito

mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in.....

ito po ung code

$sql="SELECT DISTINCT tbl_salesstorename tbl_basket WHERE tbl_customername= '$usern'" . " LIMIT " . $_GET['p'] . "," . $perpage;

$query=mysql_query($sql);
$fetch= mysql_fetch_assoc( $query );


try to use @mysql_fetch_assoc( $query );
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

help naman po..

EXAMPLE po: meron akong profile page.. syempre po nakalist po dun ung mga data info ng isang member tapos po hindi xa nakatexbox..

tapos po sa ilalim po merong edit button.. kapag pinindot po ung edit button mappnta po ung mga info sa loob textbox po tapos ung edit button

magiging save button naman po.. paano ko po gagawin un?? help po mga master..

patulong po..


Code:
<?php
if( isset( $_POST['info'] ) )
{
       $data = mysql_query( "SELECT * FROM `user` WHERE `id` = $_SESSION[id]" );

        header( "Content-type: text/plain" );
        exit( json_encode( @mysql_fetch_assoc( $data ) ) );
}
else if( isset( $_POST['save'] ) )
{
        header( "Content-type: text/plain" );
         if( mysql_query( "UPDATE `user` SET `about` = '$_POST[about]', `name` = '$_POST[name]'" ) )
               exit( "Data was saved successfully" );
          else
             exit( "Error saving to the database." );
}
<form method="post" action="?">
About Me:<textarea name="about" id="about"></textarea>
<br />
Name: <input type="text" name="name" id="name" />
<br />
<input type="button" name="edit" value=" Edit " onclick="
var cache = this;
$( this ).attr( 'disabled', true ).unbind( 'click' );
$.post( '?', {info: true}, function( data )
{
        var info = {};
         try {
            info = eval( '(' + data + ' )' );
         } catch(e ) {}

         $( '#about' ).val( info.about );
         $( '#name' ).val( info.name );
         $( cache ).attr( {type: 'submit', name: 'save', value: ' Save ', disabled: false} ).click( function( )
       {
                  $.post( '?',  $( this ).parent().serialize( ), function( data )
                 {
                           alert( data );
                  } );
       } );
} );

" />

</form>


Full functional na ito, hindi ko nilagyan ng mga filter para mas madali maintindihan. Jquery based yung code, so mag include ka din ng script ng jquery.

AJAX based yung interface kaya hindi na irereload yung page.
Good luck! (:

Sorry kung medyo kumplikado pero kapag pinag aralan mo yan, marami ka mapupulot na kaalaman hehe ^^
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Hi there!

I'm new here.. And syempre.. Ang purpose ko eh matuto ng PHP..
Pa check naman ng site na to.
Ganito kasi yung plano naming gayahin ng childhood friend ko..

www.bjpascual.com

Hindi po ako nagaadvertise.. ang tanong ko po kasi sana eh.. Yung mga pictures kasi jan, pag tinapat mo yung mouse mo sa left side..
may lumalabas na parang "ticker" ng facebook..

Pero controlled ng mouse.. Hindi ng scroll bar.. So san po gawa yun?
PHP rin po ba?

Yun lang po.. Sana may sumagot sa tanong ko.
Thanks..

:salute:
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Code:
<?php
if( isset( $_POST['info'] ) )
{
       $data = mysql_query( "SELECT * FROM `user` WHERE `id` = $_SESSION[id]" );

        header( "Content-type: text/plain" );
        exit( json_encode( @mysql_fetch_assoc( $data ) ) );
}
else if( isset( $_POST['save'] ) )
{
        header( "Content-type: text/plain" );
         if( mysql_query( "UPDATE `user` SET `about` = '$_POST[about]', `name` = '$_POST[name]'" ) )
               exit( "Data was saved successfully" );
          else
             exit( "Error saving to the database." );
}
<form method="post" action="?">
About Me:<textarea name="about" id="about"></textarea>
<br />
Name: <input type="text" name="name" id="name" />
<br />
<input type="button" name="edit" value=" Edit " onclick="
var cache = this;
$( this ).attr( 'disabled', true ).unbind( 'click' );
$.post( '?', {info: true}, function( data )
{
        var info = {};
         try {
            info = eval( '(' + data + ' )' );
         } catch(e ) {}

         $( '#about' ).val( info.about );
         $( '#name' ).val( info.name );
         $( cache ).attr( {type: 'submit', name: 'save', value: ' Save ', disabled: false} ).click( function( )
       {
                  $.post( '?',  $( this ).parent().serialize( ), function( data )
                 {
                           alert( data );
                  } );
       } );
} );

" />

</form>


Full functional na ito, hindi ko nilagyan ng mga filter para mas madali maintindihan. Jquery based yung code, so mag include ka din ng script ng jquery.

AJAX based yung interface kaya hindi na irereload yung page.
Good luck! (:

Sorry kung medyo kumplikado pero kapag pinag aralan mo yan, marami ka mapupulot na kaalaman hehe ^^


salamat po dito sir.. pero iba pla ang gusto ng boss ko.. ang gsto nya kung anung field lang ang eedit nya un lang ang magiging textbox.. my nakita ako sa net.. pero d ko po maapply kasi dinidisplay nya ang lahat ng laman ng table nya. then gamit nya ang id ng bawat un para mapalabas ung texbox.. eto ung code ko sir.. check nyo po..


Code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
	<script type="text/javascript">
				$(document).ready(function()
				{
				$(".edit_td").click(function()
				{
				var ID =$(this).attr('id');
				$("#edit_"+ID).hide();
				$("#edit_this_"+ID).show();
				}).change(function()
				{
				var ID=$(this).attr('id');
				var name = $(this).attr('name');
				var etoangvaluenginedit=$("#edit_this_"+ID).val();
				var dataHere = 'id='+ ID +'&variablenyasapost='+etoangvaluenginedit+'&valuename='+name;
				$("#edit_"+ID).html('<img src="images/load.gif" />');


				if(etoangvaluenginedit.length>0)
				{
				$.ajax({
				type: "POST",
				url: "updatetheedit.php",
				data: dataHere,
				cache: false,
				success: function(html)
				{

				$("#edit_"+ID).html(etoangvaluenginedit);
				}
				});
				}
				else
				{
				alert('Enter something.');
				}

				});

				$(".textbox").mouseup(function() 
				{
				return false
				});

				$(document).mouseup(function()
				{
				$(".textbox").hide();
				$(".insidelabel").show();
				});

				});
			</script>

eto naman po ung snipnet ng code ko.. mahaba po kasi kaya eto nalang.. puro po kasi same lang..


Code:
<table><tr><td><label>Password</label></td><td id="<?php echo $id; ?>" class="edit_td"><span id="edit_<?php echo $id?>" class="insidelabel"><?php echo $row['username'];?></span><input id="edit_this_<?php echo $id?>" class="textbox" style="display:none;" type="text" name="username" value="<?php echo $row['username'];?>"/></td></tr>
<tr><td><label>Name</label></td><td id="<?php echo $id; ?>" class="edit_td"><span id="edit_<?php echo $id?>" class="insidelabel"><?php echo $row['name'];?></span><input id="edit_this_<?php echo $id?>" class="textbox" style="display:none;" type="text" name="name" value="<?php echo $row['name'];?>" /></td></tr></table>

html code ko sir.. kapag nagclick ung .edit_td dapat lalabas ung textbox tapos maghide ung span.. kaso gumagana lang ung isang table kasi po dun sa <td id="<?php echo $id; ?>" class="edit_td"> id ng member ung nakalagay kya kapag tinignan nyo yan iisa po sila at na prang ganito ang kakalabasan... sa source code sir

Code:
<td id="1" class="edit_td">
<td id="1" class="edit_td">

kaya ung una lang nababasa ung pangalawa hndi na lumalabas textbox kahit iclick.. sinubukan kong gawing class pero not working.. dq po alam paano.. tulong po.. at sana po naintindihan nyo ung mgulong code at paliwanag ko.. 3days na po akong stak jan eh.. please help po..
 
Last edited:
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

sir nid ko po example ng thickbox.. ung para s registration... san po ba ko pede makakuha ng sample nun? i nid sum mor improvement sa project ko ngaung summer e.. help po


anong thickbox un dude? sa drupal po ba?
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

salamat po dito sir.. pero iba pla ang gusto ng boss ko.. ang gsto nya kung anung field lang ang eedit nya un lang ang magiging textbox.. my nakita ako sa net.. pero d ko po maapply kasi dinidisplay nya ang lahat ng laman ng table nya. then gamit nya ang id ng bawat un para mapalabas ung texbox.. eto ung code ko sir.. check nyo po..


Code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
	<script type="text/javascript">
				$(document).ready(function()
				{
				$(".edit_td").click(function()
				{
				var ID =$(this).attr('id');
				$("#edit_"+ID).hide();
				$("#edit_this_"+ID).show();
				}).change(function()
				{
				var ID=$(this).attr('id');
				var name = $(this).attr('name');
				var etoangvaluenginedit=$("#edit_this_"+ID).val();
				var dataHere = 'id='+ ID +'&variablenyasapost='+etoangvaluenginedit+'&valuename='+name;
				$("#edit_"+ID).html('<img src="images/load.gif" />');


				if(etoangvaluenginedit.length>0)
				{
				$.ajax({
				type: "POST",
				url: "updatetheedit.php",
				data: dataHere,
				cache: false,
				success: function(html)
				{

				$("#edit_"+ID).html(etoangvaluenginedit);
				}
				});
				}
				else
				{
				alert('Enter something.');
				}

				});

				$(".textbox").mouseup(function() 
				{
				return false
				});

				$(document).mouseup(function()
				{
				$(".textbox").hide();
				$(".insidelabel").show();
				});

				});
			</script>

eto naman po ung snipnet ng code ko.. mahaba po kasi kaya eto nalang.. puro po kasi same lang..


Code:
<table><tr><td><label>Password</label></td><td id="<?php echo $id; ?>" class="edit_td"><span id="edit_<?php echo $id?>" class="insidelabel"><?php echo $row['username'];?></span><input id="edit_this_<?php echo $id?>" class="textbox" style="display:none;" type="text" name="username" value="<?php echo $row['username'];?>"/></td></tr>
<tr><td><label>Name</label></td><td id="<?php echo $id; ?>" class="edit_td"><span id="edit_<?php echo $id?>" class="insidelabel"><?php echo $row['name'];?></span><input id="edit_this_<?php echo $id?>" class="textbox" style="display:none;" type="text" name="name" value="<?php echo $row['name'];?>" /></td></tr></table>

html code ko sir.. kapag nagclick ung .edit_td dapat lalabas ung textbox tapos maghide ung span.. kaso gumagana lang ung isang table kasi po dun sa <td id="<?php echo $id; ?>" class="edit_td"> id ng member ung nakalagay kya kapag tinignan nyo yan iisa po sila at na prang ganito ang kakalabasan... sa source code sir

Code:
<td id="1" class="edit_td">
<td id="1" class="edit_td">

kaya ung una lang nababasa ung pangalawa hndi na lumalabas textbox kahit iclick.. sinubukan kong gawing class pero not working.. dq po alam paano.. tulong po.. at sana po naintindihan nyo ung mgulong code at paliwanag ko.. 3days na po akong stak jan eh.. please help po..




Code:
<?php
	// here should be the server codes
	if( isset( $_GET['ajax'] ) && isset( $_POST['username'] ) )
	{
		// ajax request must return a plain text or json
		header( "Content-type: text/plain" );

		// validation here

		// save to the database
		echo "Thanks $_POST[name]. Your information was updated successfully.";

		// exit because this is an ajax request
		exit;
	}
// to test, the $row value is defined
$row = array (
	"username" => "zidaine_38",
	"name" => "Secret Agent"
);

?><!-- limit the use of <table> element -->
<style>
.hidden-input {
	display: none;
	}
</style>
<form method="post" action="?" id="update">
<!-- use form element for non-javascript browser like android, etc. -->
<table>
	<tr>
		<!-- the context here is username not password -->
		<td width="100px" height="35px" valign="top"><label for="username">Username</label></td>
		<!-- use for attribute for xhtml validity -->
		<td width="150px" valign="top">
			<span class="data"><?php echo $row['username']; ?></span>
			<input type="text" class="edittable hidden-input" name="username" value="<?php echo htmlentities( $row['username'] ); ?>" />
		</td>
	</tr>
	<tr>
		<!-- Name is inappropriate. I'll use Full name here instead -->
		<td height="35px" valign="top"><label>Full Name</label></td>
		<td valign="top">
			<span class="data"><?php echo $row['name']; ?></span>
			<input type="text" class="edittable hidden-input" name="name" value="<?php echo htmlentities( $row['name'] ); ?>" />
		</td>
	</tr>
	<!-- I added submit/ edit button for full browser support -->
	<tr>
		<td colspan="2" align="left">
			<input type="submit" id="button" value=" Update " name="save" />
		</td>
	</tr>
</table>
</form>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript">
// use shorthand 
$( function( )
{
	// get the data class elements
	// these are the span elements with data 
	$( '.data' )
		.click( function( )
		{
			// hide this right?
			$( this ).css( 'display', 'none' );

			// NOTE: dont use $( this ).hide( );


			// get the next input from its parent node
			// show it up by making its attribute "type" to text
			$( this ).parent( ).find( 'input.edittable' )
				.removeClass( 'hidden-input' )

				// get focused
				.focus();
		} );
 
	// get the edittble input
	// when the user got out of focus from this element..
	$( '.edittable' ).blur( function( )
	{ 
		// hide this by mking its attribute type to hidden
		$( this ).addClass( 'hidden-input' );

		// get the span class from the parent node which id the <td> element
		$( this ).parent().find( 'span.data' )
			// update the text content with the editted value
			.text( $( this ).val( ) )

			// show it by making its display property to "block"
			.css( 'display', 'block' );
	} );

	// now for the submit button
	$( '#button' )
		.click( function( e )
		{
			// prevent the form to auto submit
			e.preventDefault( );

			// serialize the data so as to limit hacker attempt
			// this will automatically generate post variables like:  name=johndoe&username=blahblah etc.
			var editted_data = $( '#update' ).serialize( );

			// pass it to the server for processing
			// the question mark here means "this page"
			$.post( '?ajax', editted_data, function( response )
			{
				// let the server do the validation to limit hcker attempt
				alert( response );
			} );
		} );
} );
</script>
 
Back
Top Bottom