[PHP] Emptying a Single Array Value
Howdy, If someone out there could tell me how to get rid of a single key/index pair within an array, it would be great. I've tried both unset() and empty(), but both destroy the entire array. Please CC me directly, as I'm on the digest. Thanks in advance! Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Emptying a Single Array Value
I have an online example of the progam at http://www.recordconsulting.com/temp/shop.php. Each of the delete links use the corresponding index values for the array, and use the unset() function to remove them. While I'm here... how do I find the amount of information in an array? JavaScript parlance would be $array.length. Code is below: snip ?php if($action == delete) { unset($item[$id]); } $color = #336699; var_dump($item); for($counter = 0; $counter 7; $counter++) { $offset = $counter + 1; echo trtd width=\80%\ bgcolor=\$color\\n; echo Item . $offset . : . $item[$counter]; echo /td\n; echo td width=\20%\ bgcolor=\$color\\n; echo a href=\makelist.php?action=deleteid=$counter\ class=\link\Delete/a\n; echo /td/tr\n\n; if($color == #336699) { $color = #6699CC; } else { $color = #336699; } } ? /snip Thanks! Philip Olson [EMAIL PROTECTED] 06/12/02 03:02PM unset() works for this, how are you using it exactly? Please post a short test script that misbehaves for you. $arr = array('foo','bar'); unset($arr[0]); print_r($arr); // only $arr[1] = 'bar' exists now See also: http://www.php.net/unset http://www.php.net/array_splice Regards, Philip Olson On Wed, 12 Jun 2002, Martin Clifford wrote: Howdy, If someone out there could tell me how to get rid of a single key/index pair within an array, it would be great. I've tried both unset() and empty(), but both destroy the entire array. Please CC me directly, as I'm on the digest. Thanks in advance! Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] redirection
You can pretty much use ANY JavaScript event handler to accomplish the redirection. I'm new to PHP, so the header is the only place I know of to redirect. onclick onmouseup onmousedown onmouseover onmousemove onkeydown onkeypress onkeyup onchange etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] days between two timestamps
laughs Well, I had the right idea... John is just more advance than me. :o) 1LT John W. Holmes [EMAIL PROTECTED] 06/05/02 11:09AM Since those look like MySQL timestamps, I would suggest you do it in your query. SELECT TO_DAYS(column1) - TO_DAYS(column2) AS Difference FROM table Adapt to your needs. Explain what your overall mission is and there is probably a query that'll return just that. If you want to use PHP, format those timestamps into something strtotime() will convert to a unix timestamp, find the difference in seconds, and convert the number of seconds into days. ---John Holmes... - Original Message - From: Tyler Longren [EMAIL PROTECTED] To: php-general [EMAIL PROTECTED] Sent: Wednesday, June 05, 2002 11:01 AM Subject: [PHP] days between two timestamps Hi, I have two different timestamps: 20020603164114 and 20020605054710 Is there a simple way to get the number of days between the two dates? thanks, tyler -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions question (-enable-trans-sid)
I'm sure this is not a definitive answer, but I would assume that since you would be passing the information through both the URI and Cookies, it will work regardless of cookies enabled or disabled. On the other hand, if you are passing the session id through the URI in the first place, you don't have to worry about cookies being on at all. Just some idle speculation, I've never tried to use both at the same time. Martin Jeff Field [EMAIL PROTECTED] 06/05/02 12:56PM Hi, I'm confused about one thing regarding sessions and haven't been able to find the definitive answer anywhere. Hopefully, I can here. There are two ways to enable sessions: 1) Session ID is passed through cookies 2) Session ID is passed through the URL, either done manually or by automatic URL rewriting All the books, tutorials, etc. basically say that cookies are the way to go but when users don't have cookies enabled, you have to use the URL method. Since I have an e-commerce site that is available to the world, I'm assuming *some* are not going to have cookies enabled. Duh! So, from what I've read, you can implement the URL method of sessions by either manually attaching the session ID to the URLs, or, by compiling PHP with enable-trans-sid, which will add the session ID to the URL's automatically. The answer that I haven't been able to find is this: Is this a one or the other proposition? IOW, if I implement sessions with cookies, then I can't use the URL method? Or, if I implement the URL method (with enable-trans-sid), I can't use the cookie method? Or, do they work in combination. IOW, does PHP automatically know that if a user has cookies enabled, PHP will use the cookie method and, when cookies are *not* enabled, PHP automatically implements the URL method? Thanks for the help! Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php and javascript question
As far as I'm aware you can't create a javascript variable and use it within PHP on the same page. You can add that variable's value to a hidden form element to be passed to the next page, but I don't think so with the same page. martin kemu [EMAIL PROTECTED] 06/05/02 02:30PM I have a page first he generates a var in javascript my next question is is it possible to use that var in php on the same page first he does the javascript then the php ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Outputting Array Values
Hello everyone! I'm fairly new to PHP, but I do know JavaScript, which is both a blessing and a hinderance, as there are many syntax similarities, but a subtle amount of difference which means I usually screw something trivial up in my PHP code. Can someone explain to me why the following isn't printing out each Array value? ? $List = Array(Tomatoes, Onions, Carrots, Lettuce); echo table border=1 bordercolor=white cellpadding=0 cellspacing=0; for($n=0; $n count($List); $n++) { echo trtdItem . ($n + 1) . is $List[$n]./td/tr; } ? It successfully prints out the following: Item Number 1 is . Item Number 2 is . Item Number 3 is . Item Number 4 is . I just don't understand why it doesn't print out each value in the array... any help would be VERY appreciated! Also, please CC me on any replies, as I'm subscribed to the digest! Thanks! Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DB Question
Hello all, I've been waiting in the shadows, reading, trying to get a handle on what type of questions go here. I'm hoping this one does, and that some of you guru's might be able to offer some insight. I've just started out with PHP, and want to get to know relational databases. I've seen numerous tutorials that show you how to create the DB with PHP... something along the lines of... $link = mysql_connect('localhost', 'mylogin', 'mypass'); And the like... but here's my question... You connect to the database program (MySQL in MyCASE, hehe) and create the database and tables you want to use, but... do you only have to run this PHP script once to create the database/tables... or do you have to run the lines that create the database and tables each time you want to write information to them or extract information from them? I've not come across any tutorials that expand on that. I'm guessing you run the script once to create the DB and Tables, then it's there. After that, you need only write to/extract from them. If anyone can please offer information on this I'd greatly appreciate it. Also, direct replies to this mail address are encouraged, as I'm in digest mode and want to get your answers as soon as I can :o) Take care all, and thanks in advance! Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php