Re: [PHP-DB] using query_strings in sql
Looking at that. You are combining html and php without distinguishing between the two. I am assuming you are in php mode because html wouldn't give you errors. try this: echo a href='somefile.php?order=; if ($order == ASC){ echo DESC; }else{ echo ASC; } echo '; - Original Message - From: mayo [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 1:10 PM Subject: RE: [PHP-DB] using query_strings in sql I have a table displaying data. The column headers are links that allow the users to order the content in ASC or DESC. basic version is: a href=somefile.php?order=ASCTitle/a a closer to reality version is (or would be if it worked) a href=somefile.php?order= if ($order == ASC){ echo DESC; }else{ echo ASC; } (Actually that would be a switch/case :-) ) The sql call is $selection = mysql_query( SELECT * FROM classes ORDER BY title $order ) And since there is no query string when someone lands on the page there needs to be a default value set: // setting the default variables if(!isset($order)){$order=ASC;} Unfortunately its not working :( thx, gil -Original Message- From: Micah Stevens [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 1:59 PM To: [EMAIL PROTECTED] Cc: mayo Subject: Re: [PHP-DB] using query_strings in sql I may be misunderstanding you, but your first statement about pulling from a query string is throwing me. ?php echo $section; ? will only display the value of $section on the screen. You will need to build a form to get a value into $section. form action=soemthing.php input type=text name=section /form something.php: ?php echo This is what was submitted in the form: .$section; ? Now you can do your query: $selection = mysql_query(SELECT * FROM classes WHERE classCategory = '$section' ) you'll notice I pulled the other variables out since you had not defined them yet, like your ordering variables. Otherwise the SQL would end with ORDER which will cause an error.. -Micah On Wed January 21 2004 10:41 am, mayo wrote: I'm a cold fusion refugee and am having incredible problems with something that I think is relatively easy -- so I must be missing something basic. I would like to pull info from a query string and use it inside a database call. I can pull the query string into a general variable: ?php echo $section; ? now I would like to use it in a SQL statement, or in if/else clauses to modifiy results from queries. examples below: USE query_string in SQL : ?php function whatever(){ $username = ; ... // setting the default variables if(!isset($category)){$category=Something;} if(!isset($section)){$section=SomethingElse;} [EMAIL PROTECTED]($hostname,$username,$password); mysql_select_db($database); $selection = mysql_query( SELECT * FROM classes WHERE classCategory = '$category' ORDER BY $reorder $order ) ... ? The PHP SQL call below work nicely: while ($row = mysql_fetch_array($selection)){ echo $row[sectionName]; } now I would like to do an if/else to modifiy it: while ($row = mysql_fetch_array($selection)){ if (section == $sectionName){ echo b . $row[sectionName] . /b; }else{ echo $row[sectionName]; } Nothing is working. I must be missing something basic over here. thx, Gil -- 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
[PHP-DB] PHP and XML Parsing
I have a piece of xml that has characters like and other non-normal ones. When I use the $this-parser = xml_parser_create(); functions it doesn't read the entire character sting inside the tag/tag. It stops at the . If I take out the it works perfectly. Any ideas on how I can fix this? Rick
[PHP-DB] PHP and XML
What is the best way to parse through a non-repeting XML output using php? - Rick -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Form Actions in PHP
I have a small problem. I need to have a form post to two different locations. If a variable is a certain value, it goes to location_one.cgi and if it is another value, it goes to location_two.cgi. This may turn out be a html problem but I figured php was the way to go since it is more dynamic. Any help is appreciated. - Rick
[PHP-DB] Getting a date in number form
I need to get the month in a number format; July =7. Right now it is returning the string: July. This is what I am doing. $today = getdate(); $month = $today['month']; $mday = $today['mday']; $year = $today['year']; What can I do to get the number instead of the word? - Rick
[PHP-DB] removing a # from a string
How would I remove a # from a string? I want #2 to be 2. - Rick
[PHP-DB] Reading from a file
I need to read from a file that is tab delimited. Is there anyway to specify that it reads between each tab and that is it. I know fread() uses bytes to figure out what to read but that isn't very practical in my case. Also, how do I get rid of any white space at the end of a variable if there is some once it is read in? - Rick
[PHP-DB] Altering a column in an existing table
I have a column (ID) that is currently not auto_incremental. I need to change it so that it is auto_incremental. There are already records in this column. also, I need to change the field type from int(4) to int(8). Rick
[PHP-DB] redirecting to a page
I need to redirect to another page once some scripts that I can't alter run. I have this function at the top of my page: ? function Redirect ($url) { Header (Location: . $url); exit; } ? How do I call the function? Rick
[PHP-DB] another redirecting question
The scripts I need to run before I redirect automatically send output to the browser. I cannot alter these scripts. Is there a way around this? Rick
[PHP-DB] to all the people that lended a hand
to all the people that tried to lend a hand. For some reason the javascripts didn't work. There wasn't a need to get as complicated as session variables. I ultimately figured out a way to do it by just moving { } around. Rick
[PHP-DB] formatting a timestamp
I want to print out a timestamp of length 14. I want to have it formatted like: mm-dd-yy : hh-mm I have looked but all I can find is how to format a date and I don't want that. I want the time also. Rick Don't burn the day...away ~ DJM _ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Member login
Having a member login is just checking the password against the database and starting a session for that person, right? Rick _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Updating and deleting
Why won't this work? html titleEdit Show List/title body ?php $db = mysql_connect(localhost, root); mysql_select_db(websitedb,$db); if($sent) { $sql = UPDATE bp set sent=$sent where fname=$fname AND lname=$lname; mysql_query($sql); ? Sentbra href=http://twostep.antsmarching.org/bpedit.php3;Back/a ?php }else if($received) { $sql = UPDATE bp set received=$received where fname=$fname AND lname=$lnam;; mysql_query($sql); ? Receivedbra href=http://twostep.antsmarching.org/bpedit.php3;Back/a ?php } else if($delete) { $sql = DELETE FROM bp WHERE lname=$lname AND fname=$fname; mysql_query($sql); ? Deletebra href=http://twostep.antsmarching.org/bpedit.php3;Back/a ?php } $result = mysql_query(SELECT * FROM bp ORDER by showdate, $db); echo table border=1 align=center\n; echo trtd align=centerDate/tdtd align=centerName/tdtd align=centerAddress 1/tdtd align=centerAddress 2/tdtd align=centerCity, State Zip/tdtdReceived/tdtdSent/tdtdEdit/td/tr; while($myrow = mysql_fetch_row($result)) { printf(trtd%s/tdtd%s %s/tdtd%s/tdtd%s/tdtd%s, %s %s/tdtd%s/tdtd%s/td, $myrow[7], $myrow[1], $myrow[0], $myrow[2], $myrow[3], $myrow[4], $myrow[5], $myrow[6], $myrow[8], $myrow[9]); printf(tda href=\%s?lname=%sfname=%sreceived=yes\Received/a, $PHP_SELF, $myrow[0], $myrow[1]); printf(bra href=\%s?lname=%sfname=%ssent=yes\sent/a, $PHP_SELF, $myrow[0], $myrow[1]); printf(bra href=\%s?lname=%sfname=%sdelete=yes\Delete/a/td/tr, $PHP_SELF, $myrow[0], $myrow[1]); }
Re: [PHP-DB] mail() function
Is the the type of thing I would need? http://www.postcastserver.com/ I found where I am supposed to alter the PHP.ini file. What am I supposed to type instead of 'localhost' Rick Don't burn the day...away ~ DJM From: Jason Wong [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mail() function Date: Sat, 22 Mar 2003 14:49:29 +0800 On Saturday 22 March 2003 16:53, Rick Dahl wrote: I think the fact that I don't have a mailserver would do it. Unless the PHP home edition 2 bundle has a mailserver, I don't have one. Where can I get one of those? Can I get it for free? I think having a mailserver would be a tremendous help in sending mail :) If you're running on some Windows system you can try specifying the SMTP server provided by your ISP. Otherwise google is your friend. If you're running some *nix system then they usually come with the ubiquitous sendmail. -- 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-db -- /* Let me put it this way: today is going to be a learning experience. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mail() function
I can't get it to work. I get the echo to show up but never receive a email. if($blankpostage) { $to = Rick Dahl [EMAIL PROTECTED]; $subject = Online B+P Request; $body = Show ID = . $id; mail($to, $subject, $body); echo sadflkjaflkasdj; } What am I doing wrong? Rick
Re: [PHP-DB] mail() function
I think the fact that I don't have a mailserver would do it. Unless the PHP home edition 2 bundle has a mailserver, I don't have one. Where can I get one of those? Can I get it for free? Rick - Original Message - From: Jason Wong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, March 21, 2003 10:41 PM Subject: Re: [PHP-DB] mail() function On Saturday 22 March 2003 16:38, Rick Dahl wrote: I can't get it to work. I get the echo to show up but never receive a email. if($blankpostage) { $to = Rick Dahl [EMAIL PROTECTED]; $subject = Online B+P Request; $body = Show ID = . $id; mail($to, $subject, $body); echo sadflkjaflkasdj; } 1) Check that php.ini is correctly configured 2) Check the php error log 3) Check your mailserver log -- 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-db -- /* You can learn many things from children. How much patience you have, for instance. -- Franklin P. Jones */ -- 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