Re: [PHP-DB] LIMIT
What about 'select count(*) from aTable' - Frank > Is there a way to get the number of rows that would have been returned had > there not been a LIMIT clause in a SELECT statement? > > For example, if > Query #1) SELECT * FROM aTable > would normally return 100 rows. But > Query #2) SELECT * FROM aTable LIMIT 5 > will return 5 rows. Is there a way to find out that 100 rows would have > been returned if there was no LIMIT clause, by using only Query #2 and maybe > a PHP function on the $result? > > Regards, > Dwight > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] LIMIT
Is there a way to get the number of rows that would have been returned had there not been a LIMIT clause in a SELECT statement? For example, if Query #1) SELECT * FROM aTable would normally return 100 rows. But Query #2) SELECT * FROM aTable LIMIT 5 will return 5 rows. Is there a way to find out that 100 rows would have been returned if there was no LIMIT clause, by using only Query #2 and maybe a PHP function on the $result? Regards, Dwight -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Count Many Records
Thanks for your help, Chris. You certainly got me going in the right direction. In case anyone is interested, below is the completed solution, with design elements, turned into a function so I can easily call it several times. function counter_maker ($database,$name,$link) { echo ""; echo "\"content\">$name"; $query = "select status, count(id) AS count from $database where status in ('', 'h', 'p') group by status"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $status_code = $row['status']; if ($status_code == "") { $status_code = "n"; } $count_array[$status_code] = $row['count']; } echo " { echo " style=\"background-color: #F3CF45; color: #00599E; font- weight: bold;\">"; echo $count_array['n']; } else { echo "> 0";} echo ""; echo " { echo " style=\"background-color: #00599E; color: #F3CF45; font- weight: bold;\">"; echo $count_array['h']; } else { echo "> 0";} echo ""; echo ""; if (isset($count_array['p'])) { echo $count_array['p']; } else { echo "0"; } echo ""; } counter_maker ("data1","Form Name","link.php"); -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 On Jun 28, 2006, at 5:39 PM, Chris wrote: Kevin Murphy wrote: Actually the design is in the code below I need to display the counts from all of those queries in a grid. Basically, its just a summary of a bunch of information. Another way to look at it would be a several lines that say something like this: You have $data1_count NEW records in data1, You have $data1p_count PROCESSED records in data1, etc. Instead of $data1_query = "select id from data1 WHERE status = ''"; $data1_results = mysql_query($data1_query); $data1_count = mysql_num_rows($data1_results); $data1p_query = "select id from data1 WHERE status = 'p'"; $data1p_results = mysql_query($data1p_query); $data1p_count = mysql_num_rows($data1p_results); $data1h_query = "select id from data1 WHERE status = 'h'"; $data1h_results = mysql_query($data1h_query); $data1h_count = mysql_num_rows($data1h_results); You could do it all in one query: $query = "select status, count(id) AS count from data1 where status in ('', 'p', 'h') group by status"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { echo "status: " . $row['status'] . ""; echo "count: " . $row['count'] . ""; } -- Postgresql & php tutorials http://www.designmagick.com/
RE: [PHP-DB] mysqldump via php
You could use exec() within PHP! -Original Message- From: Adrian Bruce [mailto:[EMAIL PROTECTED] Sent: Jueves, 29 de Junio de 2006 06:31 a.m. To: Jeffrey Cc: PHP DB Subject: Re: [PHP-DB] mysqldump via php mysqldump is a .exe, and therefore it will not work within mysql_query(); You may be able to use mysqldump from PHP using the system function check out http://uk.php.net/system Ade Jeffrey wrote: > I would like to do a backup of an entire MySQL database via php. My > thought was to use mysqldump, write the data to a file and save the > file. However... > > $query="mysqldump $dbase"; > $result=mysql_query($query) or die(mysql_error()); > > ...immediately results in an "error in your SQL syntax near mysqldump > [database name]". > > The reason I want to do a MySQL back up via php is that I have a web > application in which the user can archive a project, which involves > moving a lot data from one set of tables to another set of tables. The > user can also delete a project, which removes lots of data from the DB > altogether. Although there are lots of "Are you sure you really want > to do this?" messages the user must click upon, I am sure I will > eventually get a user telling me she accidentally archived/deleted > stuff and can I help. > > So, my thought was to do a incorporate a mysqldump in the > archiving/delete page. That way there would be a snapshot of the > pre-action db, making it easy to put things right. > > Can you help with my query - or by suggesting an alternative solution? > > Thanks, > > Jeffrey > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta dirigido; contiene informacion estrictamente confidencial y legalmente protegida, cuya divulgacion es sancionada por la ley. Si el lector de este mensaje no es a quien esta dirigido, ni se trata del empleado o agente responsable de esta informacion, se le notifica por medio del presente, que su reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio este comunicado por error, favor de notificarlo inmediatamente al remitente y destruir el mensaje. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos. This message is for the sole use of the person or entity to whom it is being sent. Therefore, it contains strictly confidential and legally protected material whose disclosure is subject to penalty by law. If the person reading this message is not the one to whom it is being sent and/or is not an employee or the responsible agent for this information, this person is herein notified that any unauthorized dissemination, distribution or copying of the materials included in this facsimile is strictly prohibited. If you received this document by mistake please notify immediately to the subscriber and destroy the message. Any opinions contained in this e-mail are those of the author of the message and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries companies. No part of this message or attachments may be used or reproduced in any manner whatsoever. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysqldump via php
why no use phpmyadmin to admin the db? Bastien From: Jeffrey <[EMAIL PROTECTED]> To: PHP DB Subject: [PHP-DB] mysqldump via php Date: Thu, 29 Jun 2006 12:38:51 +0200 I would like to do a backup of an entire MySQL database via php. My thought was to use mysqldump, write the data to a file and save the file. However... $query="mysqldump $dbase"; $result=mysql_query($query) or die(mysql_error()); ...immediately results in an "error in your SQL syntax near mysqldump [database name]". The reason I want to do a MySQL back up via php is that I have a web application in which the user can archive a project, which involves moving a lot data from one set of tables to another set of tables. The user can also delete a project, which removes lots of data from the DB altogether. Although there are lots of "Are you sure you really want to do this?" messages the user must click upon, I am sure I will eventually get a user telling me she accidentally archived/deleted stuff and can I help. So, my thought was to do a incorporate a mysqldump in the archiving/delete page. That way there would be a snapshot of the pre-action db, making it easy to put things right. Can you help with my query - or by suggesting an alternative solution? Thanks, Jeffrey -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysqldump via php
mysqldump is a .exe, and therefore it will not work within mysql_query(); You may be able to use mysqldump from PHP using the system function check out http://uk.php.net/system Ade Jeffrey wrote: I would like to do a backup of an entire MySQL database via php. My thought was to use mysqldump, write the data to a file and save the file. However... $query="mysqldump $dbase"; $result=mysql_query($query) or die(mysql_error()); ...immediately results in an "error in your SQL syntax near mysqldump [database name]". The reason I want to do a MySQL back up via php is that I have a web application in which the user can archive a project, which involves moving a lot data from one set of tables to another set of tables. The user can also delete a project, which removes lots of data from the DB altogether. Although there are lots of "Are you sure you really want to do this?" messages the user must click upon, I am sure I will eventually get a user telling me she accidentally archived/deleted stuff and can I help. So, my thought was to do a incorporate a mysqldump in the archiving/delete page. That way there would be a snapshot of the pre-action db, making it easy to put things right. Can you help with my query - or by suggesting an alternative solution? Thanks, Jeffrey -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysqldump via php
I would like to do a backup of an entire MySQL database via php. My thought was to use mysqldump, write the data to a file and save the file. However... $query="mysqldump $dbase"; $result=mysql_query($query) or die(mysql_error()); ...immediately results in an "error in your SQL syntax near mysqldump [database name]". The reason I want to do a MySQL back up via php is that I have a web application in which the user can archive a project, which involves moving a lot data from one set of tables to another set of tables. The user can also delete a project, which removes lots of data from the DB altogether. Although there are lots of "Are you sure you really want to do this?" messages the user must click upon, I am sure I will eventually get a user telling me she accidentally archived/deleted stuff and can I help. So, my thought was to do a incorporate a mysqldump in the archiving/delete page. That way there would be a snapshot of the pre-action db, making it easy to put things right. Can you help with my query - or by suggesting an alternative solution? Thanks, Jeffrey -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php