Re: [PHP-DB] MYSQL Table Dump

2003-09-10 Thread Parker Morse
On Wednesday, Sep 10, 2003, at 16:23 US/Eastern, John Ryan wrote:
Is there any way *from the command line* to get a dump of a mysql 
table and
have it saved to a local file, instead of standard output
Have a look at "man mysqldump", particularly the "examples" section.

If you're already dumping the table to standard output, just use the 
same command and redirect the output:

$ mysqldump --tables database.table > some_dump_file

(I didn't test that...)

pjm

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] setcookie

2003-09-05 Thread Parker Morse
On Friday, Sep 5, 2003, at 08:58 US/Eastern, Hutchins, Richard wrote:
"If you wish to assign multiple values to a single cookie, just add [] 
to
the cookie name. "

So if you wanted to set one cookie to hold all of your items, you 
should be
able to setcookie("items[]", item1), setcookie("items[]", item2), etc 
up to
itemN. Then you can access the items as an array in a PHP script. I'm 
pretty
sure that handling your list of items in this manner would allow you to
store a large number of items in the same cookie without setting 
additional
cookies and running into the upper limit of 20.
IIRC there is a browser-set limit to the size of a given cookie, around 
4k. That's pretty big, but there is a limit and it may vary by browser, 
so it's to your advantage to keep it short.

pjm

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] another PHP Sql question...

2003-08-29 Thread Parker Morse
On Friday, Aug 29, 2003, at 02:14 US/Eastern, jsWalter wrote:
But now I've been thrown a wrench in the form of double row display.

my client wants...

a   b
c   d
e   f
   ...
.. I need to create...

   
  row_1/feild_A
  row_1/feild_B
   
   
  row_2/feild_A
  row_2/feild_B
   
   ...
And using the method of WHILE() doesn't cut it.

Can some one enlighten me what syntax can I use to hit 2 rows at a 
time?
Use "for".

You'll need to know the number of rows returned by your query. Using 
MySQL, I find that out using mysql_num_rows($query). You'll need to 
adapt this for your database.

So I would do it this way (probably not the most elegant, but it works):

$your_query = mysql_query("select your data from your table",$db); // 
Run the query
$row_count = mysql_num_rows($your_query); // Count rows returned

$table_row_index = 1; // We'll use this to count your table rows

echo "\r";
for ($i=0; $i<$row_count; $i++) { // Start with $i = 0, do while $i < 
number of rows, and increment $i with each loop
	$your_row = mysql_fetch_array($your_query);
	$field = $your_row['field'];
	echo "Row_$table_row_index/$field\r"; // This is all stuff 
you've done
// so far we've just returned values from your query and written them 
to a table cell
// Here's the trick: if $i is even, we're on the first cell of a row. 
If $i is odd,
// we're on the second cell. We determine this with fmod($i/2); if the 
remainder
// (the result) is 0, $i is even, if it's 1, $i is odd.
	if (fmod($i/2) != 1)) { // if $i is odd, we need to end this row and 
start another.
		echo "\r\r";
		$table_row_index++; // Increment your row numbering.
	}
}
echo "\r";

Sorry about the weird comment wraps. I hope this makes sense.

pjm

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php