Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi guys

 

I have a new challenge.

 

Short intro. I am from Holland. In Holland we have a car license plating system that links a license plate to a car. And looking up a license plate, can show the known data of that car (technical info, not personal)

 

There are a bunch of sites where you can get the data for one car at the same time. I am thinking to build a site where I can draw information for a whole range of license plate numbers at once.

 

I don't know if I should create an array or another means to create the range.

 

Example

 

at one time, the numbering on our license plates was: 2 digits - 2 letters - 2 digits (99-xx-99)

 

I wrote a script already that can set the begin and end value... but I have no clue how to create an array with all possible combinations between begin and end value.

 

the code I am using to create the begin and end value for the range is as follows:

 

as part of index.php:

 

  $letter = array (1 => 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'N', 'P', 'R', 'S', 'T', 'X', 'Y', 'Z');
  $number = range (0, 9);
 

  echo '<form action="select.php" method="post">';
   
  // create select for range 1
  echo '<p>Set range 1';
  echo '<select name="letter11">';
  foreach ($letter as $key => $value) {
   echo "<option value=\"$value\"> $value</option>\n";
  }
  echo '</select>'; 

  echo '<select name="letter12">';
  foreach ($letter as $key => $value) {
   echo "<option value=\"$value\"> $value</option>\n";
  }
  echo '</select>';
 
  echo '<select name="digit11">';
  for ($number = 0; $number <= 9; $number++) { 
   echo "<option value=\"$number\"> $number</option>\n";
  }
  echo '</select>';
 
  echo '<select name="digit12">';
  for ($number = 0; $number <= 9; $number++) { 
  echo "<option value=\"$number\"> $number</option>\n";
  }
  echo '</select>';
  
  echo '<select name="letter13">';
  foreach ($letter as $key => $value) {
   echo "<option value=\"$value\"> $value</option>\n";
  }
  echo '</select>'; 

  echo '<select name="letter14">';
  foreach ($letter as $key => $value) {
   echo "<option value=\"$value\"> $value</option>\n";
  }
  echo '</select></p>';
 // create select for range 2
  echo '<p>Set range 2';
    echo '<select name="letter21">';
  foreach ($letter as $key => $value) {
   echo "<option value=\"$value\"> $value</option>\n";
  }
  echo '</select>'; 

  echo '<select name="letter22">';
  foreach ($letter as $key => $value) {
   echo "<option value=\"$value\"> $value</option>\n";
  }
  echo '</select>';
 
  echo '<select name="digit21">';
  for ($number = 0; $number <= 9; $number++) { 
   echo "<option value=\"$number\"> $number</option>\n";
  }
  echo '</select>';
 
  echo '<select name="digit22">';
  for ($number = 0; $number <= 9; $number++) { 
  echo "<option value=\"$number\"> $number</option>\n";
  }
  echo '</select>';
  
  echo '<select name="letter23">';
  foreach ($letter as $key => $value) {
   echo "<option value=\"$value\"> $value</option>\n";
  }
  echo '</select>'; 

  echo '<select name="letter24">';
  foreach ($letter as $key => $value) {
   echo "<option value=\"$value\"> $value</option>\n";
  }
  echo '</select></p>';
  echo '<input type="hidden" name="sc" value="sc4">';
  echo '<input name="submit" type="submit" value="Create List"';
 }

 

 

After pressing the submit, it will send all data to select.php

 

for now I simply plot the beginning and end in it as follows:

$letterrange11 = ($_POST ['letter11']).($_POST ['letter12']);
  $digitrange11 = ($_POST ['digit11']).($_POST ['digit12']);
  $letterrange12 = ($_POST ['letter13']).($_POST ['letter14']);
 
  $letterrange21 = ($_POST ['letter21']).($_POST ['letter22']);
  $digitrange21 = ($_POST ['digit21']).($_POST ['digit22']);
  $letterrange22 = ($_POST ['letter23']).($_POST ['letter24']);
  
  echo '<p>'.$letterrange11.'-'.$digitrange11.'-'.$letterrange12.' until '.$letterrange21.'-'.$digitrange21.'-'.$letterrange22.'</p>';

 

 

So the big question is now... The code I used til now, is it a good basis to create the array that I need? If so, How do I build an array that will look like as follows...

 

What I need is if I select DD-00-DD to DZ-99-ZZ, to plot all possible values in an array. This based on the $letter array.

e.g.

DD-00-DD

DD-01-DD

DD-02-DD

etc, etc, etc,

DZ-99-ZV

DZ-99-ZX

DZ-99-ZZ

 

This data I can then send per license plate to the to-be-built script.

 

 

I realize it is a huge list, but I am curious how this could work out.

 

Any help is welcome.

 

THANKS GUYS!

Regards

Mike

Link to comment
Share on other sites

I wouldn't recommend doing things the way you're doing it now, but before I can help you, I need to better understand how the system works. For example, if I specify the following range:

 

AA-00-AA to AA-00-AG

 

Then I would want to find all of the following license plates, right?

 

AA-00-AA

AA-00-AB

AA-00-AC

AA-00-AD

AA-00-AE

AA-00-AF

AA-00-AG

 

Likewise, if I searched for AA-00-AA to AA-02-BD, then I'd need all 676 (26 * 26) licence plates that start with AA-00, all 676 license plates that start with AA-01 and all the AA-02 license plates up to AA-02-BD, right?

 

Please let me know if me logic is correct or not. Thank you.

Link to comment
Share on other sites

Hey HartleySan

 

Thank you so much for looking with me

 

Yes, more or less

 

Except we're limited to these letters:

  $letter = array (1 => 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'N', 'P', 'R', 'S', 'T', 'X', 'Y', 'Z');

 

All others are not necessary. All digits are possible.

 

This is just one of the many series of possible combinations

Example... currently we are at 1 digit - three letters - 2 digits (9-xxx-99). So I was trying to create a script that I can easily apply to all kinds of possible (and future) ranges

 

Thanks

Mike

Link to comment
Share on other sites

Hmmm... first off, I wouldn't bother with searching for license plates of the format AA-00-AA until such a system actually exists. In other words, I would stick with the 0-AAA-00 format until a new format starts being used.

 

Secondly, is there any particular reason why you are starting the index of the letters array at 1 and not 0?

 

Thirdly, I can see why all the other sites only let you search one license plate at a time. With the (seemingly) random letters being used and huge number of possibilities with even a "small" range, your queries strings could be quite long and queries could be quite time-consuming.

 

Fourthly, do you have legit access to the DB that you're planning on querying?

 

Assuming all of the things I just mentioned are okay, I have a few additional thoughts:

 

1) For the license plate input range, I would simply provide two text inputs, and then have users input a range such as the following:

2-DLN-98     2-DLP-53

 

You can then use a regex on the user input to both validate and process the input.

 

2) I can't think of an easy way to perform the queries. You're either going to have to perform a bunch of queries (for which, I definitely recommend prepared statements), or you're going to have to build up a huge query string in PHP (which would perhaps exceed the MySQL limit, if there is one). Either way, your queries seem like they will be very inefficient, but I can't think of a better way to do this. Perhaps someone else on the forums has a better idea.

 

3) Related to #2, I would greatly limit people's queries to a range of 100 license plates or less. I think that's more than reasonable, don't you?

 

Anyway, please give me your thoughts, and we can go from there.

  • Upvote 1
Link to comment
Share on other sites

Hello HartleySan

 

I will add some answers and comments to yours

 

1. These are the (existing) systems I want to make inquiries in:

Sidecode 4 (XX-99-XX)
Sidecode 5 (XX-XX-99)
Sidecode 6 (99-XX-XX)
Sidecode 7 (99-XXX-9)
Sidecode 8 (9-XXX-99)

Hence the flexibility I am searching for in creating the begin and end point.

 

2. No, no reason, it is an adjusted array of one of Larry's scripts

 

3. That's why I want to be the first

 

4. Yes I have legit access, but these things are all besides the point. I have java scripts available, but first things first.

 

as answers to your ) - numbered remarks;

 

1) I want to exclude non-existing combinations, by providing a fixed selection (hence the letter array)

 

2) and 3) Good idea to limit it.

 

So remains... how can I build this array?

 

 

Any ideas how to start this?

 

Thanks again

Link to comment
Share on other sites

Okay. Here is my response:

 

Are all the differently formatted license plate numbers mixed together in the same table? If so, are there any other columns in the table to check for only a certain format (e.g., XX-99-XX)? In other words, what's the structure of the DBs/tables that you're dealing with?

 

As I said before, I would allow the user to input a string into a text field (or two text fields for a range), upon which you should use regexes and whatnot to both parse and validate the input. Once you have confirmed that the input is legit, then I would make the DB request(s).

Link to comment
Share on other sites

 Share

×
×
  • Create New...