[PHP] Problem to insert the field
im having problem in making php news. I have session variables in login prosses: $_SESSION['username']=$rec['username']; $_SESSION['registered_admin']=TRUE; $_SESSION['username'] is taken from admin table registered_admin can publish the news, and i want to insert the value that were sent from the add_news form into news table, one of them is admin_id which is a foreign key to admin table. the problem is i do not know how to insert admin_id into news table. becoz the session which is taken from admin table is username can anyone help me please... - Ahhh...imagining that irresistible new car smell? Check outnew cars at Yahoo! Autos.
Re: [PHP] Problem to insert the field
2007. 05. 8, kedd keltezéssel 03.35-kor uni uni ezt írta: im having problem in making php news. I have session variables in login prosses: $_SESSION['username']=$rec['username']; $_SESSION['registered_admin']=TRUE; $_SESSION['username'] is taken from admin table registered_admin can publish the news, and i want to insert the value that were sent from the add_news form into news table, one of them is admin_id which is a foreign key to admin table. the problem is i do not know how to insert admin_id into news table. becoz the session which is taken from admin table is username solution 1: look up the id of the admin in the db when he logs in, store it in the session and later use that value solution 2: look up the id of the admin before inserting into the news table greets Zoltán Németh can anyone help me please... - Ahhh...imagining that irresistible new car smell? Check outnew cars at Yahoo! Autos. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem to insert the field
On Tue, May 8, 2007 5:35 am, uni uni wrote: im having problem in making php news. I have session variables in login prosses: $_SESSION['username']=$rec['username']; $_SESSION['registered_admin']=TRUE; $_SESSION['username'] is taken from admin table registered_admin can publish the news, and i want to insert the value that were sent from the add_news form into news table, one of them is admin_id which is a foreign key to admin table. the problem is i do not know how to insert admin_id into news table. becoz the session which is taken from admin table is username If you need to get the ID you just inserted, use http://php.net/mysql_insert_id If you're asking how to get the ID to insert, when all you have is the username, there are two schools of thought. One is to just go ahead and cram the ID into $_SESSION as well, when you get the username, with one more field in the query. The other is to just write another query to look up the ID. One is easier on your $_SESSION array/storage size/needs/performance. The second is easier on your raw database query count. Which is really better depends on the rest of your architecture, and your own hardware/software, more than any absolute statement we could make. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php