Re: [PHP-DB] Page refresh question

2005-06-09 Thread Bobo Wieland
...or if everything else fail, do it the ugly-hack style and us a 
frameset with an 1 px wide frame where you update the db... just target 
the update to the invisible frame and only that gets updated...


_bobo www.bitbob.biz

Chris Payne wrote:


Hi there everyone,



I'm using PHP and MySQL in a shopping cart system but the client wants it so
that when you add an item to the cart the page doesn't refresh and we all
know with PHP the page MUST refresh in order to execute the MySQL query.  Is
it possible, maybe with javascript? That I can talk to MySQL without having
to have the page itself refresh when they add the items to the cart?  This
is really a pain as the system was basically finished and now I'm told they
don't want the page to refresh and they see other sites that don't refresh -
sigh.  If it can be done with Javascript, do you have a sample of how I can
use PHP, Javascript and MySQL together to achieve this please?



Any help would not only be appreciated, but would save my life.



Thank you.



Chris


 



--

_bobo wieland _ [EMAIL PROTECTED] _
winamp  aphex twin cd 2 | -ziggomatic v17

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



Re: [PHP-DB] SQL prob

2005-01-31 Thread Bobo Wieland
Thanks, but DISTINCT doesn't work... But I managed to get it to work 
anyway by including

namn_1 NOT LIKE 'H%'
in the second WHERE-clause...
Micah Stevens wrote:
use DISTINCT?
On Sunday 30 January 2005 12:51 pm, Bobo Wieland wrote:
 

Anyone that can help me with this one? I want this SQL-statement to
retrive only distinct values from the original table column named (not
the AS stuff)
(
SELECT * , namn_2 AS sec_namn, namn_1 AS one
FROM sortiment
WHERE namn_1 LIKE 'H%'
)
UNION (
SELECT * , UPPER( namn_2 ) AS sec_namn, namn_2 AS one
FROM sortiment
WHERE namn_2 LIKE 'H%'
AND SUBSTRING( namn_2, 1, 1 ) LIKE BINARY 'H'
)
ORDER BY one
LIMIT 0 , 10
this will return, for example, the following row twice where (in the
original table)
namn_1 = Humulus lupulus
namn_2 =  Humle
the two rows are identical except for the sec_namn and one created
by the query. They are set to:
sec_namn  one
HUMLEHumle
HumleHumulus lupulus

_bobo wieland _ [EMAIL PROTECTED] _
winamp  Not playing anything right now...
   

 

--
_bobo wieland _ [EMAIL PROTECTED] _
winamp  Not playing anything right now...
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] SQL prob

2005-01-30 Thread Bobo Wieland
Anyone that can help me with this one? I want this SQL-statement to 
retrive only distinct values from the original table column named (not 
the AS stuff)

(
SELECT * , namn_2 AS sec_namn, namn_1 AS one
FROM sortiment
WHERE namn_1 LIKE 'H%'
)
UNION (
SELECT * , UPPER( namn_2 ) AS sec_namn, namn_2 AS one
FROM sortiment
WHERE namn_2 LIKE 'H%'
AND SUBSTRING( namn_2, 1, 1 ) LIKE BINARY 'H'
)
ORDER BY one
LIMIT 0 , 10
this will return, for example, the following row twice where (in the 
original table)
namn_1 = Humulus lupulus
namn_2 =  Humle

the two rows are identical except for the sec_namn and one created 
by the query. They are set to:
sec_namn  one
HUMLEHumle
HumleHumulus lupulus


_bobo wieland _ [EMAIL PROTECTED] _
winamp  Not playing anything right now...
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] amp; and sessions

2004-11-29 Thread Bobo Wieland
how can i force the SID variable in urls not to be SID=, but amp;SID ?
_ bobo wieland  [EMAIL PROTECTED] __
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] amp; and sessions

2004-11-29 Thread Bobo Wieland
well... in xhtml you HAVE to write amp; in urls... if I can't do that whats 
the point in trying to use xhtml, when it won't work with php anyway?

_bobo wieland _ [EMAIL PROTECTED] _
winamp  kruder dorfmeister | lamb- trans fatty acid

- Original Message - 
From: Bastien Koert [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, November 29, 2004 9:51 PM
Subject: RE: [PHP-DB] amp; and sessions


you can't, not allowed
read here http://www.faqs.org/rfcs/rfc1738.html
bastien
From: Bobo Wieland [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP-DB] amp; and sessions
Date: Mon, 29 Nov 2004 20:44:43 +0100
how can i force the SID variable in urls not to be SID=, but amp;SID ?
_ bobo wieland  [EMAIL PROTECTED] __
--
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] amp; and sessions

2004-11-29 Thread Bobo Wieland
Trying to answer a couple of mails here...
How
exactly are you tacking the SID onto the end of these URLs?  If it's
done by php automatically then you shouldn't be having problems at all
at the xhtml level, if you're doing it manually - then manually add
amp;SID=$wherever_sid_is_stored onto the urls.
php adds the SID automatically so I have no control over that part of the 
url... for all other params i use amp; manually.

Otherwise, take a look at this php.ini option -
; The separator used in PHP generated URLs to separate arguments.
; Default is .
;arg_separator.output = amp;
I would do that if I had control over the server... but I don't get to say 
what the ISP can do or not... That might change in the future but right now 
I'm stuck with them...

There is no REAL problem, since all pages displays nicly in all browsers 
I've checked... the problem is that I in _one_ place put a valid xhtml 
banner with a direct link to w3's xhtml validator... not so nice when it 
turns out that it's not valid xhtml after all...

I guess I will have to add the sid manually... I've never bothered doing it 
that way before, so I guess I'll have to dig trough the php manual again... 
;)

thanks for your help!
_bobo wieland _ [EMAIL PROTECTED] _
winamp  the prodigy | weather experience (top buzz remix)


- Original Message - 
From: Norland, Martin [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, November 29, 2004 10:49 PM
Subject: RE: [PHP-DB] amp; and sessions

Section 3.3 of that rfc indicates that ; is reserved in URLs - so I'm
guessing there's another solution.
Obviously you can wrap all your URLs up in a nice CDATA structure - but
that seems ridiculous.
A quick googling perusal confirms what I expected:
http://www.biglist.com/lists/xsl-list/archives/200101/msg00510.html
The XML that you see in a file is just a *serialisation* of a node
tree. In the node tree, entity references are substituted for whatever
they reference.
Which means either the browser should automagically translate the amp;
- or it should otherwise be translated before the page is rendered.  How
exactly are you tacking the SID onto the end of these URLs?  If it's
done by php automatically then you shouldn't be having problems at all
at the xhtml level, if you're doing it manually - then manually add
amp;SID=$wherever_sid_is_stored onto the urls.
Of course, I'm probably oversimplifying a problem you've fought hours
on, so all I can say is I hope the link and its thread shines some
light.
Cheers,
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.
-Original Message-
From: Bobo Wieland [mailto:[EMAIL PROTECTED]
Sent: Monday, November 29, 2004 3:31 PM
To: Bastien Koert; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] amp; and sessions
well... in xhtml you HAVE to write amp; in urls... if I can't do that
whats
the point in trying to use xhtml, when it won't work with php anyway?
_bobo wieland _ [EMAIL PROTECTED] _
winamp  kruder dorfmeister | lamb- trans fatty acid

- Original Message - 
From: Bastien Koert [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, November 29, 2004 9:51 PM
Subject: RE: [PHP-DB] amp; and sessions


you can't, not allowed
read here http://www.faqs.org/rfcs/rfc1738.html
bastien
From: Bobo Wieland [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP-DB] amp; and sessions
Date: Mon, 29 Nov 2004 20:44:43 +0100
how can i force the SID variable in urls not to be SID=, but amp;SID

?
_ bobo wieland  [EMAIL PROTECTED] __
--
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 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] Something wierd with time() and curdate()

2004-11-01 Thread Bobo Wieland
Thanks for trying to help me...
I just found out what the problem was... I use the number of seconds in a 
day (86400) as a constant Yesterday there wasn't 60*60*24 seconds in a day 
though... It was acctually 60*60*25 seconds... That's why the script flipped 
out at 11 pm... Also, in the spring time when we change the time again there 
will be 60*60*23 seconds... I think I'll live with this, since the script 
won't generate any serious error...

thanks again
_bobo
[EMAIL PROTECTED]
- Original Message - 
From: Jason Wong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, November 01, 2004 11:14 AM
Subject: Re: [PHP-DB] Something wierd with time() and curdate()


On Sunday 31 October 2004 22:45, Bobo Wieland wrote:
There is something wierd going on over here...
I have a date field, datum, in mysql that I cast to a timestamp and check
against time(). If the datum value is more than one day old the table 
finds
a new random row and sets the datum field to CURDATE(). Now, this has
worked for two years now, but today the script suddenly finds a new 
random
row each time the script is run...
Would this line have anything to with it? If not, post some concise code 
(see
below).

mysql_data_seek($result, rand(0,$rows));

I've notice this just after 11 pm today.
As I can see from some debugging time() allways returns a higher value 
than
the timestamp + 86400... Have I missed something in this script for the
last couple of years or is there a bug somewhere? Could it have something
to do with the fact that we turned the time back one hour last night?

This is the code btw:
Please *try* to isolate the problem and post CONCISE code which 
sufficiently
illustrates your problem. For example (for this particular problem) if you
suspect PHP is calculating the dates incorrectly then a few lines of code
showing the date calculations would be sufficient. If you suspect MySQL is
the culprit then a single query would be sufficient.

--
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
There are things that are so serious that you can only joke about them
- Heisenberg
*/
--
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] Something wierd with time() and curdate()

2004-10-31 Thread Bobo Wieland
There is something wierd going on over here...

I have a date field, datum, in mysql that I cast to a timestamp and check against 
time().
If the datum value is more than one day old the table finds a new random row and sets 
the datum field to CURDATE().
Now, this has worked for two years now, but today the script suddenly finds a new 
random row each time the script is run...
I've notice this just after 11 pm today.
As I can see from some debugging time() allways returns a higher value than the 
timestamp + 86400...
Have I missed something in this script for the last couple of years or is there a bug 
somewhere? Could it have something to do with the fact that we turned the time back 
one hour last night?

This is the code btw:

function bibelvers($link_id, $color = white) {
 $myBible = new Bible($link_id, FB);
 $myBible-set_delimiters(span,p,bibelversnum,text);
 $vers_nr = ;
 $vers_txt = ;
 $reset = false;
 $q = SELECT vers,textkod,UNIX_TIMESTAMP(datum) as datum FROM dagensvers WHERE visad 
= 'NU';
 $result = mysql_query($q, $link_id);
 if (mysql_affected_rows($link_id) == 1) {
  $v = mysql_fetch_object($result);
  if (time()  ($v-datum + ONEDAY)) {
   mysql_free_result($result);
   $q = SELECT vers,textkod FROM dagensvers WHERE visad = 'NEJ';
   $result = mysql_query($q, $link_id);
   $rows = mysql_affected_rows($link_id)-1;
   if ($rows = 0) {
mysql_data_seek($result, rand(0,$rows));
$v = mysql_fetch_object($result);
$q = UPDATE dagensvers SET visad = 'JA' WHERE visad = 'NU';
mysql_query($q, $link_id);
$q = UPDATE dagensvers SET datum = CURDATE(), visad = 'NU' WHERE textkod = 
'.$v-textkod.';
mysql_query($q, $link_id);
   }
   else { $reset = true; }   
  }
 }
 else { $reset = true; }
 if ($reset) {
  $q = UPDATE dagensvers SET visad = 'NEJ' WHERE visad = 'JA';
  mysql_query($q, $link_id);
  $q = SELECT vers,textkod FROM dagensvers WHERE visad = 'NEJ';
  $result = mysql_query($q, $link_id);
  $rows = mysql_affected_rows($link_id)-1;
  mysql_data_seek($result, rand(0,$rows));
  $v = mysql_fetch_object($result);
  $q = UPDATE dagensvers SET visad = 'NEJ' WHERE visad = 'NU';
  mysql_query($q, $link_id);
  $q = UPDATE dagensvers SET datum = CURDATE(), visad = 'NU' WHERE textkod = 
'.$v-textkod.';
  mysql_query($q, $link_id);
 }
 $vers_nr = $v-vers;
 $vers_txt = $v-textkod;
 $myBible-str_vers_format($vers_txt, false, false);
 $str = div class='rubb' style='width:300px;'\n.
  \tnbsp;DAGENS BIBELVERS | .$vers_nr.\n.
  \tdiv class='brod_s' id='.$color.' style='height:65px; overflow:auto;'\n.
  \t\tdiv style='width:275px; margin:0px; padding:0px;'.
  $vers_txt.
  \t\t/div\n.
  \t/div\n.
  /div\n;
 return $str;
} 

Re: [PHP-DB] Reverse (or backward?) Infinity Loop

2004-10-20 Thread Bobo Wieland
this is some code i've written once that gets all supercategories from a 
mysql db... Take it as it is... It prints out a html-string of links like 
this:
Category : sub_cat1 : sub_cat2 : sub_cat3.

Maybe you can figure it out... it takes the current id (in your example 
catId13) as a parameter and goes up to the root...

function catPathRec($id, $show_lnk = false, $rtn_val=) {
global $link_id;
$katname = strtoupper(mysql_result(mysql_query(SELECT kat_namn AS kat FROM 
text_kat WHERE id = .$id, $link_id), kat));
$hid = mysql_result(mysql_query(SELECT h_id AS hkat FROM text_kat WHERE id 
= .$id, $link_id), hkat);
if ($rtn_val == ) {
 if ($show_lnk) { return ($hid == 0) ? (a 
href='text.php?action=katkat_id=.$id.' style='font-weight:normal;' 
onfocus='this.blur()'.$katname./a) : (catPathRec($hid, $show_lnk,  : 
a href='text.php?action=katkat_id=.$id.' style='font-weight:normal;' 
onfocus='this.blur()'.$katname./a)); }
 else { return ($hid == 0) ? ($katname) : (catPathRec($hid, $show_lnk,  : 
.$katname)); }
}
else if ($hid != 0) { return catPathRec($hid, $show_lnk,  : a 
href='text.php?action=katkat_id=.$id.' style='font-weight:normal;' 
onfocus='this.blur()'.$katname./a.$rtn_val); }
return a href='text.php?action=katkat_id=.$id.' 
style='font-weight:normal;' 
onfocus='this.blur()'.$katname./a.$rtn_val.\n;
}
- Original Message - 
From: Bruno B B Magalhes [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; php-db [EMAIL PROTECTED]
Sent: Wednesday, October 20, 2004 4:47 AM
Subject: [PHP-DB] Reverse (or backward?) Infinity Loop

Hi guys,
I have a normal categories table:
catId
catParentId
catName
catStatus
But I want when a user enters on:
http://hostname/site/products/catId1/catId7/catId13/../../contentId.html
A listing should apear like that:
 Category 1
  Category 7
   Category 13
 Category 2
 Category 3
 Category 4
 Category 5
A reverse (or backward) loop! We need to get the last category and then
follow the ParentId until the 0 ParentId. Have anybody made this before
(I hope so)?
Many Thanks,
Bruno B B Magalhaes
--
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] images in db

2004-06-30 Thread Bobo Wieland
How do you accualty stor jpegs in a mysql db? And what's the pros and cons
of storing the whole image in the db and not just the path to the file on
the server?

It feels to me that it can be a bit difficult to organize the images if
they're just placed in a directory on the server. It would be esier just to
keep the images within the db so that if I need to erase a row in the db the
images will be erased too without any extra work for me...


.bobo

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



[PHP-DB] diplicate entries

2004-06-11 Thread Bobo Wieland
Hi!

What is the best way to check if a record allready exists in a msql-db from
php in the case of when the same form is submited twice beacuse of the
refresh-button?
Should I allways check the db for the same entry, or is there some esier way
to prevent the user from submiting a form more then once?
Btw, is it possible for an sql-query to stop halfway through (if the server
goes down or something)?

Thanks!


.bobo

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



Re: [PHP-DB] Multiple SQL queries...?

2004-06-03 Thread Bobo Wieland
$sql1 = SELECT COUNT(*) as views FROM $table WHERE viewed = '1' AND email =
'$row[email]';

$views = mysql_resutl(mysql_query($sql1,$connection),views);

maybe?



.bobo
www.elstudion.com/bitbob/  - not finished though...

- Original Message - 
From: [EMAIL PROTECTED]
To: Daniel Clark [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Thursday, June 03, 2004 4:43 PM
Subject: Re: [PHP-DB] Multiple SQL queries...?


 Kinda, but I just wanna count how many views in total...
 Hence my $row1++; bit...
 I'll have a play with your code though...!
 Cheers,
 Tris...




 Daniel Clark [EMAIL PROTECTED]
 03/06/2004 14:28
 Please respond to
 Daniel Clark [EMAIL PROTECTED]


 To
 [EMAIL PROTECTED] [EMAIL PROTECTED],
 [EMAIL PROTECTED] [EMAIL PROTECTED]
 cc

 Subject
 Re: [PHP-DB] Multiple SQL queries...?






 Is this what you want ??

 $sql = SELECT DISTINCT(email) FROM $table;
 $result = mysql_query($sql,$connection) or die(Couldn't execute query
 0.);

 $row1 = 0;


 while ($row = mysql_fetch_array($result)) {

  echo $row[email] ;

  $sql1 = SELECT * FROM $table WHERE viewed = '1' AND
 email = '$row[email]';
  $result1 = mysql_query($sql1,$connection)   or
 die(Couldn't execute query 1.);

  if (mysql_num_rows($result1) = 1) {
 echo 'Viewed' ;
  } else {
  echo '' ;
 }
 }

 echo $row1 ;

 Right, todays fun dilema... ;-)
 I've a user capture system set up for downloads on our site.
 Each time a user downloads a file, their info is captured (so we'll have

 multiple entries for each email address).
 Also in the table, is a field to state if the result has been viewed by
 my
 boss. (Just a 1/0 value)
 
 So, what my boss wants me to do now, is to show her, the total No of
 people captured, and how many she's viewed.
 Using the 'email' field, from the table, I've done a distinct() sort in
 MySQL to ensure that I have a list of emails(users) and no duplicates.
 My prob is this:
 I want to take each email, and see if at any point, there's a '1' in the

 viewed field.
 if there is, I want to add one to the total of $row1
 So I can output the num_rows from the distinct request, and then show
 the
 total of $row1...
 So I'll have total No of users, and total No of viewed... as I've
 mentioned above.
 What am I doing wrong?
 
 ?
 $sql = SELECT DISTINCT(email) FROM $table;
 $result = mysql_query($sql,$connection)
 or die(Couldn't execute query 0.);
 
 $row1 = 0;
 
 while ($row = mysql_fetch_array($result)) {
 
 $sql1 = SELECT * FROM $table WHERE viewed = '1' AND email =
 '$row[email]';
 $result1 = mysql_query($sql1,$connection)
 or die(Couldn't execute query 1.);
 if (mysql_num_rows($result1) = 1) {
 $row1++;
 }
 }
 ?
 ?=$row1 ?

 -- 
 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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] search engine query

2004-05-19 Thread Bobo Wieland
Hi! I'm new to this list. I usually try to get my answers at the php-win
mailing list...

But since this is a mysql question I thought it would be better to ask i t
here;

How do I get the best result from a simple search (just one input box and a
search button) from a mysql db with two tables containing
the following fields;

_table1_
id (int) (primary)
title (varchar 40)
keywords (varchar 255 with a list of keywords separated with comma)
description (varchar 255 with fulltext index)
-

_table2_
f_key (int), page (int) (f_key is the same as id from table1 and f_key and
page combined is the primary)
text (text with fulltext index)
-


I guess you can see what the table represents... One article split in 1 to *
pages with one entry in table1 for all the common stuff...

I need to find the articles that fits the search the best (obviously... )...
I'm really not sure how to do this... There must be some general way that
people goes about this since it seems to me to be a quite common thing to
do...



.bobo

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