SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Apr 2012
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Editing/deleting information from a database through a webpage

    Hello!

    So, I am having a few problems with Dreamweaver. I will try and explain it (quite) succinctly at first, and rather try and elaborate if I don't get the answer I need.

    Anyway: I have made a connection with a MySQL-database with Dreamweaver CS3, and I have presented information from the tables in Query Browser through tables in DW. When I can make a simple query in order to this, I have no problems adding a column in the DW-table with a button or two saying "edit" and/or "delete", in order to edit/delete a single post of information in the table. However, when I want to make complex queries, I can't find out how to do this - I have a book on the subject, and it only explains how to make these buttons when we can make queries through the "simple" menu. I do not manage to do this when I have to use the advanced menu (which I have to do in order to present information in one table in DW from several tables in QB).

    So, in short; how do I get edit/delete buttons in a DW-table which a mod can use to easily edit information when I have to use advanced queries in order to present the information? (By the way, it is not that important with the delete-button, it's the edit-thing that bites me)

    In advance: thanks for all help!

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well, the real solution might not involve as many button-clicks or menus as you're hoping for...

    If you want to get any real use out of PHP, you need to learn it (and that doesn't involve dreamweaver or any other WYGIA {'what you get is awful'} editors). Can you post the source code of what you have and we'll see if we can help.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Member
    Join Date
    Apr 2012
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just the entire page? All right.

    Code:
    <?php require_once('Connections/mysqlconnection.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
    
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
    
    mysql_select_db($database_mysqlconnection, $mysqlconnection);
    $query_orderquery = "SELECT building.adress, bygning.zipcode, customer.name, order.worktype, order.status, order.notes, order.date FROM building, customer, order WHERE building.buildingid=order.buildingid AND customer.customerid=order.customerid ORDER BY order.date ASC";
    $orderquery = mysql_query($query_orderquery, $mysqlconnection) or die(mysql_error());
    $row_orderquery = mysql_fetch_assoc($orderquery);
    $totalRows_orderquery = mysql_num_rows($orderquery);
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/sidemal.dwt" codeOutsideHTMLIsLocked="false" -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Taktekkerservice AS</title>
    <!-- InstanceEndEditable -->
    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
    <style type="text/css">
    <!--
    .style1 {font-family: Arial, Helvetica, sans-serif}
    -->
    </style>
    </head>
    
    <body>
    <table width="1000" border="1" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td valign="top"><span class="style1">Header</span></td>
      </tr>
      <tr>
        <td valign="top"><span class="style1">Buttons</span></td>
      </tr>
      <tr>
        <td valign="top"><!-- InstanceBeginEditable name="content" -->
          <p class="style1">Overview over all the orders that have been completed:</p>
          <p class="style1">&nbsp;</p>
        
          <table border="1" align="center" cellpadding="5" cellspacing="5">
            <tr>
              <td><span class="style1"><strong>The building's adress</strong></span></td>
              <td><span class="style1"><strong>Zip code</strong></span></td>
              <td><span class="style1"><strong>Customer's name</strong></span></td>
              <td><span class="style1"><strong>Type of work</strong></span></td>
              <td><span class="style1"><strong>Status</strong></span></td>
              <td><span class="style1"><strong>Notes</strong></span></td>
              <td><span class="style1"><strong>Date</strong></span></td>
            </tr>
            <?php do { ?>
            <tr>
              <td><span class="style1"><?php echo $row_orderquery['adress']; ?></span></td>
              <td><span class="style1"><?php echo $row_orderquery['zipcode']; ?></span></td>
              <td><span class="style1"><?php echo $row_orderquery['name']; ?></span></td>
              <td><span class="style1"><?php echo $row_orderquery['worktype']; ?></span></td>
              <td><span class="style1"><?php echo $row_orderquery['status']; ?></span></td>
              <td><span class="style1"><?php echo $row_orderquery['notes']; ?></span></td>
              <td><span class="style1"><?php echo $row_orderquery['date']; ?></span></td>
            </tr>
            <?php } while ($row_orderquery = mysql_fetch_assoc($orderquery)); ?>
                </table>
          <p align="center" class="style1">Total number of orders completed: <?php echo $totalRows_orderquery ?> </p>
        <!-- InstanceEndEditable --></td>
      </tr>
    </table>
    </body>
    <!-- InstanceEnd --></html>
    <?php
    mysql_free_result($orderquery);
    ?>

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,330
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Gathoon View Post
    $query_orderquery = "SELECT building.adress, bygning.zipcode, customer.name, order.worktype, order.status, order.notes, order.date FROM building, customer, order WHERE building.buildingid=order.buildingid AND customer.customerid=order.customerid ORDER BY order.date ASC";
    see that bit there in red? that'll cause a syntax error

    also, ORDER is a reserved word, you shouldn't be using it as a table name
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Member
    Join Date
    Apr 2012
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, well, you can ignore those parts - I am making a webpage in another language, so I thought I'd translate the parts of the code that I had used in my own language to English, but it seems I forgot doing it at some places. I don't use "order" as a table name, and that part you marked in red is correct in my code.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •