Re: [PHP-DB] Search witin text.

2007-02-11 Thread Christopher Blöcker

you can use  explode

from php.net:
 array *explode* ( string $delimiter, string $string [, int $limit] )
Returns an array of strings, each of which is a substring of /string/ 
formed by splitting it on boundaries formed by the string /delimiter/. 
If /limit/ is set, the returned array will contain a maximum of /limit/ 
elements with the last element containing the rest of /string/. 


as delimiter you would use a space character in this case. for example:

the user input is   $input = Chris Carter;
now you can  $split = explode( , $input);
so $split would be an array that contains  [Chris, Carter]

now you can persorm your search using $split[0] and/or $split[1]

;) I hope that's what you're looking for

Chris Carter wrote:

Thanks much ... this has been achieved now. However, there is another issue.
Say for example, the user wants to search 'Chriscarter' but puts into the
search field 'Chris Carter' how is it that I can take only the 'Chris' out
of the search string and present the matching searches from the database?

Any clue or link would be of great assistance.

Thanks again.


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



Re: [PHP-DB] Trying to add primary key to existing database.

2007-02-04 Thread Christopher Blöcker

hehe, ok
i would write a script that reads the existing data from the table and 
inserts it into a new one that has the same structure PLUS a primary key


something like:
original_table:name, description, whatever
new_table:id, name, description, whatever

where id is primary key and auto_increment

then

?
if ($link=mysql_connect(host,user,pw)
{
mysql_select_db(the_correct_database);
$result=mysql_query(SELECT * FROM original_table);
while (list($name,$description,$whatever) = mysql_fetch_row($result))
{
  mysql_query(INSERT INTO new_table (name,description,whatever) VALUES 
($name,$description,$whatever));  //that should add the id automatically

 }
mysql_close($link)
?

then you can drop the original_table and rename the new_table to 
original_table


i don't know if there's a better, more simple solution and i hope i did 
not forget anything important and it works this way


Chris

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



Re: [PHP-DB] Ways to display remaining data columns.

2007-02-03 Thread Christopher Blöcker

my first idea is the following:

since i'm sure there must be any kind of primary key you could add a 
simple link that opens in a new window and passes your primary key. a 
script (the one in the new window) now gets the details from the database
the link might be something like the following: a 
href='details.php?unique_id=123' target='_blank'Details/a
but please make shure you check the submitted data before using it in a 
query.(think of sql injections..)
you might consider using a POST form instead of GET in order to make it 
more secure i think it should also work with something like  
target='_blank'  but i'm not sure at the moment


i hope it helps and i hope i did not forget security issues ;)

Chris

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



Re: [PHP-DB] retaining form information when someone presses back

2007-01-01 Thread Christopher Blöcker

Flint Million:

This might not be relavent for this forum, so if not please direct me
to the proper one; although I do like to keep my email list
subscriptions down.

I have a custom application in PHP in which a user fills out a form of
information. When the user submits, I perform sanity checking on the
user's submitted data and refuse to actually process/insert it if
those checks fail. However, my users are complaining that when they
press back to correct, all the data is gone from the form and they
have to re-enter it all. I know many websites that can retain the form
data when someone presses back; how is this done?

Flint M



ok, an input field might be something like input type='text' 
name='username' size='8' maxlegth='32' -- the submitted variable would 
be stored in $_POST[username] (or $_GET[username] depending on what 
method you use to submit it)
your back-button should now contain a link like a 
href='fill-in-form.php?username=$_POST[username]'back/a to keep the 
information
an other possibility might be using cookies but this would be impossible 
if the user refuses to accept cookies, so this method might not be wanted


Chris

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



[PHP-DB] retain form information -.-

2007-01-01 Thread Christopher Blöcker

sorry i fogot something...
in the fill-in-form.php you would now have to modify the form to 
something like

echo  [...]
 input type='text' name='username' value='$_GET[\username\]' 
... to retain the information

  ;
i think thats it

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