Re: [PHP-DB] Row order
Stefan, Depending on your load, you could save the results in a database table, make the table name a session variable, and just have the sorting column names be fields in the saved table. CREATE TABLE Q1234 AS SELECT ...; You can also put all the variables in a variable then put the new variable in the a tags like this: $query_vars = field1=afield2=bfield3=c...; a href=file.php??=$query_vars?sort=field4Field 4/a Hope this helps. Dan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Informix Question (Still need help,please)
B, Do your first query, then run this (for one record returned). while($row = ifx_fetch_row($query_result_id)) { for(reset($row); $fieldname=key($row); next($row)) { $$fieldname = $row[$fieldname]; } } Do your second query. The while statement will set each field value equal to the field name. Dan What I want to do is create another query from some of the data from another one. The question is how do I take the data I get back from my first query and put that into variables so I can build my second query. The example I have in mind is: I a do a select tracknum,orderdate,ordertotal,status,shipdate from orders where tracknum = '$trknum' and I want the data returned into vars: like orderdate = $orderdate so I can create a new query like: select * from shipping where orderdate = '$orderdate'. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] SELECT question
Nick, Use the group by function: SELECT items.itemId, description, link, sum(qty) AS total_qty, sum(price) AS total_price FROM carts, items WHERE carts.custId = '$custId' AND items.itemId = carts.itemId GROUP BY items.itemId, description, link You'll have to change the reference to the following 2 variables in your PHP code: $qty $total_qty $price $total_price Dan Subject: SELECT question Date: Wed, 16 May 2001 21:06:56 -0400 From: Nicholas W. Miller [EMAIL PROTECTED] To: [EMAIL PROTECTED] Hi All, I'm building a standard shopping cart style e-commerce site using PHP and MySQL running on Apache. I store my users' cart info in this table: ++--+--+-+-+---+ | | Field | Type | Null | Key | Default | Extra | + ++--+--+-+-+---+ | | custId | int(11) | | | 0 | | | | itemId | int(11) | YES | | NULL| | | | qty| int(11) | YES | | NULL| | | | totalPrice | float(10,2) | YES | | NULL| | | | dateAdded | timestamp(6) | YES | | NULL| | + ++--+--+-+-+---+ I currently use this statement to display a user's cart contents: SELECT items.itemId, description, link, qty, price FROM carts, items WHERE carts.custId = '$custId' AND items.itemId = carts.itemId If a user happens to add the same item to their cart more than once, this statement displays the item more then once. Is there a way I can augment the select statement above so I can group multiple instances of the same product into a single line, but still get a sum of the quantities so the single lines reflects the total quantity of all the instances. So for example, if add 2 of itemId 1 and then add 3 more of itemId 1 my cart will display itemId 1 two times ... once with a qty of 2 and once with a qty of 3. Instead, I would like it to display one time with a qty of 5. Make sense? I'm sure I could hack around this, but I'd like to know if it is doable in a single select statement. Thanks! Nick -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Help please
I assume that the username field is text. You need to add single quotes around the field. $validate = mysql_query("SELECT username, user_password FROM users WHERE username='".$uname."'",$db); OR simply: $validate = mysql_query("SELECT username, user_password FROM users WHERE username='$uname'",$db); Hope this helps. Dan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: SQL Mysql - Informix
Jon, Try the following: Use the sysmaster DB. Then: SELECT tabname FROM systabnames WHERE dbsname = '$your_db_name' [ AND owner 'informix' ] - Assuming you were not logged in as informix when you created the tables [ AND tabname NOT LIKE ' %' ] - If you use blobs you may have some numeric tables I think The stuff in the square brakets is optional. Informix throughs in a lot of system tables and hidden tables. The systabnames table is in the sysmaster database and has the following fields: partnum, dbsname, owner, tabname, collate Hope this helps. Dan Any idea how to extract table names for a database in informix - like the sql for mysql SHOW TABLES; ?? J -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Join statement and output
Norman, The SQL statement is this: select s.first_name AS s_name, t.first_name AS t_name, f.date from members s, members t, schedule f where s.first_name=f.member1 and t.first_name=f.member2 The AS is optional but it works the same as aliasing table names in the FROM clause. $s_name | $t_name | date Dan __ Subject: Join statement and output Date: Sat, 03 Mar 2001 22:43:27 -0800 From: Norman Tan [EMAIL PROTECTED] To: [EMAIL PROTECTED] No actual code, but hopefully, someone can help me through the theory here. I have 2 tables: members - first_name, last_name schedule - member1, member2, date The SQL statement is this: select s.first_name, t.first_name, f.date from members s, members t, schedule f where s.first_name=f.member1 and t.first_name=f.member2 Now the output would look something like this. | first_name | first_name | date | Question is, in PHP, how would I distinguish the two first_name fields? Database is currenly MySQL, but I would like this to be database independant. Thanks for your help. -- Norman Tan North Shore Interactive http://www.nsmb.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]