smantscheff 265 Veteran Poster

The $path is missing in the img tag in line 30.

smantscheff 265 Veteran Poster

If you were my fellow programmer you would use code tags for better readability. And you would boil down your code to the problem without having us to spell our way through lots of irrelevant HTML. Be a good fellow and try again.

mschroeder commented: well put +3
EvolutionFallen commented: Was thinking the same thing +2
smantscheff 265 Veteran Poster

Is date a character or a date field? In the latter case you could use a query like

select * from mytable sort by date desc;

In the former case you have to convert the date field with an inline function.

smantscheff 265 Veteran Poster

Of course. With preg_replace you can synthesize any expressions which you could catch with preg_match. E.g. for formatting domain names, you could use:

echo preg_replace( '~([a-z]+://)?(([a-z0-9]+\.)?([a-z0-9]+\.)+([a-z]{2}[a-z]?[a-z]?))~s', '<a href="http://$2">$2</a>', $sample);
//Result: 1word <a href="http://www.domain.com">www.domain.com</a> no period <a href="http://domain.com">domain.com</a> period. <a href="http://domain.com">domain.com</a> what else? <a href="http://www.domain.com">www.domain.com</a>
smantscheff 265 Veteran Poster

You can include aggregate functions for the stores in you Group subquery.

SELECT tblpolicies.PolicyNumber
     , tblpolicies.StoreId
     , tblpolicies.ConsultantFullName
     , tblpolicies.DateReceived
     , tblpolicies.ClientFullName
     , tblpolicies.Comment
     , tblpolicies.Query
     , tblpolicies.PolicyStatus
     , tblpolicies.DateModified
     , Groups.GroupName
     , Groups.StoreName
     , Groups.StoreTarget
     , Groups.StoreManager
     , Groups.PortfolioName
     , Groups.StoreStatus
     , Groups.RepName
     , Groups.ProvinceName
     , Groups.NumberOfPolicies

  FROM tblpolicies
LEFT OUTER
  JOIN ( SELECT StoreId,
                StoreName, StoreManager, GroupName, StoreTarget, PortfolioName
                , StoreStatus, RepName, ProvinceName 
                , (SELECT count(*) FROM tblpolicies where StoreId = tblstores.StoreId) as NumberOfPolicies
           FROM tblstores
         GROUP
             BY StoreId ) AS Groups
    ON tblpolicies.StoreId = Groups.StoreId
WHERE DateReceived BETWEEN '2011-01-01' AND '2011-01-31'
 AND StoreStatus='ACTIVE' ORDER BY GroupName

For further help submit a complete test case with CREATE TABLE statements, INSERT statements for test data and the relevant queries.

smantscheff 265 Veteran Poster

Yes, if preg can identify elements it can also transform them to any standard. My code does not provide for some more exotic url forms like username/password elements, and it does not tackle the query string, if present. But with an additional bracket you can at least catch the standard subdomain, domain and top level domain parts:

preg_match_all( '~([a-z]+://)?(([a-z0-9]+\.)?([a-z0-9]+\.)+([a-z]{2}[a-z]?[a-z]?))~', $sample, $matches, PREG_SET_ORDER)

Array
(
    [0] => Array
        (
            [0] => [url]www.domain.com[/url]
            [1] =>
            [2] => [url]www.domain.com[/url]
            [3] => www.
            [4] => domain.
            [5] => com
        )

    [1] => Array
        (
            [0] => domain.com
            [1] =>
            [2] => domain.com
            [3] =>
            [4] => domain.
            [5] => com
        )

    [2] => Array
        (
            [0] => [url]http://domain.com[/url]
            [1] => http://
            [2] => domain.com
            [3] =>
            [4] => domain.
            [5] => com
        )

    [3] => Array
        (
            [0] => [url]http://www.domain.com[/url]
            [1] => http://
            [2] => [url]www.domain.com[/url]
            [3] => www.
            [4] => domain.
            [5] => com
        )

)
smantscheff 265 Veteran Poster

If the form contains names like "date[]", the receiving $_POST array contains an element named "date" which is an array of key/value pairs which contains all the date values of the form. So you might have

$date1 = $_POST['date'][0];
$date2 = $_POST['date'][1];
...
smantscheff 265 Veteran Poster

Look at the answer to your first post of this item.

smantscheff 265 Veteran Poster

echo yor $query to see if it contains the expected content.
If it does, run in from the mysql command line.

smantscheff 265 Veteran Poster

0) Your select box has several HTML errors: name=linklabel='' should probably read name='linklabel' Put quotes around all attribute values in HTML.
1) Use the onclick event in JavaScript: <select onclick='document.test.submit()'...> or something like that - I don't know the necessary javascript by heart.
2) In edit_page.php you get the selected value of your list box as a post variable: $selected = $_POST['linklabel']; // now $selected contains the id of the selected option

smantscheff 265 Veteran Poster

It is possible, but it's not a mysql or database problem. The database part is peanuts. The time consuming part is analyzing the target site's interfaces. Many of such sites have provisions against automated usage which would have to be overcome. So if your developers are stuck it's probably this point where they are facing the highest obstacles.

smantscheff 265 Veteran Poster

If you submit your data in the form of a test case - that is as MySQL statements which can directly entered into the mysql command line interface reproducing your problem, as in my post http://www.daniweb.com/forums/post1492091.html#post1492091 - I'm willing to give it a try.

smantscheff 265 Veteran Poster

If you are learning PHP, that's fine. In real life I'd rather recommend the linux command line.
The sleep function in this context is rather a joke - I would not trust a PHP program running as a web server module to run longer than a few minutes.
To combine it with a database, learn about php and mysql. Set up a table for URL, search string and result and insert your findings with something like insert into mytable (url,searchstring,result) values ('$url','$searchstring','result');

smantscheff 265 Veteran Poster

It depends on how regular your input is. In your example, domain names consist of lower-char strings with dots in between with an optional protocol name:

$sample = " 1word www.domain.com no period domain.com period. http://domain.com what else? http://www.domain.com ";
if (preg_match_all( '~([a-z]+://)?(([a-z0-9]+\.)+([a-z]{2}[a-z]?[a-z]?))~', $sample, $matches, PREG_SET_ORDER))
  print_r( $matches );
Array
(
    [0] => Array
        (
            [0] => [url]www.domain.com[/url]
            [1] =>
            [2] => [url]www.domain.com[/url]
            [3] => domain.
            [4] => com
        )

    [1] => Array
        (
            [0] => domain.com
            [1] =>
            [2] => domain.com
            [3] => domain.
            [4] => com
        )

    [2] => Array
        (
            [0] => [url]http://domain.com[/url]
            [1] => http://
            [2] => domain.com
            [3] => domain.
            [4] => com
        )

    [3] => Array
        (
            [0] => [url]http://www.domain.com[/url]
            [1] => http://
            [2] => [url]www.domain.com[/url]
            [3] => domain.
            [4] => com
        )

)

// hey ardav, what's a mook?

smantscheff 265 Veteran Poster

Use an INSERT query instead of an UPDATE query.

smantscheff 265 Veteran Poster

Use preg_match_all()

if (preg_match_all( '/A ([0-9]+)/', $paragraph, $matches, PREG_SET_ORDER )){
  foreach( $matches as $m )
    ... // process $m[1]
  }
}
smantscheff 265 Veteran Poster

One assignment for each field:

UPDATE table1 SET at_bats = at_bats + $at_bats, hits = hits + $hits WHERE user_id = $id;
smantscheff 265 Veteran Poster

It's not us who are confused ;-)

You can put your php script to sleep for one day (see the sleep function) and let it run unterminated. Or you can use PHP from the command line as a script language and call it from a cronjob.
I'd recommend you use wget and grep from the command line to retrieve the site's source code, grep for the string and write the result to a text log file. Then you can load the log file later into a database for statistical evaluation and further processing.

smantscheff 265 Veteran Poster

There are numerous ways. For example, you can use the mysql_field_name() function. Or you can alter your script. In the loop, do

foreach($show as $key => $value)
  echo "$key: $value\t";
echo "\n";
smantscheff 265 Veteran Poster

Use preg_replace() to match and format the values supplied by users.
Strip the phone numbers of any non-numeric characters first. Apply

$number = preg_replace( '/[^0-9]/', '', $number );
$number = preg_replace( '/([0-9]{3})([0-9]{3})([0-9]{4})/', '($1) $2-$3', $number );

Likewise for the domain.

jrotunda85 commented: Great informative post! +1
smantscheff 265 Veteran Poster

Before you move on to the next problem, mark this thread as solved.

smantscheff 265 Veteran Poster

Replace name="date" by name="date[]" .
Then in send.php walk through the array $_POST['date'] and generate an INSERT query for each element.

smantscheff 265 Veteran Poster

Assuming that you use an Apache server, the best you can do for increased capacity is to increase the RAM.

smantscheff 265 Veteran Poster

What does "is not working" mean?

smantscheff 265 Veteran Poster

Study regular expressions. You can achieve your goal with the preg_replace() function which can find well-formed links and replace them with the appropriate HTML code.

smantscheff 265 Veteran Poster

Without having understood the details of your problem, I see that it cannot work: your LEFT JOIN clause does not contain any comparison:

FROM prod_contacts.cms_contacts
LEFT JOIN prod_contacts.cms_table_packholder ON cms_contacts.packholder

should probably read

FROM prod_contacts
LEFT JOIN cms_contacts ON cms_contacts.packholder = prod_contacts.packholder
smantscheff 265 Veteran Poster

First I recommend that you test your variants for speed and efficiency. Then have a look at the EXPLAIN explanations for your update queries which might tell you about some potential inefficencies. Third, I assume you have an unique user/products index. Therefore you could use an INSERT IGNORE query to add a user/product pair and then update this row. With a unique primary index overhead should be minimal. Then you could delete empty rows in an cronjob on an hourly or daily base.
You can of course update more than one row at once, but with unique user/product tupels you will have one update query for each product per user.

smantscheff 265 Veteran Poster

I'd rather let you tell us what does not work and how it is supposed to work than digging through all your code.

smantscheff 265 Veteran Poster

When you remove the RewriteRule from .htaccess, you are seeing the .jpg file. If the rule is active, you see the output of the PHP file which is something completely different.
You do not need this setup. Instead replace all references to the .jpg file by references to the .php file and let the script not only update the graphics but also display it. Use

header('Content-type: image/png');
  readfile('Nintendo3DS4free.jpg');
smantscheff 265 Veteran Poster

I assume that with "row names" you mean the column names.
You can get them with the functions mysql_field_name and mysql_field_count:

while ($object = mysql_fetch_object($result) {
  for ($i = 0; $i < mysql_field_count($result); $i++) {
    $field_name = mysql_field_name($result, $i);
    $field = $object->$field_name;
    ...
  }
}
smantscheff 265 Veteran Poster

Where is the problem?
You dynamic PHP page displays the database content.
When the user submits new stats, store it to the database first place in your script. Then load the data from the database and display the current database content - including the newly submitted data - in the same script.

smantscheff 265 Veteran Poster

I suggest you do some basic research of relational database design and learn the notions of 1:n and m:n relations.
Download an open source shop system (like OSCommerce or the like) and study their database setup.
A lookup table is a table with key-value pairs. In your item table you have a field which contains the key, in the lookup table you have some text string associated with it. You could also use the mysql enum type for that purpose, but that's not so easy to maintain as a separate table.
With proper database design you find the number of items per invoice with a query which selects all item positions for a given invoice number from the invoice details table.
For further help, show us the CREATE TABLE statements or some ERM or other design code which you have done already.

smantscheff 265 Veteran Poster

1. Add a field "size" to the product table and add a lookup table "sizes" for this field.
2. The standard layout is one table for the invoice and one table for the invoice positions (items) which are linked to the invoice table.

smantscheff 265 Veteran Poster
select a.form_num, a.name, b.score, b.ddate
from form1 a, form2 b
where a.from_num=b.form_num
order by b.ddate
limit 1;

or

select a.form_num, a.name, b.score, b.ddate
from form1 a, form2 b
where a.form_num=b.form_num
and b.ddate = (select min(ddate) from form2 where form_num=a.form_num) c;
smantscheff 265 Veteran Poster

I do not understand. What does not work? My query returns the sum of all pop values for each single blkidfp00 value - which is 2333 in your example.
Which result do you expect from this test case? Replace 'Adams' by your '$county' $_GET variable, and there you are. Or aren't you?

drop table if exists wi_allbcdata;
create table wi_allbcdata
(id integer,
blkidfp00 char(30),
countyname char(30),
servicetype integer,
pop integer
);
insert into wi_allbcdata values 
('1','55001950100100','Adams','10','1980'),
('2','55001950100100','Adams','20','1980'),
('3','55001950100100','Adams','30','1980'),
('4','55001950100101','Adams','10','353'),
('5','55001950100101','Adams','20','353'),
('6','55001950100101','Adams','30','353');

SELECT blkidfp00, pop FROM wi_allbcdata b WHERE b.countyname='Adams' GROUP BY blkidfp00;
+----------------+------+
| blkidfp00      | pop  |
+----------------+------+
| 55001950100100 | 1980 |
| 55001950100101 |  353 |
+----------------+------+
select sum(c.pop) from (SELECT pop FROM wi_allbcdata b WHERE b.countyname='Adams' GROUP BY blkidfp00) c;
+------------+
| sum(c.pop) |
+------------+
| 2333       |
+------------+
smantscheff 265 Veteran Poster
select sum(c.pop) from (SELECT pop FROM wi_allbcdata b WHERE b.countyname='Adams' GROUP BY blkidfp00) c;
smantscheff 265 Veteran Poster

At which point are you stuck?

smantscheff 265 Veteran Poster

Also have a look at the preg functions of PHP which might be much easier to handle than the external grep.

smantscheff 265 Veteran Poster

You do not get a PHP error, but a notice.
To avoid it, change

$act = $_GET['act']; //retrives the page action

to

if (isset($_GET['act'])) $act = $_GET['act']; //retrieves the page action

I am not sure if the PHP error notice appears before the header is sent to the browser. If this is the case, the header cannot be processed any more. So first try to get rid of the PHP notice. (You can also use the PHP error_reporting() statement. Look it up in the manual.)

smantscheff 265 Veteran Poster

If you don't provide a complete test case including test data (in the form of INSERT statements), I'm not able to further help you.

smantscheff 265 Veteran Poster

I strongly support Sorcher's advice. Don't use a framework until you have hand-coded it all at least once yourself. Then move on to facilitate the job with a framework. Otherwise you will never know what you are actually doing.

smantscheff 265 Veteran Poster

There is a lot wrong with this code.
Another question is why it is not working as expected. I assume because your pictures are in the pic subdirectory and you are applying the filesize function to a non-existent file in the root directory.
Try

print(filesize("/pic/" . $dirArray[$index]));
smantscheff 265 Veteran Poster

Send your users to a script which evaluates the user id and sends a Location: header back to the desired page.
But are 01.php and 02.php really substantially different? Would you not be better off with only one script and variable content depending on the user?

smantscheff 265 Veteran Poster

You could store the calculation formulas in a database table (as you do) and then generate your query from PHP (or any other programming language with a MySQL interface) so that the query contains those formulas as literal values - exactly as in my example query above. The only database language I know of which is capable of macro processing is CLIPPER but I doubt that there is anyone around here old enough to have heard of it.

smantscheff 265 Veteran Poster

For a new question, open a new thread and mark this as solved.
How do "words continue to get caught up over and over again during the mysql insert query" - what does that mean? How do you catch words? If you want to protect against double entries, add a unique index to your word field.

smantscheff 265 Veteran Poster

Use the id attribute in Javascript and the name attribute in the PHP form processing.
For processing it is irrelevant if you have a submit button or a javascript function calling form.submit().

smantscheff 265 Veteran Poster

This has nothing to do with Joomla (or with PHP). Just set up a page with four links to four different pages.
You can host as much sites and databases on one server as you want.

smantscheff 265 Veteran Poster

Replace "Replay" by "Reply". Replace "\n" by "\r\n". Add a "\r\n" to the first header to separate it from the second.

$headers = "From: mywebsite.ca\r\nReply-To: Do Not Reply\r\nX-Mailer: PHP/" . phpversion();
$headers .= "\r\nContent-type: text/html; charset=iso-8859-1";

Then try again.

smantscheff 265 Veteran Poster

I suggest you use something like pritaeas' expression in a BEFORE INSERT trigger and store it in a invoice_number field. Instead of using the count(*) function I'd rather check for the highest number in this month and store it in a separate field. In your trigger BEFORE INSERT:

SET new.invoice_number = 0 + (SELECT max(invoice_number FROM bills WHERE YEAR(timestamp) = YEAR(NOW()) AND MONTH(timestamp) = MONTH(NOW()))
smantscheff 265 Veteran Poster

Please mark this thread as solved.