Tow quick questions ...
1/ Is it possible to select coun(*) from xxx where .... directly into a
$variable? Rather than select * and mysql_numrows ...
The result of SELECT COUNT(*) ... is a set of 1 or more rows which are passed to PHP in exactly the same way that the result of SELECT (*) ... is passed to PHP. You handle the result sets in exactly the same way.
2/ I am selecting from a database of UK postcodes. For Example, W13AB ..
this is in London W1. Example 2 ... W113AB .. this is in London W11.
If I "select * from table where postcode like '$postcode%' " and $postcode
is"W1", it will pick up records for both W1 and W11.
Can I "select * from table where postcode='$postcode' " But without the last
three digits (i.e. W13AB -3 digits = W1)? This is doing a regular expression
within the SQL query.
You've answered your own question. If the pattern will match both W1 and W11, then it will match W13AB. The MySQL syntax is 'W1%'. To match W1 plus exactly 3 characters, use 'W1___' (3 underscores). That will match W13AB, but not W1 or W11.
Bob Hall
Know thyself? Absurd direction!
Bubbles bear no introspection. -Khushhal Khan Khatak