Jump to content

Find Highest Number


TRI0N

Recommended Posts

Okay here is the gig. I have a Event Number that looks like this. CU-12345678901-0001

 

Breakdown CU (Company ID) - 1234567890 (Client ID) - 0001 (Event ID)

 

Senerio: CU-1234567890-0012 is the hight event by this client. So then next added event by this client will be CU-1234567890-0013.

 

At this time I have the Event ID as whole (CU-1234567890-0001 and I search the Event Table via Client ID which is CU-1234567890 and want it to look for the highes Event ID.

 

In the Even Table I have cells that store just the trailing Event ID (0001) and the Client ID (CU-1234567890).

 

Now I search for all records for that client. Now what I want to determin is the highest number trailing Event ID number. The rest is obvious that I want to increase this number by 1 for a new event which I have that part.

 

Any help on how to determine the highest Trailing Event ID number would be Excellent.

 

Thanks ahead of time.

 

 

Link to comment
https://forums.phpfreaks.com/topic/97900-find-highest-number/
Share on other sites

Okay lets see I figured it would be max but I'm not sure where to put this in order to determin the MAX().

 

Let me attempt a connect code:

// Database Connection
mysql_connect("$dbhost","$dbuser","$dbpasswd") ;

// Database Selection
mysql_select_db("$dbname") ;

// Check Client in Events Database
$result50 = mysql_query("select distinct * from events WHERE client_id = '$client_id'") ;
while($row = mysql_fetch_row($result50)) {
$event_tail = $row[4] ;
}
$event_tail_max = MAX($event_tail) ;
$event_tail = $event_tail_max + 1 ;

 

Hot, Warm, Cold?

 

Thanks for the help.

Link to comment
https://forums.phpfreaks.com/topic/97900-find-highest-number/#findComment-500894
Share on other sites

No you are correct.  Can you give me an example of using that in the Query..  row 4 only cotains the trailing number for the complete event ID.  But the script I wrote above does work however it does not return the value in whole.  0001 is returned as 1.  Not that this is a problem since I can format this number no doubt..  However it would be nice to see a query example.

Link to comment
https://forums.phpfreaks.com/topic/97900-find-highest-number/#findComment-500916
Share on other sites

Okay this sucks..  I'm going nuts trying to use Max() in a query.

 

 

$result50 = mysql_query("SELECT MAX(event_tail) FROM events WHERE client_id = '$client_id'") ;

 

This isn't doing the trick and I've tried:

 

$result50 = mysql_query("SELECT * FROM events WHERE client_id = '$client_id' AND MAX(event_tail)") ;

Link to comment
https://forums.phpfreaks.com/topic/97900-find-highest-number/#findComment-500976
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.