[PHP] Re: Simple Problem
I'm not sure, but I just know that if you need to select the information from two tables (and not just from one), you should use JOIN syntax ( http://dev.mysql.com/doc/mysql/en/join.html ) Hope this helps, Lab. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Simple Problem
I'm not sure, but I just know that if you need to select the information from two tables (and not just from one), you should use JOIN syntax ( http://dev.mysql.com/doc/mysql/en/join.html ) Hope this helps, Lab. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Simple Problem
That's a SQL problem, nothing to do with PHP. You've forgotten a JOIN clause. - Skrol29 www.tinybutstrong.com - PartyPosters a écrit : I can't figure out what I am doing wrong, this sql string seems to filter out the information I want but it duplicates the all info, as 'num_rows' is total of rows in the table and not the correct value of the filtered information? $sql=SELECT products.productID, products.title, products.number_per_box, products.stock_level, products.image, users.username, users.email, users.userID FROM users, products WHERE products.userID = $userID; $mysql_result=mysql_query($sql,$connection); $num_rows=mysql_num_rows($mysql_result); this is the old sql statement which works fine - $sql=SELECT productID, title, number_per_box, stock_level, image, userID FROM products WHERE userID = '$userID'; $mysql_result=mysql_query($sql,$connection); $num_rows=mysql_num_rows($mysql_result); what I am I doing wrong. Thanks Kaan. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Simple Problem about forms and sending info to db
Ok I think I figured out my own problem. The speechmarks in the Form break up the speech marks in the echo statement so I originally changed the echo statements speechmark to a ' which worked but was informed that this was considered bad syntax and that maybe I should add a \ in front of all speechmarks which are not part of the echo statement. I could still do with an example of how to put the information from the form into the db though. As I have never done this before. Logan Moore [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am currently coding a cms. So far I have completed the security login/password system but have now moved on to a new area of php. Uploading info to a database. This is the code as it stands now. ?php if($_GET[action] == ){echo form name=adduser method=post action=adduser.php?action=adduser table width=400 border=0 cellspacing=0 cellpadding=5 tr valign=top td width=50% align=rightFull Name:/td td width=50%input name=fullname type=text id=fullname/td /tr tr valign=top td height=50 align=rightEmail:/td tdinput name=email type=text id=email/td /tr tr valign=top td align=rightUserName:/td tdinput name=username type=text id=username/td /tr tr valign=top td align=rightPassword:/td tdinput name=password type=password id=password/td /tr tr align=center td colspan=2input type=submit name=Submit value=Submit/td /tr /table /form ;} if($_GET[action] == adduser){echo Add User Function is still Under Construction br as a result what you just did has had no effect} ? I know there is something wrong as i get an error when I goto the page. I want it to display the form, then when you click submit, goto the same page except run the command to add the information from the form to the database. Also how do I put the information in the database. Regards Logan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Simple Problem about forms and sending info to db
First of all, I'd use something like this: -- CODE -- ? if (!isset($_GET['action']) || trim($_GET['action']) == ) { ? form./form ? } else if ($_GET['action'] == 'adduser') { ? Foo ? } ? -- END -- But the actual error is in the echo. You're having quotation marks inside it. You need to do it my way, or write the form like ? echo form name=\myForm\.../form; ? Niklas Logan Moore wrote: I am currently coding a cms. So far I have completed the security login/password system but have now moved on to a new area of php. Uploading info to a database. This is the code as it stands now. ?php if($_GET[action] == ){echo form name=adduser method=post action=adduser.php?action=adduser table width=400 border=0 cellspacing=0 cellpadding=5 tr valign=top td width=50% align=rightFull Name:/td td width=50%input name=fullname type=text id=fullname/td /tr tr valign=top td height=50 align=rightEmail:/td tdinput name=email type=text id=email/td /tr tr valign=top td align=rightUserName:/td tdinput name=username type=text id=username/td /tr tr valign=top td align=rightPassword:/td tdinput name=password type=password id=password/td /tr tr align=center td colspan=2input type=submit name=Submit value=Submit/td /tr /table /form ;} if($_GET[action] == adduser){echo Add User Function is still Under Construction br as a result what you just did has had no effect} ? I know there is something wrong as i get an error when I goto the page. I want it to display the form, then when you click submit, goto the same page except run the command to add the information from the form to the database. Also how do I put the information in the database. Regards Logan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple Problem about forms and sending info to db
On Tuesday 14 September 2004 18:06, Logan Moore wrote: Ok I think I figured out my own problem. The speechmarks in the Form break up the speech marks in the echo statement so I originally changed the echo statements speechmark to a ' which worked but was informed that this was considered bad syntax and that maybe I should add a \ in front of all speechmarks which are not part of the echo statement. It's up to you. IMO, using single quote strings and breaking out when handling variables is more readable than using double quote strings and escaping the double quote (\). I could still do with an example of how to put the information from the form into the db though. As I have never done this before. Plenty of tutorials out there. -- 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-general -- /* There are no working trigger cables, unless they are too short -- Ralf's Laws of Observational Astronomy n2 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple Problem about forms and sending info to db
On Tue, 14 Sep 2004 18:32:50 +0800, Jason Wong [EMAIL PROTECTED] wrote: On Tuesday 14 September 2004 18:06, Logan Moore wrote: Ok I think I figured out my own problem. The speechmarks in the Form break up the speech marks in the echo statement so I originally changed the echo statements speechmark to a ' which worked but was informed that this was considered bad syntax and that maybe I should add a \ in front of all speechmarks which are not part of the echo statement. It's up to you. IMO, using single quote strings and breaking out when handling variables is more readable than using double quote strings and escaping the double quote (\). I could still do with an example of how to put the information from the form into the db though. As I have never done this before. Plenty of tutorials out there. First of all, you're making some pretty harsh coding style errors. For the sake of compatibility, always make sure you're quoting non-numerical elements in an array, thus: write $_GET['action'] instead of $_GET[action]. Imagine, for example, what would happen if you've got some field named public and you're upgrading to php5? Or when, in php 5.4 (just saying smth), action suddenly becomes a keyword. You're stuck then with dead code. Good practice is also to check whether your expected array entry is actually set. I usually do smth like: isset($_GET['action']) or $_GET['action'] = 'thedefaultvalue'; or if (!isset($_GET['action'])) { $_GET['action'] = 'thedefalutvalue']; }; (both do the same, first one is just a lot shorter). As adviced before, whenever you have to check if a certain variable has a certain value, and if one of them is true, none of the others will be true (which is the case with $_GET['action'] checks, usually) - use the if ( /* conditions */ ) { } elseif ( /* other conditions */ ) { } method, rather than all seperate if's. I once changed this in somebody else's code and found the script running about 5 (!!) times faster, with about 15 conditions. For inserting into the databas, mysql_connect() and mysql_execute() are very good options. Or, if you're able to use the PEAR::DB package I'd advice you to use that. It's more fun to do it that way, and will help a lot if ever you'd want to change your database server from mysql to something else (postgres, for example). Ow, and it also helps a lot with any quoting problem you'd come up with. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: simple problem
add the following: if( $i % 3 == 0 ) { print(something else); } You might need to vary the zero in that equation to get it to print at the right time by which I mean, the above will print something else on the first iteration of the below loop. -philip On Wed, 4 Sep 2002, Cirkit Braker wrote: what would be the best, most efficient way to print something every three times a loop runs for ($i=0; $i$num_products; $i++) { echo something; } this happens every time it runs and has to stay that way but every three times i want to print additional info. Any help appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: simple problem
Hi, On every loop, just put the text you want to add to a variable. like if($i == 0) echo first print; elseif($i == 1) echo second; elseif($i == 2) echo third; etc... -- Nicos - CHAILLAN Nicolas [EMAIL PROTECTED] www.WorldAKT.com - Hébergement de sites Internet Cirkit Braker [EMAIL PROTECTED] a écrit dans le message de news: [EMAIL PROTECTED] what would be the best, most efficient way to print something every three times a loop runs for ($i=0; $i$num_products; $i++) { echo something; } this happens every time it runs and has to stay that way but every three times i want to print additional info. Any help appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: simple problem
Sorry I hadn't read well, yes use if(!($i %3)) echo lala; -- Nicos - CHAILLAN Nicolas [EMAIL PROTECTED] www.WorldAKT.com - Hébergement de sites Internet [EMAIL PROTECTED] a écrit dans le message de news: [EMAIL PROTECTED] Hi, On every loop, just put the text you want to add to a variable. like if($i == 0) echo first print; elseif($i == 1) echo second; elseif($i == 2) echo third; etc... -- Nicos - CHAILLAN Nicolas [EMAIL PROTECTED] www.WorldAKT.com - Hébergement de sites Internet Cirkit Braker [EMAIL PROTECTED] a écrit dans le message de news: [EMAIL PROTECTED] what would be the best, most efficient way to print something every three times a loop runs for ($i=0; $i$num_products; $i++) { echo something; } this happens every time it runs and has to stay that way but every three times i want to print additional info. Any help appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php