Re: [PHP-DB] Display records on form
On Tuesday 04 January 2005 10:10, David Ziggy Lubowa wrote: Hey guys , I was wondering , i have 16 records within a table in my Database , i have managed to have a form which can add and modify the records. My only problem is how i can display on a form when i search. Can someone give me heads up on how i can code this in php, to display the records in a tabular manner when i search. sorry i meant 16 fields not records : ) Any help is highly appreciated. cheers -Z -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL database converter ?
Nayyar Ahmed wrote: Hello All: Is there any tool available for conversion of M$ Access, Oracle etc Databases to MySQL database ? google will probably give you more answers than this list (try also searching for the term 'datapump' and variations on it) IBExpert is one tool that will allow you to reverse engineer an existing DB and then use the model that is created to generate SQL to create a new DB in the format of your choice (the 3 you mention are supported) also bare in mind that not all features of each database can be translated to the others. TIA: -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Removing first word from a string?
Chris, I'll try to explain the basics of a technique I often use: imagine you have 0 or more possible where clauses. start of with an empty array e.g. $whereClauses = array(); now for each clause you need add the relevant subclause as a seperate item to the array (DO NOT include the AND or WHERE string). e.g. if ($foo) { // it up to you to make sure $foo is okay for adding to a query string $whereClauses[] = foofield='$foo'; } once you have gone thru all the possible subclauses that could exist do something like this (I'll assume $sql contains the base query): if (count($whereClauses)) { // we have a where statement to make $sql = $sql . ' WHERE ' . join(' AND ', $whereClauses); } I leave it up to your imagination how you apply this idea! greets, Jochem Bastien Koert wrote: one simple trick is to use a clause that always evaluates correctly. For example, in my site I don't delete data, but flag it with a field (record_deleted) which defaults to 'No' (actually 0) and can be set to 'Yes' (again 1) so that all queries are built with the requirement to use AND ie $sql = select * from tablename where record_deleted = 0 //code to delevop additional where paramters goes here if (!empty($_POST['city'])){ $sql .= AND city like '{$_POST['city']}%' ; }//end if you could also use the same mechanism that PHPMYAdmin does which is to 1 select * from tablename where 1 since one always evaluates to true and does not affect the query, its a simple way of doing the same as above bastien From: Chris Payne [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Removing first word from a string? Date: Mon, 3 Jan 2005 21:46:03 -0500 Hi there everyone, I am building a dynamic MySQL query for a project I am working on, but there are instances where it products WHERE AND instead of WHERE city etc .. due to the nature of the system I am developing. My question is, how can I remove the FIRST AND from a string if it is present, but leave all other AND statements in the string? I would really appreciate any help on this. I can do a find and replace on a string no problem, but just want it to be removed IF it is the FIRST word in the string. Oh and Happy New Year everyone. Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.296 / Virus Database: 265.6.7 - Release Date: 12/30/2004 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Display records on form
David Ziggy Lubowa wrote: On Tuesday 04 January 2005 10:10, David Ziggy Lubowa wrote: Hey guys , I was wondering , i have 16 records within a table in my Database , i have managed to have a form which can add and modify the records. My only problem is how i can display on a form when i search. Can someone give me heads up on how i can code this in php, to display the records in a tabular manner when i search. how does somebody manage to create a working script to insert/update data in a table and not be able to figure out how to output a simple HTML table listing the current records? I mean, do you want us to teach you how to write PHP? (My rate is 40euros/hour) -- Sorry David but your email shows little to no effort on your part to: a, define you problem succinctly b, show context (e.g. code,SQL snippets) c, show that you have made a decent effort to work the problem. given those facts you can consider yourself lucky to recieve any replies at all. ANYWAY... seeing as I'm bitchin' at ya I might as well give you a small clue the process, roughly speaking is: 1. do a SQL select query. (e.g. SELECT id,name FROM mytable) 2. loop thru the result, for each row output some HTML for a table row e.g. echo ' tr tda href=/edit.php?id='.$row['id'].'edit/td td'.$row['id'].'/td td'.$row['name'].'/td /tr' 3. don't forget to add begin- and ending TABLE tags. try googling 'display a MYSQL result set with PHP': I came up with: http://juicystudio.com/tutorial/php/mysql.asp (which is pretty funny cos the guy wrote a tutorial on mysql/php on an ASP based site!!) sorry i meant 16 fields not records : ) whether you tables has 16 rows or fields seems to me to be completely irrelevant. Any help is highly appreciated. cheers -Z -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Display records on form
first of all , let me apologize for the top post, second let me apologize for not giving more detail. The main problem is basically pagination , i have failed to add pagination code to my own code simply because it is not as simple as i thought. Considering i am a begginer in PHP , i must give myself some credit for reaching where i am , as for code snippet here goes, [snip] html titleIP Addresses/title body ?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable // check for an empty string and display a message. if ($trimmed == ) { echo pPlease enter a search.../p; exit; } // check for a search parameter if (!isset($var)) { echo pWe dont seem to have a search parameter!/p; exit; } $link = mysql_connect(localhost, me,me2); mysql_select_db(ip, $link); $qry = mysql_query(SELECT * FROM IP_Addresses where free like '%. $_GET['q'].%', $link); ? table border=1 width=100%tr?php if (mysql_num_rows($qry)==0 ) { print Oops No records found ; ? br a href=http://localhost/ipsearch2.html;Back/a /br ? exit(); } if (mysql_num_rows($qry) 0) { for ($i = 0; $imysql_num_fields($qry); $i++) { echo td align=centerstrong . mysql_field_name($qry, $i) . /td; } } ? /tr?php if (mysql_num_rows($qry) 0) { for ($j = 0; $jmysql_num_rows($qry); $j++) { ?tr?php for ($k = 0; $kmysql_num_fields($qry); $k++) { echo td align=center . mysql_result($qry,$j, $k) . /td; } ?/tr?php } } ? /table br br a href=http://localhost/index.html;Main Page/a br br a href=http://localhost/ipsearch2.html;IP Address Search/a/br/br /br /br /body /html [/snip] i had posted some time back that i have problems with pagination and got alot of help , but the problem is i have never known how to put the code together with what i have .. any help is appreciated... cheers On Tuesday 04 January 2005 04:17, Jochem Maas wrote: David Ziggy Lubowa wrote: On Tuesday 04 January 2005 10:10, David Ziggy Lubowa wrote: Hey guys , I was wondering , i have 16 records within a table in my Database , i have managed to have a form which can add and modify the records. My only problem is how i can display on a form when i search. Can someone give me heads up on how i can code this in php, to display the records in a tabular manner when i search. how does somebody manage to create a working script to insert/update data in a table and not be able to figure out how to output a simple HTML table listing the current records? I mean, do you want us to teach you how to write PHP? (My rate is 40euros/hour) -- Sorry David but your email shows little to no effort on your part to: a, define you problem succinctly b, show context (e.g. code,SQL snippets) c, show that you have made a decent effort to work the problem. given those facts you can consider yourself lucky to recieve any replies at all. ANYWAY... seeing as I'm bitchin' at ya I might as well give you a small clue the process, roughly speaking is: 1. do a SQL select query. (e.g. SELECT id,name FROM mytable) 2. loop thru the result, for each row output some HTML for a table row e.g. echo ' tr tda href=/edit.php?id='.$row['id'].'edit/td td'.$row['id'].'/td td'.$row['name'].'/td /tr' 3. don't forget to add begin- and ending TABLE tags. try googling 'display a MYSQL result set with PHP': I came up with: http://juicystudio.com/tutorial/php/mysql.asp (which is pretty funny cos the guy wrote a tutorial on mysql/php on an ASP based site!!) sorry i meant 16 fields not records : ) whether you tables has 16 rows or fields seems to me to be completely irrelevant. Any help is highly appreciated. cheers -Z -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL version issue
As some of you will recall, I enquired on this list about versions of MySQL and PHP a while back regarding and issue wit using the 'ON DUPLICATE KEY UPDATE' command in MySQL INSERT queries. Having upgraded our in-house system to PHP5 and MySQL 4 the issue was no longer a problem. However I have subsequently enquired with our out-of-house web host and they are still using PHP 4.1.2 and MySQL 3.25.58. As one of the purposes of asking them was to establish if I could easily upload from my database to the remote database, I now have a problem. I was planning to use a compare and update script that used 'ON DUPLICATE KEY UPDATE' command in MySQL INSERT queries to add or change items on the remote server. However I can't, as it's a MySQL4 feature and the database to which I am writing ain't using MySQL4! Any ideas about how I can create a MySQL3 compliant substitute for the 'ON DUPLICATE KEY UPDATE' Query action? -- Mark Benson http://homepage.mac.com/markbenson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL database converter ?
DB Designer4 from fabforce (www.fabforce.net/dbdesigner4/) bastien From: Nayyar Ahmed [EMAIL PROTECTED] Reply-To: Nayyar Ahmed [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] MySQL database converter ? Date: Tue, 4 Jan 2005 10:36:20 +0500 Hello All: Is there any tool available for conversion of M$ Access, Oracle etc Databases to MySQL database ? TIA: -- Nayyar Ahmad Lecturer Faculty Of Computer Science, Institute Of Management Sciences, Hayat Abad Peshawar , Pakistan. Office : 92-091-9217404 , 9217452 Cell : 92-0333-9139461 -- 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] MySQL version issue
Hi Mark, I guess the best way would be to use some php and sql and let the application do the checking. First run a query to acertain if the key is present, if yes then update the main record else insert a new record. bascially you just need to bring the SQL logic into the app logic. Bastien From: Mark Benson [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] MySQL version issue Date: Tue, 04 Jan 2005 14:43:48 + As some of you will recall, I enquired on this list about versions of MySQL and PHP a while back regarding and issue wit using the 'ON DUPLICATE KEY UPDATE' command in MySQL INSERT queries. Having upgraded our in-house system to PHP5 and MySQL 4 the issue was no longer a problem. However I have subsequently enquired with our out-of-house web host and they are still using PHP 4.1.2 and MySQL 3.25.58. As one of the purposes of asking them was to establish if I could easily upload from my database to the remote database, I now have a problem. I was planning to use a compare and update script that used 'ON DUPLICATE KEY UPDATE' command in MySQL INSERT queries to add or change items on the remote server. However I can't, as it's a MySQL4 feature and the database to which I am writing ain't using MySQL4! Any ideas about how I can create a MySQL3 compliant substitute for the 'ON DUPLICATE KEY UPDATE' Query action? -- Mark Benson http://homepage.mac.com/markbenson -- 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] MySQL version issue
It seems to me that the _mysql manual_ gives a most straightforward and useful explanation: If you specify the ON DUPLICATE KEY UPDATE clause (new in MySQL 4.1.0), and a row is inserted that would cause a duplicate value in a UNIQUE index or PRIMARY KEY, an UPDATE of the old row is performed. For example, if column a is declared as UNIQUE and already contains the value 1, the following two statements have identical effect: mysql INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1; mysql UPDATE table SET c=c+1 WHERE a=1; The rows-affected value is 1 if the row is inserted as a new record and 2 if an existing record is updated. Note: If column b is unique too, the INSERT would be equivalent to this UPDATE statement instead: mysql UPDATE table SET c=c+1 WHERE a=1 OR b=2 LIMIT 1; If a=1 OR b=2 matches several rows, only one row is updated! In general, you should try to avoid using the ON DUPLICATE KEY clause on tables with multiple UNIQUE keys. Or, you might find a more interesting answer on a MySQL list. Doug Mark Benson wrote: As some of you will recall, I enquired on this list about versions of MySQL and PHP a while back regarding and issue wit using the 'ON DUPLICATE KEY UPDATE' command in MySQL INSERT queries. Having upgraded our in-house system to PHP5 and MySQL 4 the issue was no longer a problem. However I have subsequently enquired with our out-of-house web host and they are still using PHP 4.1.2 and MySQL 3.25.58. As one of the purposes of asking them was to establish if I could easily upload from my database to the remote database, I now have a problem. I was planning to use a compare and update script that used 'ON DUPLICATE KEY UPDATE' command in MySQL INSERT queries to add or change items on the remote server. However I can't, as it's a MySQL4 feature and the database to which I am writing ain't using MySQL4! Any ideas about how I can create a MySQL3 compliant substitute for the 'ON DUPLICATE KEY UPDATE' Query action? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php