Skip navigation
Currently Being Moderated

Need help with Data Bridge/DataAssist!!

Apr 3, 2013 6:09 AM

Hi All,

So ive recently brought Data Bridge as i need to create a search box on a website i am developing. I have limited knowledge of Dreamweaver and so was advised to purchase Data Bridge in order to help me create my search box. This is what i would like my webpage to do -

 

The website is a funeral directors and i need to create a donations page with a search box so that donors can enter the deceased name and as a result a name (or names similar to what has been entered) will appear. Next to the name will be a URL.  Each deceased person(s) will have a unique URL, donation payments wont actually be taken on this website, the URL will link them to a different donations page for that individual on another website, the link will redirect them to that website (hopefully all that makes sense!).

 

Ive setup MAMP on my computer, created a table for database information in phpmyadmin, connected deamweaver to that database with a recordset, created a DataAssist Search Wizard php page which automatically inserts the form on my donations.html page (please see below - donations.html and php)

 

 

But i am now stuck as to what to do next. Will the results appear on this page or do i need to create a html page for results to appear on and a new php page for results? I am confused as to what i need to do?

 

Any help REALLY appreciated!!

 

 

screenshot.jpg

 

 

<?php require_once('Connections/milesdata.php'); ?>

<?php require_once("webassist/database_management/wada_search.php"); ?>

<?php

//WA Database Search (Copyright 2005, WebAssist.com)

//Recordset: milesdata;

//Searchpage: donations.html;

//Form: form1;

$WADbSearch2_DefaultWhere = "";

if (!session_id()) session_start();

if ((isset($_POST["WADbSearch2"])) && ($_POST["WADbSearch2"] != "")) {

  $WADbSearch2 = new FilterDef;

  $WADbSearch2->initializeQueryBuilder("MYSQL","1");

  //keyword array declarations

  $KeyArr0 = array("name");

 

 

  //comparison list additions

  $WADbSearch2->keywordComparison($KeyArr0,"".((isset($_POST["Name"]))? $_POST["Name"]:"")  ."","AND","Includes",",%20","%20","%22","%22",0);

 

 

  //save the query in a session variable

  if (1 == 1) {

    $_SESSION["WADbSearch2_search"]=$WADbSearch2->whereClause;

  }

}

else     {

  $WADbSearch2 = new FilterDef;

  $WADbSearch2->initializeQueryBuilder("MYSQL","1");

  //get the filter definition from a session variable

  if (1 == 1)     {

    if (isset($_SESSION["WADbSearch2_search"]) && $_SESSION["WADbSearch2_search"] != "")     {

      $WADbSearch2->whereClause = $_SESSION["WADbSearch2_search"];

    }

    else     {

      $WADbSearch2->whereClause = $WADbSearch2_DefaultWhere;

    }

  }

  else     {

    $WADbSearch2->whereClause = $WADbSearch2_DefaultWhere;

  }

}

$WADbSearch2->whereClause = str_replace("\\''", "''", $WADbSearch2->whereClause);

$WADbSearch2whereClause = '';

?>

<?php

 

 

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  if (PHP_VERSION < 6) {

    $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_milesdata, $milesdata);

$query_milesdata = "SELECT url FROM donation WHERE name = 'name' ORDER BY name ASC";

setQueryBuilderSource($query_milesdata,$WADbSearch2,false);

$milesdata = mysql_query($query_milesdata, $milesdata) or die(mysql_error());

$row_milesdata = mysql_fetch_assoc($milesdata);

$totalRows_milesdata = mysql_num_rows($milesdata);

?>

 

 

<?php

mysql_free_result($milesdata);

?>

 
Replies 1 2 Previous Next
  • Currently Being Moderated
    Apr 3, 2013 6:11 AM   in reply to Ness_quick

    Please take such support questions to the webassist support forum.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 6:28 AM   in reply to Ness_quick

    Normally, search results are displayed on a separate page. But DataBridge should have created this separate page for you. You will find the WebAssist forums to be very useful, but the community is not as active as this one in the sense that you rarely get immediate responses. Please be patient.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 6:45 AM   in reply to Ness_quick

    Ness_quick wrote:

     

     

     

    But i am now stuck as to what to do next. Will the results appear on this page or do i need to create a html page for results to appear on and a new php page for results? I am confused as to what i need to do?

     

    Any help REALLY appreciated!!

     

     

     

    You now need to create another page (commonly known as a Results Page) to display the results when the search form is submitted.

     

    This will list the name of the person which has been inserted into the search field with a url or if nothing is found you need to provide a message which says 'No Matches Found'

     

    If a match is found it lists the name and the unique url next to it.

     

    All of this could have been produced using the satndard Server Behaviours in Dreamweaver. I know there has been discussions about not using them now Adobe have offcially declared they will be removed in the next upgrade BUT Data Assist also uses the sql_ functions to connect to the datbase.

     

    First off you need to design your datbase information.

     

    You have the name of the deceased person.  That should be broken down into two fields foreName and surName. What other information do you require, just the url to the donations page which is outside of your own website?

     

    If so create a specific field for that in the database - donationsUrl

     

    Id ask the user to search by the 'surName' field in the database. When the results are returned you can get the foreName and donationsUrl infomation from the database.

     

    Of course the next issue you have is who is going to keep updating this every time someone dies? Are you going to provide the client with update/insert/delete pages?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 6:50 AM   in reply to Ness_quick

    Iooks like the code you have provided IS selecting the information from your database BUT that should be on the 'results page' not the page where the search box is.

     

    mysql_select_db($database_milesdata, $milesdata);

    $query_milesdata = "SELECT url FROM donation WHERE name = 'name' ORDER BY name ASC";

    setQueryBuilderSource($query_milesdata,$WADbSearch2,false);

    $milesdata = mysql_query($query_milesdata, $milesdata) or die(mysql_error());

    $row_milesdata = mysql_fetch_assoc($milesdata);

    $totalRows_milesdata = mysql_num_rows($milesdata);

    ?>

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 7:05 AM   in reply to Ness_quick

    So where is the following piece of code, on the search form page, or on another page which the search form links to?

     

    mysql_select_db($database_milesdata, $milesdata);

    $query_milesdata = "SELECT url FROM donation WHERE name = 'name' ORDER BY name ASC";

    setQueryBuilderSource($query_milesdata,$WADbSearch2,false);

    $milesdata = mysql_query($query_milesdata, $milesdata) or die(mysql_error());

    $row_milesdata = mysql_fetch_assoc($milesdata);

    $totalRows_milesdata = mysql_num_rows($milesdata);

     

     

     

     

     

    On your results page you need to now echo out the results:

     

    <td><?php echo $row_milesdata['url']; ?></td>

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 7:28 AM   in reply to Ness_quick

    Ness_quick wrote:

     

    Ive not yet created results page. I dont know if thats to be created using DataAssist. Just to be sure, do i need to create a html page that displays the results? or will this be another php file?

     

    Ive now amended the database table as Murray suggested. It now looks like this

     

    screenshot.jpg

     

    Do i need to alter the recordset now that my database table has changed?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 7:51 AM   in reply to osgood_

    osgood_ wrote:

     

    Ness_quick wrote:

     

    Ive not yet created results page. I dont know if thats to be created using DataAssist. Just to be sure, do i need to create a html page that displays the results? or will this be another php file?

     

    Ive now amended the database table as Murray suggested. It now looks like this

     

    screenshot.jpg

     

    Do i need to alter the recordset now that my database table has changed?

     

    Can you do a test, change the database fields back to how they were for now.

     

    Take all the initial code you posted and dump it into a new Dreamweaver document and save it as results.php

     

    The form, which should be on a page independent of the code you posted, needs to have its action tag pointing to the results.php page action="results.php" Also make sure the input field name is set to name="Name"

     

    On the results page insert a simple table like below:

     

    <table width="600" cellpadding="0" cellspacing="0" border="0">

    <tr>

    <td><td><?php echo $row_milesdata['url']; ?></td></td>

    </tr>

    </table>

     

    If the results.php page is getting the information from the database the url field will be returned assuming you have a url in it of course.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 8:36 AM   in reply to Ness_quick

    Probably would have been much easier for you to have used the Dreamweaver server behaviours maybe.

     

    All you would have really need to do was create a blank results.php page. Go to Window>Server Behaviours and create recordset - name it rsDonationResults. Select the 'connection' and 'donation' table (if they havent already been automatically selected by DW) Columns select ALL then filter by the database name column, choose form variable from the drop down directly beneath that and in the field opposite type in the form field name you have given your search form. That should be it.

     

    Then all you do is insert a table on the results.php page, put in a bit of place holder text. Go to the bindings tab and select name, click insert. That binds the database name field to the text.

     

    If all goes well the name should be retreived from the database. Do the same for the url next to the name binding

     

    Make sure the forms action tag points to the results.php page

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 9:16 AM   in reply to Ness_quick

    Ness_quick wrote:

     

    Right ive done the above thread and changed the action on the donation.html (where search box is), i then tried testing it but when hit the search button and all i is a blank page with ';' a semi colon. This is what is in the results.php page -

     

    <?php require_once('Connections/milesdata.php'); ?>

    <?php

    if (!function_exists("GetSQLValueString")) {

    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

    {

      if (PHP_VERSION < 6) {

        $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;

    }

    }

     

     

    $colname_rsDonationResults = "-1";

    if (isset($_POST['form1'])) {

      $colname_rsDonationResults = $_POST['form1'];

    }

    mysql_select_db($database_milesdata, $milesdata);

    $query_rsDonationResults = sprintf("SELECT * FROM donation WHERE name = %s", GetSQLValueString($colname_rsDonationResults, "text"));

    $rsDonationResults = mysql_query($query_rsDonationResults, $milesdata) or die(mysql_error());

    $row_rsDonationResults = mysql_fetch_assoc($rsDonationResults);

    $totalRows_rsDonationResults = mysql_num_rows($rsDonationResults);

     

     

    mysql_free_result($rsDonationResults);

    ?>

    <table width="200" border="0" cellspacing="auto" cellpadding="4">

      <tr>

        <td> </td>

      </tr>

      <tr>

        <td> </td>

      </tr>

      <tr>

        <td><?php echo $row_rsDonationResults['name']; ?></td>

      </tr>

      <tr>

        <td><?php echo $row_rsDonationResults['url']; ?>;</td>

      </tr>

      <tr>

        <td> </td>

      </tr>

    </table>

     

    What's the name of your search box field name? Its not form1 is it that's the name of the form itself, right? Go back to the recordset, click on it in the panel and wait till it opens up, replace form1 which is opposite  'form variable' you selected from the drop down with the name of the search box field name.

     

     

    Probably my mistake I just re-read what I originally wrote and I dont make that part very clear.

     

     

    $colname_rsDonationResults = "-1";

    if (isset($_POST['form1'])) {

      $colname_rsDonationResults = $_POST['form1'];

    }

     

    So if the name you have given to the search box input field is name="name" the below would look like:

     

    $colname_rsDonationResults = "-1";

    if (isset($_POST['name'])) {

      $colname_rsDonationResults = $_POST['name'];

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 9:28 AM   in reply to osgood_

    Hi there - I use DataBridge. First up, I'm surprised you say the forums aren't very helpful. I've found the support from WebAssist to be fantastic. It can take a while to get used to how stuff works, but it is pretty good.

     

    I haven't read all of the above, but DataAssist should create your search and results pages - so it may be that you just didn't set them up.

     

    Try the following starting from scratch again. I'm going to assume you have a database table set up, and a database connection set up.

     

    The following will create any or all of the following pages: Search, Results, Detail, Insert, Update.

     

    1. Select Web Assist > Database > Data Assist Pages from the menu at the top.

     

    2. In the first tab, Page Settings, select your connection. Select New from Blank for Application type. Select the table and key column.

     

    3. In the second tab, Manage Pages, under Configure Field Settings, click on the little pencil / edit button. In there select all the fields you want to use, with any validation. You won't necessarily use all the fields on all the pages, but you can still set them up here.

     

    Under 'Define Features' click on the + icon, and select the pages you want to create. Presumably search, results and possibly a details page.

     

    For each you select, it will bring up another box click the + icon to add any fields you want to appear on the page you are adding.

     

    You can ignore the server settings tab - that is used if you want to send any emails.

     

    When you're done click finish, and it will create the pages for you.

     

    Common things to watch - make sure you upload all the pages, and all the associated files. I usually just upload the entire webassist folder to make sure I don't miss anything.

     

    Anyway - hope that helps. If you need any more, try again at the web assist forums - they really are very good.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 9:31 AM   in reply to Ness_quick

    Ness_quick wrote:

    Ive just spotted this in the form1 for donations.html code -

     

    <input name="WADbSearch2" type="submit" class="submit" value="Search" >

     

    Could this be the problem, "WADbSearch2" this is what DataAssist developed. But what should it be changed to?

    For sure that's the problem.

     

    Change WADbSearch2 to Name as below:

     

    <input name="Name" type="submit" class="submit" value="Search" >

     

    The results.php page is getting the information from a form input field with the name of 'Name' as is shown below:

     

    $colname_rsDonationResults = "-1";

    if (isset($_POST['Name'])) {

      $colname_rsDonationResults = $_POST['Name'];

    }

     

    If it can't get anything nothing will be shown on your page which is where the server behaviour show regions comes in handy but lets get a result on the page first.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 10:00 AM   in reply to Ness_quick

    OK I may have stumbled across why this is happening. What 'method' is your search form using to obtain the information in the form tags method field?

     

    If it is 'get' then change it to 'post' as below:

     

     

    method="post"

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 10:18 AM   in reply to Ness_quick

    The data you have entered into the database looks alright to me.

     

    I'm leavng my office for the evening now BUT I'm determined we can sort this out so if you havent done so by the time I get back in tomorrow we can take it from there, I'm in the UK too.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 10:32 AM   in reply to osgood_

    I've just had time to test your main code and there is nothing wrong with that so it must be something do with the form page.

     

    Can you post the form itself so I can have a look at it and make sure there is no stuff which this Data Assist has written on the page.

     

    As a test just insert a basic form on a new DW page, make sure it points to the results.php page:

     

    <form id="form1" name="form1" method="post" action="results.php">

    <label>

    Search

    <input type="text" name="Name" id="Name" />

    </label>

    <input type="submit" name="button" id="button" value="Search" />

     

    </form>

     

    Also are you typing in the full name Rita King and spelling it correctly because if  not no result will be returned.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 10:45 AM   in reply to Ness_quick

    BINGO!

     

    You have two instances of name="Name" - one for the search field and one for the submit button

     

    Change this:

    <input name="Name" type="submit" class="submit" value="Search" >

     

    To This: (name="submit') NOT (name="Name")

    <input name="submit" type="submit" class="submit" value="Search" >

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 10:55 AM   in reply to Ness_quick

    Ness_quick wrote:

     

    OMG wow its working!!! You are fabulous!!! Is it possible to make the results show underneath search box on the donations page? Rather than on a seperate page? I know, im being fussy!

     

    Most likely. I can help you out with that tomorrow. I'll have to get my head around the code to do that.

     

    All it really means is sending the form data back to the same page and then displaying it.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 11:50 PM   in reply to Ness_quick

    Copy the working version of the mysql/php code, taken from the results.php page, and insert it at the top of your search page which I think is called donations.html BUT you will have to change .html to .php so it becomes donations.php- Thats this code below:

     

     

    <?php require_once('Connections/milesdata.php'); ?>

    <?php

    if (!function_exists("GetSQLValueString")) {

    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

    {

      if (PHP_VERSION < 6) {

        $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;

    }

    }

     

     

    $colname_rsDonationResults = "-1";

    if (isset($_POST['Name'])) {

      $colname_rsDonationResults = $_POST['Name'];

    }

    mysql_select_db($database_milesdata, $milesdata);

    $query_rsDonationResults = sprintf("SELECT * FROM donation WHERE name = %s", GetSQLValueString($colname_rsDonationResults, "text"));

    $rsDonationResults = mysql_query($query_rsDonationResults, $milesdata) or die(mysql_error());

    $row_rsDonationResults = mysql_fetch_assoc($rsDonationResults);

    $totalRows_rsDonationResults = mysql_num_rows($rsDonationResults);

     

     

    mysql_free_result($rsDonationResults);

    ?>

     

     

    <---------------------------------------------------------------->

     

    We now need to stop the mysql/php code executing UNTIL the forms submit button has been clicked.

    Insert the below right after the opening <?php tag

     

    if (array_key_exists('submit', $_POST)) {

     

    Like this:

     

    <?php

    if (array_key_exists('submit', $_POST)) {

    if (!function_exists("GetSQLValueString")) {

     

     

    Now we need to insert the closing bracket at the end of the code as shown below:

     

    $totalRows_rsDonationResults = mysql_num_rows($rsDonationResults);

     

    mysql_free_result($rsDonationResults);

    }

    ?>

     

    <--------------------------------------------------------------------- ----->

     

    Now make sure the forms action field is pointing to the donations page:

     

    action="donations.php"

     

     

    Now copy your table code from the results.php page and insert it after the form code on your donations.php page

     

     

    <table width="200" border="0" cellspacing="auto" cellpadding="4">

      <tr>

        <td> </td>

      </tr>

      <tr>

        <td> </td>

      </tr>

      <tr>

        <td><?php echo $row_rsDonationResults['name']; ?></td>

      </tr>

      <tr>

        <td><?php echo $row_rsDonationResults['url']; ?>;</td>

      </tr>

      <tr>

        <td> </td>

      </tr>

    </table>

     

     

    <--------------------------------------------------------------------- ----------------->

     

    We now need to hide the table and only show it IF the search returns a record from the database:

    You do this by wrapping the table in a 'show region' like shown below: (This can be done in DW by selecting the table, going to the Server Behaviours>Show Region and selecting Show if Record Set is Not Empty

     

    <?php if ($totalRows_rsDonationResults > 0) { // Show if recordset not empty ?>

    <table width="200" border="0" cellspacing="auto" cellpadding="4">

      <tr>

        <td> </td>

      </tr>

      <tr>

        <td> </td>

      </tr>

      <tr>

        <td><?php echo $row_rsDonationResults['name']; ?></td>

      </tr>

      <tr>

        <td><?php echo $row_rsDonationResults['url']; ?>;</td>

      </tr>

      <tr>

        <td> </td>

      </tr>

    </table>

    <?php } // Show if recordset not empty ?>

     

     

    <-------------------------------------------------------->

     

    Thats it!

     

    You might want to insert a region on your page to show if the recordset IS empty and no results are returned:

    You can only half do this in DW so I've supplied the amended code below which says if the variable $totalRows_rsDonationResults is set AND the database can find no matches then show this region. The bit DW cant do is check if the variable isset, it can only set for no matches. You need to check whether the variable has been set otherwise the region will appear on the form page when its first opened.

     

    <?php

    if (isset($totalRows_rsDonationResults) && ($totalRows_rsDonationResults ==0)) { // Show if recordset empty ?>

    <p>No record found</p>

    <?php } // Show if recordset empty ?>

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 4, 2013 4:09 AM   in reply to Ness_quick

    Wait a momnet I'm just checking the code out - I can see right away its not correct as you have

     

    if (array_key_exists('submit', $_POST)) {

     

    in the code twice.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 4, 2013 4:16 AM   in reply to Ness_quick

    Just remove the first instance of all the code below (for some reason you have it in your code twice)

     

     

     

    if (array_key_exists('submit', $_POST)) {

    if (!function_exists("GetSQLValueString")) {

    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

    {

      if (PHP_VERSION < 6) {

        $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;

    }

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 4, 2013 4:20 AM   in reply to osgood_

    So you now end up with the donations.php page like below: Obviously it's only got a form on it at the moment so you have to incorporate your existing deisgn or take the code below and insert it into your existing design.

     

    <?php require_once('Connections/milesdata.php'); ?>

     

    <?php

    if (array_key_exists('submit', $_POST)) {

    if (!function_exists("GetSQLValueString")) {

    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

    {

    if (PHP_VERSION < 6) {

    $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;

    }

    }

     

     

    $colname_rsDonationResults = "-1";

    if (isset($_POST['Name'])) {

    $colname_rsDonationResults = $_POST['Name'];

    }

    mysql_select_db($database_milesdata, $milesdata);

    $query_rsDonationResults = sprintf("SELECT * FROM donation WHERE name = %s", GetSQLValueString($colname_rsDonationResults, "text"));

    $rsDonationResults = mysql_query($query_rsDonationResults, $milesdata) or die(mysql_error());

    $row_rsDonationResults = mysql_fetch_assoc($rsDonationResults);

    $totalRows_rsDonationResults = mysql_num_rows($rsDonationResults);

     

    mysql_free_result($rsDonationResults);

     

    }

     

    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>Untitled Document</title>

    </head>

     

    <body>

    <form name="form1" action="donations.php" method="post">

    <table cellpadding="2" cellspacing="0" border="0">

    <tr>

    <td align="right"><label for="Name">Name of Deceased</label></td>

    <td><input name="Name" type="text" value="" size="60"></td>

    </tr>

    <tr>

    <tr>

    <td align="center" colspan="2"> </td>

    </tr>

    <td align="center" colspan="2"><input name="submit" type="submit" class="submit" value="Search" ></td>

    </tr>

    <tr>

    <td align="center" colspan="2"> </td>

    </tr>

    </table>

    </form>

    <?php if ($totalRows_rsDonationResults > 0) { // Show if recordset not empty ?>

    <table width="200" border="0" cellspacing="auto" cellpadding="4">

    <tr>

    <td> </td>

    </tr>

    <tr>

    <td> </td>

    </tr>

    <tr>

    <td><?php echo $row_rsDonationResults['name']; ?></td>

    </tr>

    <tr>

    <td><?php echo $row_rsDonationResults['url']; ?>;</td>

    </tr>

    <tr>

    <td> </td>

    </tr>

    </table>

    <?php } // Show if recordset not empty ?>

     

     

     

    <?php

     

    if (isset($totalRows_rsDonationResults) && ($totalRows_rsDonationResults ==0)) { // Show if recordset empty ?>

     

    <p>No record found</p>

     

    <?php } // Show if recordset empty ?>

    </body>

    </html>

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 4, 2013 4:29 AM   in reply to Ness_quick

    Ness_quick wrote:

     

    Ok i have done that but it still only displays a blank page when i try to view in my browser window. I can only view it in design view and this is what it looks like -

     

    screenshot.jpg

     

    Could this have anything to do with this code as it is now a php file? -

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    No, Nothing.

     

    Take ALL of the code that I provided in my last post and paste it into a new DW file and save it as donations_2.php

     

    Change the forms action field to donations_2.php

     

    Everything should work how you want it to work, including if no records are found you will get a message 'No Record Found'

     

    Now that its working you have to transfer that code into your donations.php page NOT forgetting that the forms action field MUST point at donations.php.

     
    |
    Mark as:
1 2 Previous Next

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points