Advertisement

04.30.2008 at 04:18PM PDT, ID: 23367263
[x]
Attachment Details

Generate Auto Number - Update Mysql table

Asked by tofitadmin in PHP and Databases, PHP Scripting Language, MySQL

Tags: Dreamweaver

We are developing a webpage using Dreamweaver, php, and mysql as the backend.  One of the requirements is to generate an auto value based on the following syntax:

"sw" date(yymm) auto number (001)

an example would be:
sw0804001   for the first number in april 2008.

I am new at php and dreamweaver so I tried to mimic what worked in access, any better method of accomplishing this would be appreciated.  

What I have done is in mysql created 2 different fields; a sw field (default value is "sw") and an auto number field.  
I created a data entry php page where the person can enter in the needed information.  This form will create a new value in the sql table.  Once the new entry is created another php page is loaded.  My logic on this page is to run a sql query to find the new auto number value and update the entry with the sw value and the current date.  The output that I receive is "Your search warrant number is array0804array.  
All of my sql queries check out so I'm not sure why I'm receiving array as a response.  
" SELECT MAX(Number) FROM Search_Warrant_DB" returns the wanted value and so does

"SELECT MAX('SW') FROM Search_Warrant_DB"

Here is the php code that I created:


Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
//connection is made
// make police1 the current db
$db_selected = mysql_select_db('police1', $link);
if (!$db_selected) {
    die ('HAHAHAHAHA: ' . mysql_error());
}
 
$query = "SELECT MAX(Number) FROM Search_Warrant_DB";
$query2 = "SELECT MAX('SW') FROM Search_Warrant_DB";
 
$query_config = mysql_query($query) or die(mysql_error());
$query_results_Number = mysql_fetch_assoc($query_config);
$numrows = mysql_num_rows($query_config);
$new_Number_value = $query_results_Number++ ;
 
$query_config2 = mysql_query($query2) or die(mysql_error());
$query_results_sw = mysql_fetch_assoc($query_config2);
 
?>
 
<?php
$date = date(ym);
$sw_number = $query_results_sw.$date.$new_Number_value;
 
$udpate_query = mysql_query("UPDATE Search_Warrant_DB SET SEARCH_WARRANT_NUMBER = $sw_number WHERE Number = $query_results_Number"); 
 
echo "Your Search Warrant Number is $sw_number.  Please keep this information.";
 
?>
[+][-]04.30.2008 at 06:03PM PDT, ID: 21475793

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.30.2008 at 09:48PM PDT, ID: 21476571

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.01.2008 at 12:44AM PDT, ID: 21477008

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.01.2008 at 12:49AM PDT, ID: 21477021

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.01.2008 at 02:14PM PDT, ID: 21482808

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.01.2008 at 04:27PM PDT, ID: 21483588

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 12:30AM PDT, ID: 21485051

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 03:59PM PDT, ID: 21490540

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 11:05AM PDT, ID: 21576516

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP and Databases, PHP Scripting Language, MySQL
Tags: Dreamweaver
Sign Up Now!
Solution Provided By: Goodangel
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628