gtd-php
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 08, 2010, 10:00:14 PM

Login with username, password and session length
Search:     Advanced search
1756 Posts in 305 Topics by 422 Members
Latest Member: jong21
* Home Help Search Calendar Login Register
+  gtd-php
|-+  gtd-php
| |-+  gtd-php dev
| | |-+  Extending gtdphp problem with INSERT into
« previous next »
Pages: [1] Print
Author Topic: Extending gtdphp problem with INSERT into  (Read 311 times)
raamklaza
Full Member
***
Posts: 20


View Profile
« on: July 07, 2010, 01:15:46 PM »

Hello i am trying to extend gtdphp to make it more complete for my own daily usage.

I am making changes on top of the orginal 0.9 code.

However i am having some problems with a simple INSERT query... I can't figure out how you guys make it work.
I want to make a quick add section where a user can just simple enter an inbox item from everywhere in the application.
So i need to send the title into {prefix}items and the type into {prefix}itemstatus

This is what i have, but i can't figure out how to make the db_connection and the post in db stuff work...

Code:
<div id="header">
<h1 id='sitename'><a href='index.php'><?php
        
echo $_SESSION['config']['title'];
    
?>
</a><?php
        
echo ' ',(isset($titlefull))?$titlefull:$title;
    
?>
</h1>
<?php

if($_SERVER['REQUEST_METHOD'] == 'POST') { 
// $inboxitem=$_POST[inboxitem];
$sql "INSERT INTO gtdphp_items (title) 
                                         VALUES('"
.mysq_real_escape_string($_POST['inboxitem'])."')";
/* for second table post $sql2="INSERT into tabel_anders(achternaam,tussenv,voornaam,geb_datum) VALUES ('i')"; */
/* $sql="INSERT INTO `gtdphp_items`
(`title`,`description`,`desiredOutcome`,`recurdesc`,`recur`)
VALUES ('{$values['title']}','{$values['description']}',
'{$values['desiredOutcome']}',
                        '{$values['recurdesc']}','{$values['recur']}')"; */

$res mysql_query($sql,connectdb($config)); 
/* $res2 = mysql_query($sql2); */

if(!$res
{
echo("Something went wrong with the query: ".mysql_error($connection)." (".$sql.")");
}
else 

echo "Item Added<hr>"


}

    
?>

<form action="" method="post" name="quickaddinbox">
Quick add: <input type="text" name="inboxitem" />
<input type="button" name="add" value="add" />
</form>
</div>

I hope someone can help me out a bit! When i figure this out i am all good Smiley


Another question, my shortcut keys don't work. Alteast not in Chrome, didn't try another browser yet. Any else has this problem or a solution for this?
« Last Edit: July 07, 2010, 01:38:46 PM by raamklaza » Logged
Andrew
Administrator
Hero Member
*****
Posts: 375


View Profile
« Reply #1 on: July 08, 2010, 07:07:55 AM »

include headerDB.inc.php - that should do all the database connections for you.

There are library calls to add things to the db easily - have a look in some of the addins for examples.

Chrome keyboard shortcuts will only work if the link that they represent, is visible on-screen. So if you're using drop-down menus, they generally won't work (unless you hover over the dropdown, but then you may as well click on the link as use the shortcut)

Ways around this:

use a sidebar theme rather than a dropdown theme.

or

tweak the code so that it displays all of the links with accesskeys - maybe in a tiny box at the bottom of the screen, or something.
Logged
raamklaza
Full Member
***
Posts: 20


View Profile
« Reply #2 on: July 08, 2010, 08:43:45 AM »

Hi Andrew,

Thnx for the quick reply.

I will look in to the addons and try to figure it out.
On top of the page i already included headerDB.inc.php


About the keyboard shortcuts, i have a sidebar theme so the links i try are visible on-screen. But the shortcuts don't work Sad I also checked a non-edited version of gtd-php and there also the keyboard shortcuts don't work
Logged
raamklaza
Full Member
***
Posts: 20


View Profile
« Reply #3 on: July 08, 2010, 01:01:46 PM »

Hi Andrew,

Me again. Smiley

I looked into the addons and i added this "feature" with a lot of ease Smiley
I really like the way the program is builed, quite simpel and straight forward.

For people who want to add a quick add box on every page which makes a new inbox item use this code:

gtd-php 0.9 rc1
Code:
// headerMenu.inc.php line 150 till 165

<div id='container'>
<div id="header">
h1 id='sitename'><a href='index.php'><?php
        
echo $_SESSION['config']['title'];
    
?>
</a><?php
        
echo ' ',(isset($titlefull))?$titlefull:$title;
    
?>
</h1>
<form method='post' action='processItems.php'>
<div>
Quick add: <input type='text' name='title' /> <font color="gray">(press enter)</font>
<input type='hidden' name='type' value='i'>
<input type='hidden' name='action' value='create'>

</div>
</form>
</div>
Logged
Andrew
Administrator
Hero Member
*****
Posts: 375


View Profile
« Reply #4 on: July 08, 2010, 01:08:52 PM »

keyboard shortcuts - that's odd. Which version of Chrome? I've got 6.0.543.1 (dev), and when I press ALT+SHIFT+F, for example, it pulls up the GTD quick-find screen fine.
Logged
raamklaza
Full Member
***
Posts: 20


View Profile
« Reply #5 on: July 08, 2010, 01:16:17 PM »

I just tried with the normal letter for example F or I Smiley I didn't read i had to use ALT+SHIFT....

Then it works fine.

Is there a place where i can customise the ALT+SHIFT?
Logged
Andrew
Administrator
Hero Member
*****
Posts: 375


View Profile
« Reply #6 on: July 11, 2010, 03:21:07 PM »

Is there a place where i can customise the ALT+SHIFT?

I don't know, sadly.  That's a very specific question for Google Chrome, and it applies to all pages, not just gtd-php ones. There is an open source version of the browser, called chromium - the developer forums there might have an answer already.
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!