Jquery get the id of clicked element and show hidden child div
i have an array of comments, and it should be possible to answer the comment.
<div>
<a href="#" class="answerBtn" id="<?=$comment->id ?>">Answer</a>
<div id="answerDiv" style="display:none;">
<form action="" method="POST">
<input type="hidden" value="<?=$comment->id ?>"/>
<p>
<label>Your name*</label>
<br />
<input type="text" name="answer_username"
id="answer_username" required />
</p>
<p>
<label>Your Email (optional)</label>
<br />
<input type="text" name="answer_email" />
</p>
<p>
<label>Your comment*</label>
<br />
<textarea name="answer_message" required></textarea>
</p>
<input type="hidden" value="<?=base_url()?>"
id="answer_baseurl"/>
<input type="submit" value="Send"/>
</form>
</div>
i want to display the form when clicking the link, but because each
comment has the same form i have to be specific, so i want to show the
form depending on the id of the comment. so i tried something like this
with jquery:
$('.answerBtn').click(function(){
var id = $(this).attr('id');
$('id + div').slideToggle();
});
but that doesn't really work...
can someone help me out?
Thursday, 3 October 2013
Wednesday, 2 October 2013
Why SQLSTATE[42000]: Syntax error or access violation?
Why SQLSTATE[42000]: Syntax error or access violation?
I would like to run this Doctrine Query Builder query:
$repository = $this->getDoctrine()->getRepository('MyBundle:Usage');
$warranty_usage = $repository->createQueryBuilder('u')->where('u.var =
\'warranty\'')->getQuery()->getSingleResult();
But I always get:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error
in your SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'Usage u0_ WHERE u0_.var =
'warranty'' at line 1
This is my Usage entity:
<?php
namespace Herbanist\AdminBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Usage
*
* @ORM\Table()
* @ORM\Entity
*/
class Usage
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="var", type="string", length=20)
*/
private $var;
/**
* @var string
*
* @ORM\Column(name="value", type="text")
*/
private $value;
public function getId()
{
return $this->id;
}
public function setVar($var)
{
$this->var = $var;
return $this;
}
public function getVar()
{
return $this->var;
}
public function setValue($value)
{
$this->value = $value;
return $this;
}
public function getValue()
{
return $this->value;
}
}
Usage table:
mysql> select * from `Usage`;
+----+----------+-------+
| id | var | value |
+----+----------+-------+
| 1 | warranty | 0 |
+----+----------+-------+
I would like to run this Doctrine Query Builder query:
$repository = $this->getDoctrine()->getRepository('MyBundle:Usage');
$warranty_usage = $repository->createQueryBuilder('u')->where('u.var =
\'warranty\'')->getQuery()->getSingleResult();
But I always get:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error
in your SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'Usage u0_ WHERE u0_.var =
'warranty'' at line 1
This is my Usage entity:
<?php
namespace Herbanist\AdminBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Usage
*
* @ORM\Table()
* @ORM\Entity
*/
class Usage
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="var", type="string", length=20)
*/
private $var;
/**
* @var string
*
* @ORM\Column(name="value", type="text")
*/
private $value;
public function getId()
{
return $this->id;
}
public function setVar($var)
{
$this->var = $var;
return $this;
}
public function getVar()
{
return $this->var;
}
public function setValue($value)
{
$this->value = $value;
return $this;
}
public function getValue()
{
return $this->value;
}
}
Usage table:
mysql> select * from `Usage`;
+----+----------+-------+
| id | var | value |
+----+----------+-------+
| 1 | warranty | 0 |
+----+----------+-------+
C++ Main file does not display everything
C++ Main file does not display everything
My program read a *.txt file and prints a line from the file backwards. i
wanted to get the linenumber before it does so. after doing the loop, i
got my number, but everything after my "for loop" is not printing/
working. what is wrong with my code?
#include "oneLine.h"
#include <iostream>
#include <fstream>
using namespace std;
int main () {
OneLine aline;
ifstream testFile ("test.txt");
if (testFile.good()) {
int countLines = 0;
string temp;
for (int i = 0; getline(testFile, temp); i++)
countLines++;
cout << countLines;
aline.readLine(testFile);
aline.breakLine();
aline.printReverse();
//int a = aline.totalLines(testFile);
} else {
cout << "Error: Invalid File.";
}
return 0;
}
My program read a *.txt file and prints a line from the file backwards. i
wanted to get the linenumber before it does so. after doing the loop, i
got my number, but everything after my "for loop" is not printing/
working. what is wrong with my code?
#include "oneLine.h"
#include <iostream>
#include <fstream>
using namespace std;
int main () {
OneLine aline;
ifstream testFile ("test.txt");
if (testFile.good()) {
int countLines = 0;
string temp;
for (int i = 0; getline(testFile, temp); i++)
countLines++;
cout << countLines;
aline.readLine(testFile);
aline.breakLine();
aline.printReverse();
//int a = aline.totalLines(testFile);
} else {
cout << "Error: Invalid File.";
}
return 0;
}
Access a database from a DialogFragment and toast a message
Access a database from a DialogFragment and toast a message
I have a DialogFragment which displays a simple yes/no question. When the
user presses "yes", I perform a database request (which basicaly deletes
an entry). I then toast a message to report a success or failure to the
user.
I try to avoid calling the database from the UI thread, so I created a
thread which will delete the entry, and from that thread I call a handler
in the DialogFragment to display the toast message.
My problem is that when the user presses the button, the thread is started
and the dialog is closed. As the thread is started, the data is deleted
from the database. But when I toast my message from the handler, the
DialogFragment is already detached from the parent Activity so I don't
have a context anymore to call Toast.makeText().
My question is how can I toast the message ?
I know I could create a Service to handle the database operation, but
wouldn't it be too much hassle ? Is there a simpler way ?
Thanks !
I have a DialogFragment which displays a simple yes/no question. When the
user presses "yes", I perform a database request (which basicaly deletes
an entry). I then toast a message to report a success or failure to the
user.
I try to avoid calling the database from the UI thread, so I created a
thread which will delete the entry, and from that thread I call a handler
in the DialogFragment to display the toast message.
My problem is that when the user presses the button, the thread is started
and the dialog is closed. As the thread is started, the data is deleted
from the database. But when I toast my message from the handler, the
DialogFragment is already detached from the parent Activity so I don't
have a context anymore to call Toast.makeText().
My question is how can I toast the message ?
I know I could create a Service to handle the database operation, but
wouldn't it be too much hassle ? Is there a simpler way ?
Thanks !
Tuesday, 1 October 2013
PHP/SQL Where, And, Order By -- works on one statement but getting an error on another similar query
PHP/SQL Where, And, Order By -- works on one statement but getting an
error on another similar query
I'm trying to add a section that shows if any year end awards are won by
an individual. I have any Champions and Reserve Champions showing just
fine. However, when I went to add the "year end awards" section I keep
getting this error:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'show = yearend
ORDER BY year DESC' at line 1
I have played around with apostrphes, using a LIKE statement, removing the
ORDER BY, and anything I could think of but I am at a loss. I can't seem
to figure out what changed from the working statements that would cause an
error.
This works just fine
<?php
$id = $_GET['id']; //Gets the ID from the URL
$result = mysql_query("SELECT * FROM competition
WHERE id = $id
AND place = 'CH'
ORDER BY year DESC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['class'];
echo "<small>(";
echo $row['show'];
echo ")</small><br>";
}
?>
This does not work The only change I made in the below is place = is now
show =
<?php
$id = $_GET['id']; //Gets the ID from the URL
$result = mysql_query("SELECT * FROM competition
WHERE id = $id
AND show = 'yearend'
ORDER BY year DESC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['class'];
echo "<br>";
}
?>
error on another similar query
I'm trying to add a section that shows if any year end awards are won by
an individual. I have any Champions and Reserve Champions showing just
fine. However, when I went to add the "year end awards" section I keep
getting this error:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'show = yearend
ORDER BY year DESC' at line 1
I have played around with apostrphes, using a LIKE statement, removing the
ORDER BY, and anything I could think of but I am at a loss. I can't seem
to figure out what changed from the working statements that would cause an
error.
This works just fine
<?php
$id = $_GET['id']; //Gets the ID from the URL
$result = mysql_query("SELECT * FROM competition
WHERE id = $id
AND place = 'CH'
ORDER BY year DESC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['class'];
echo "<small>(";
echo $row['show'];
echo ")</small><br>";
}
?>
This does not work The only change I made in the below is place = is now
show =
<?php
$id = $_GET['id']; //Gets the ID from the URL
$result = mysql_query("SELECT * FROM competition
WHERE id = $id
AND show = 'yearend'
ORDER BY year DESC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['class'];
echo "<br>";
}
?>
How to change screen color temperature using C++?
How to change screen color temperature using C++?
How would I change the color temperature / hue of the current screen in a
Windows C++ program? I know this is possible but am not sure where to
start.
How would I change the color temperature / hue of the current screen in a
Windows C++ program? I know this is possible but am not sure where to
start.
Unknowingly improving my players' luck rpg.stackexchange.com
Unknowingly improving my players' luck – rpg.stackexchange.com
As a GM, I'd like to give my players a lucky item, one that improves their
dice rolls. However, I don't want them to immediately realize that the
item is improving their rolls. One thought I had was …
As a GM, I'd like to give my players a lucky item, one that improves their
dice rolls. However, I don't want them to immediately realize that the
item is improving their rolls. One thought I had was …
Getting the widget toolkit for a particular window
Getting the widget toolkit for a particular window
Is there a way to get the widget toolkit used to draw a particular window?
Something like xprop or xwininfo that will show it to be GTK+, Qt or
similar.
Is there a way to get the widget toolkit used to draw a particular window?
Something like xprop or xwininfo that will show it to be GTK+, Qt or
similar.
Subscribe to:
Comments (Atom)