1 Replies - 543 Views - Last Post: 19 November 2009 - 01:03 PM Rate Topic: -----

#1 Michalak  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 22-January 09

Php with java script buttons and Mysql queries

Posted 19 November 2009 - 12:48 PM

I am having problems. I know javascript is client side and php is server side. What I am trying to do is delete a entry from the data base when I check the checkbox and press the delete button.

I don't know of a different way to do this. I was trying to figure out a way to maybe refresh the page and with refreshing then delete the entries from the data base using php. I am willing to do this a differnet way. But I'm a beginner at javascript and I can do what I need to with PHP. Thanks.


<?php require "useraccess.php";
$email=$_COOKIE["dummiesemail"];

  include('PUCheader.php');

?>

<?php


$db_host = 'localhost';
$db_user = 'School';
$db_pwd = 'school';

$database = 'school';
$table = 'location';

if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");

if (!mysql_select_db($database))
die("Can't select database");


$result = mysql_query("SELECT * FROM {$table}  WHERE email = '$email' AND  RequestDate >= CURDATE() ORDER BY RequestDate, RequestTime ");

if (!$result) {
die("Query to show fields from table failed");
}



$fields_num = mysql_num_fields($result);

echo "<center>";
echo "<table border='1'>";
echo "<tr><th>	</th><th> Date </th> <th> Time </th><th> Pick Up Location </th><th> Destination </th><th> Name </th></tr>";

while($row = mysql_fetch_array($result)){
   $time =$row['time'];
   $ID=$row['Index'];
   echo "<tr><td>";
   print "<center><form><input type=\"checkbox\" name=\"nID[]\" value=\"vID[]\" onclick=\"del(this)\" ></form></center>";
   echo "</td><td>";
   echo $row['RequestDate'];
   echo "</td><td>";
   echo $row['RequestTime']. " " .$time;
   echo "</td><td>";
   if($row['bStreetNum'] == 0 && $row['bStreetAdd'] == null && $row['bCity'] == null &&$row['bZip'] == 0){
		 echo $row['slStart'];
		 echo "</td>";
   }
   else{
	  echo $row['bStreetNum'] . " "; echo $row['bStreetAdd'] . ", "; echo $row['bCity'] . " "; echo $row['bZip'];
	  echo "</td>";
   }
   echo "<td>";
   if($row['dStreetNum'] == 0 && $row['dStreetAdd'] == null && $row['dCity'] == null &&$row['dZip'] == 0){
		 echo $row['dDest'];
		 echo "</td>";
   }
   else{
	  echo $row['dStreetNum'] . " "; echo $row['dStreetAdd'] . ", "; echo $row['dCity'] . " "; echo $row['dZip'];
	  echo "</td>";
	  //echo "</td><td>";
   }
   echo "<td>";
   $email = $row['email'];
   $resultname = mysql_query("SELECT Name from school.login where email = '$email'");

   $disName = mysql_fetch_array($resultname);
   //if($email == $disName['Name']){

	  echo $disName['Name'];
	 // }
   echo "</td></tr>";
}
echo "</table>";

echo "</center>";

?>
<b>To cancel a ride request:<br> 1.) Check the box for the request to cancel.<br> 2.) Click the Cancel button.<br><br></b>
<input type= "button"  value ="Cancel" name="Cancel" onclick ="clk = true; clickbutton();" >

<br><br>
<INPUT TYPE="button" VALUE="Back" onclick="history.go(-1);return true;">
<bb>
<input type=button onclick="location.href='ScheduleMap.php'" value='Todays Schedule'>



<script language= "javascript">
clk = false;
checked = false;
function del(f) {
	  if(f.checked){
		   //alert("delete");
	  return checked = true;

   }
	  else return checked = false;

}


function clickbutton(){
   if(clk == true){
	  if(checked == true){
		 alert("checked then clicked");
		 //function for deleting from mysql entry
	  }
   }
}

//funciton to delete

</script>



<?php

// include the page footer
include('PUCfooter.php');

?>







Is This A Good Question/Topic? 0
  • +

Replies To: Php with java script buttons and Mysql queries

#2 ludjer  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 186
  • Joined: 31-October 08

Re: Php with java script buttons and Mysql queries

Posted 19 November 2009 - 01:03 PM

you have 2 options AJAX(the one you are most proberly going to end up using) or you set your delete button like a submit button that it will send you with the selected items to delete.php or what ever
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1