Javascript Button & Function For PHP/MySQL Database

May 9, 2007

I have this PHP page that has the following functions...Insert Form into Table in MySQL DatabaseDelete Entry from Table in MySQL DatabaseA Link to a separate page where I Edit entries I have coded a PHP function for Delete. Looks like this:

// delete if provided        if (isset($_GET['id'])) {        // query to delete        $query = "delete from student where STUDENT_ID =".$_GET['id'];        //execute query        if ($db->query($query)) {

Somewhere else I query the results and print them into a table. I added a column to this table with a Delete link for each row. Clicking on delete will execute the PHP function to delete.

The link looks like this: PHP Code:

echo "<td><a href=".$_SERVER['PHP_SELF']."?id=".$row[0]."></a></td>";

Likewise the first names also have links when clicked bring the user to another page with a form to edit form data.

The link looks like this: PHP Code:

echo "<td><a href='editstudent.php?id=".$row[0]."'>".$row[1]."</a></td>";

From here however I need to change those links to Buttons. One for Delete and another for Edit and use JavaScript functions to make them work as they originally did. So this is what I've done...

<td><form name='myform1'><input type='button' name='edit' value='Edit'
<td><form name='myform2'><input type='button' name='delete' value='Delete'

Next I need to write functions...this is where I am lost. Usually I'd know what to do when referencing elements in forms, i'd do something like document.formname.inputname, but my problem is those links or should I call them actions are replaced by those new buttons.

Should I put them into a form, or make them hidden, and then name the element? Or should my function look something like this...all I really want to do is to call the function, and have the function just do the action of loading the link (don't know if that sounds clear). I've tried to do this but it does not work.

<script>
function Delete()
{
document.myform2.action="href='$_SERVER['PHP_SELF']."?id=".$row[0]'";
document.myform2.submit();
}
</script>

Can anyone tell me what i am doing wrong, and could you please point me in the right direction?

View 6 Replies


ADVERTISEMENT

Java - Database - Post Form To Mysql - Only Posting First Letter Of Word/phrase For Text Input Fields To Mysql Database

Jul 13, 2011

I am having no luck with my post form to mysql. It is only posting the first letter of the word/phrase for the text input fields to the mysql database. It is a photo and text post form. The photo and only first letter of text are posting to database. I am using Jqtouch, jquery, and phonegap.

Here is my form fields:

Here is my java script:

View 3 Replies View Related

Output Data From Mysql Database In Javascript?

Mar 16, 2004

Not sure if this is the correct forum as it covers data retrieved from mysql in a .js file...

I need to grab the last 5 rows from my database (2 fields per row) and list all 5 in a table but from within a .js file that I can externally link to.

I can manage the php / mysql and the output to a .php page but how can this be contained within a .js file?

I believe it is possible but after 2 days of searching on google I'm appealing for assistance.

I realise this could be done with a php include or iframe but that isn't an option and the only way available to import this data is via an external javascript script.

View 3 Replies View Related

Connect With MYSQL Database?

Feb 2, 2010

how to connect with MYSQL database using javascript..

View 3 Replies View Related

JQuery :: Delete A Row Into Mysql Database?

Aug 24, 2010

I want to ask you is it possible to use jquery dialog with php. Using this tutorial [URL] I want to call a php script with will delete a row into Mysql database.

View 2 Replies View Related

Selecting Second Arraylist From Mysql Database ?

Dec 19, 2010

Below i have attached my code. This code is working.....but i want some modification in that code such that when i select 'vegetable' or 'fruits', it should give list of that selected one in second list, BUT THAT list should be stored in mysql database.

In the below program , i have hard-coded that second list, but i want second list to be dynamic from database.

Code:

View 2 Replies View Related

Checking Mysql Database For Username

Sep 21, 2006

I am trying to execute a query in mysql using javascript to check the username isnt taken, but dont know how.

View 3 Replies View Related

JQuery :: Insert Data In Database Mysql With Php?

Jun 15, 2009

I'm triyng to use the $.ajax jquery function to insert some dates in a database, using php.I have the page that insert the data called : sign.php and in the page I have the form, and the ajax scritp.

$("#submit_sign").click(function(data){
$.ajax({
type: "POST",
url: ("sign.php"),

[code]....

if I use the page without ajax it works, if I use the script jquery it works but doesn't insert the dates in the field, it send only white field. can't pass the variable POST beetween the ajax script and the php script.

View 1 Replies View Related

JQuery :: Autocomplete Integrated With MySQL Database

Nov 3, 2011

I am working on a project for which I need an autocomplete form which uses the value from a mysql database. I've seen many examples about using local data.

View 1 Replies View Related

Populating Order Form From Mysql Database

Oct 1, 2010

Am looking to find the easiest way to populate an order form that customers can email through to us.

I have created a database with 2 fields, id and name.

I would like to be able to have a form on my page with 3 fields, id name and qty.

I want to link the id and name fields on my form to my database so that when a customer starts to type a product id or description it will show a list of available matches. underneath which once clicked will populate the mssing field.

So for example is i have 2 products id 998 green apples and 999 red apples.

Typing in 999 in the id field of the form would populate the name field with red apples and typing red apples in the name field would populate the id field with 99.

if someone didn't know which apples they wanted they could type apples in the name field and underneath it would show both red and green which when clicked will populate both fields.

View 1 Replies View Related

Retrieve Value From Variable And Store To Mysql Database By Using Php

Mar 29, 2009

i have a image that need user click on it and get the coordinates and store the coordinates to mysql database by using php. Here my code:

Code:
<script type="text/javascript">
function(ev){
var pos=zxcPos(this.img);
var mse=[ev.clientX-pos[0],ev.clientY-pos[1]];
var ary=this.ary;
if (ary.length>4)
[Code]...

View 2 Replies View Related

Set A Variable As A Query Result From A MySQL Database

Apr 15, 2008

Does anyone know how to set a javascript variable as a query result from a MySQL database.

As an example, like this:

Set this query:

I just can't do it. I've tried doing it like this:

But the thing stops my <body onLoad=""> function from working. I'm no expert in Javascript.

View 9 Replies View Related

Insert Data Into The Mysql Database Using Ajax

Oct 19, 2009

The below coding is the javascript coding in which i have used AJAX coding also.its only pagenavigation coding.

function change(which)
{
if(which=="page1")
{
document.getElementById(which).style.borderBottomColor="white";
document.getElementById("page2").style.borderBottomColor="#778";
document.getElementById("page3").style.borderBottomColor="#778";
document.getElementById("page4").style.borderBottomColor="#778";
[Code]...

View 4 Replies View Related

Google Maps And MYSQL Database Synchronisation

Jul 13, 2011

My google map route creator. And of coure, I made my google maps route creator source.

Now i need :

1) Make markers draggable and animate;
2) Store, retrieve and delete route and marker positions to database;
3) Automatic route calculations (total route lenght and lenght between markers).

How to create file for databas synchronisation and retrieve data from database?

View 7 Replies View Related

JQuery :: Mysql - Displays All The Data Of The Database

Nov 13, 2011

I have a .load that executes a php mysql query from another page. This query displays all the data of the database. Each result is wrapped around a div.

<div id ="post<? echo $row['post_id']; ?>">

the id of the div depends on the post id of the result. How do I put the data of $row['post_id'] in my javascript?

View 6 Replies View Related

Display Data From Mysql Database Using GetJSON?

Oct 10, 2010

I'm trying to display data from mysql database using getJSON

this is the code JQuery Code

Code:

//get data from database
$.getJSON('getCategories.php', parseCat);
// display data

[Code]....

View 2 Replies View Related

Ajax :: Form Retrieves Results From A Mysql Database

Jun 22, 2011

This form retrieves results from a mysql database. It works fine but when I click submit it shows the result only for a second. When I hold down submit the result stays there. How do I get the result to stay on the screen after I hit submit? Even better how do I get it to spit out results without having to hit a submit button or press enter?

View 15 Replies View Related

Validate If User Input Already Exists In MYSQL Database

Feb 15, 2012

I've got this form that needs to check if the user input is already in the database, if this isn't the case it should disable the submit button and display an error depending on which input isn't found.

eg. client name isn't found...

This is the form:

How do I get this to work?

View 1 Replies View Related

Image Rollover Using Images Stored In MySQL Database

Feb 12, 2010

I've been advised that the only way to accomplish this is via some hand-coded javascript, at which I'm a complete noob, so hopefully someone here might be able to steer me in the right direction.I have a listings page which displays results using images and text which are stored in a MySQL database, all is working fine. The images are pulled into the page from the database and each listing can have up to a maximum of 10 images. Some will have all 10, some probably one or two, so the page is coded such that if there's an image in the field, it displays a thumbnail, if there isn't then it shoves a " " in instead.The results page has one main photo (image 1) and then a series of thumbnails (images 2-10) below it and I need to be able to set this up so that when someone clicks on image 2 it shows the full-size version of that image in the div where image1 sits, and the same for however many remaining images there are.

So my question is, how easy it is to do this with javascript and does anyone have any idea how to code it?The main photo sits in a div whose id is "mainphoto" the remainder all sit in a div whose id is "thumbpix".

View 1 Replies View Related

Generate Table From Which Can Easily Edit Contents Of A MySQL Database

Jul 30, 2009

I would like to be able to generate a table from which I can easily edit the contents of a mySQL database (similar to phpMyAdmin.) In that table I would like to have a button that will open a pop-up, allowing me to edit - and maintain formatting such as apostrophes and line breaks - a long description field. That popup will then populate a hidden input field on its parent with the modified description.

I've got the pop-up opening and its fields are populated using php's GET function (see line 11). The special characters, particularly carriage returns, are messing me up; I can remove them using php's str_replace, but I want to retain them for formatting.

View 1 Replies View Related

Onload / Onmouseover - Web Page That Accesses Mysql Database Data Through PHP

Apr 8, 2011

I am writing a web page that accesses Mysql database data through PHP then dynamically displayes the Mysql data when the user mouses over different parts of an imagemap. I use Javascript OnLoad function to load the Mysql data into the header and then I use the Onmouseover function to change the display dynamically.

Here is my question; when I mouse-over a part of an image the data in my side bar changes (exactly what I want) but I can't seem to make the data linkable. For example, when a user mouse-overs a certain part of the image, on the side bar it displays the companies web adr. How do I make that data a link? On the initial load the default data displayed is linkable but because I use <div> </div> to change the data dynamically, I loose the likability.

View 5 Replies View Related

Ajax :: Dropdown Menu Pulling Info From MYSQL Database?

Jun 20, 2009

I need to create three dropdown boxes (box 1:colour, box 2: price, box 3:brand) and when the user presses "GO" they are returned with the correct information, pulled from corresponding fields in my MYSQL database.

For example, colour: silver, price £100-£200, brand:samsung...should return 5 items on the page. I do not need the dropdown boxes to populate depending on ther previous selection - they are static, so to speak. If possible, I would like the information to be retuned to my page without the URL changing, which leads me to think I will need to be ausing ajax....?

View 2 Replies View Related

Mysql - Create A Site That Will Require A Database - Like Facebook Functions

Jul 30, 2009

I am trying trying to create a site that will require a database. (much like facebook functions)

I am not new to programming, as I know Java and C++, but I am very new to the web development.

For security reasons (so I have heard), I would like to write this site in php. At the same time, I may need some client sided code. (Or do I?) I am not at all sure.

I know that facebook is written in php, and the site I am making basically has the majority of those functions.

Any inputs as to how I should go about choosing what language? As of now, my partner is learning javascript and mysql, while I am studying php and mysql.

I know that some sites implement both, javascript and php, but I was wondering if it is at all necessary to use both, and how would one know which code to write in what language.

View 8 Replies View Related

JQuery :: Live Mysql Database Querying To Show Number Of Rows?

Jul 27, 2010

Basically i have a form with jqueryui implemented (autocompletes) and I need the form to display the number of current results as the user fills the form, i.e. once the user has finishedinputtingdata into one field, the form will query the database with the current form details and return just the number of results ($mysql_num_rows)

View 2 Replies View Related

Ajax :: Creating Page That Displays 'live' Data From Mysql Database?

Jun 6, 2010

could someone please point me in the right direction for creating an AJAX page that displays "live" data from a mysql database? I need the page to update its self every time data changes in a mysql table.

View 1 Replies View Related

Ajax :: Combobox Autocomplete - When The Client Types On The Drop Down, The Records Appear From MySQL Database?

Apr 14, 2010

I am looking for an Ajax combobox (drop down, not a text box) auto complete script. I searched for it on Google and only result which seems similar to what I am looking for, is dhtmlxCombo. And that one is too complicated for me. What I basicly need is:

When the client types on the drop down, the records appear from MySQL database and when the client chooses one and submits the form, I want the ID (not the text written) to be posted.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved