|
A sub-select with a GROUP_CONCAT should do it....although I have not test this query.
select GROUP_CONCAT((select DISTINCT model FROM models where shw=1 ORDER BY modelid)) as mod_name, * FROM models where shw=1 ORDER BY modelid
this would return the subselect as a comma seperated value on each row by a column named "mod_name".
I would advise that you do not use the "*" in the other query as this forces mysql to do a secondary query to find and return the column names for the table models, it is better to just set them in the query to improve performance.
Chris J
www.redash.org
|
|
|
|
|
Hi All,
<?php
echo "Hello World";
?>
This index.php is not outputting anything to the browser but I can copy this file to another computer and it works as expected. Also, on the problem machine phpinfo() works fine and displays everything you'd expect.
I'm running Ubuntu 11.04 32-bit, Apache 2.2.17, and PHP 5.3.5-1. I'm guessing there must be something wrong with the php configuration but I haven't a clue as to what that might be. I've also tried print() as well and get the same results.
Suggestions?
Thanks much for any help...
|
|
|
|
|
First, I would check that the page is actually blank, and not just serving the PHP as HTML.
The next thing I would check is the file permissions.
After that I would take a look at the server log to see if there are any errors reported there.
Next, I would make sure display_errors and error_reporting are turned on and insert an error into the page to make sure it is actually being executed.
|
|
|
|
|
Thanks,
display_errors help a lot. I had a parsing error. I wasn't able to see it in nano but when I erased it and re-typed the line, it worked fine.
|
|
|
|
|
Hi, I am new to PHP. I am currently working on CRM project, I need to keep track of email status and update into my database such as who read the email or who opened?, who deleted?, who replied? and also When was the email opened/deleted/replied? Date and time. is there any possible to track if someone has read the email or hasn't which I have sent the email to them?
|
|
|
|
|
And you are what, writing the mail client then. No mail client will ever sent you a notification upon deletion, reading or reply.
You could try a redirect under each and every link in the e-mail, or possibly the images used in the e-mail. And you could track the hits this redirect page gets. This would give you a somewhat decent overview of how many people open / read. But again delete is a lot harder if not impossible to track.
|
|
|
|
|
thanks for your reply, I used images with my message content, I got read status. but I need delete status. First of all I want to know is it possible to track for delete? if yes is there a way to find out if someone delete the email which i have been sent?
|
|
|
|
|
If my memory serves IMAP has some features for this but your code has to manage this. If the user can connect to the email via an outside email program, outlook for example, then I do not think you can do anything about it.
You may look at your email server, the actual software that manages the email, and see if it has any kind of user logging features.
try read this in the php manual http://php.net/manual/en/function.imap-delete.php[^]
Chris J
www.redash.org
|
|
|
|
|
Dear,
I am a self learner, i wanted to know " How to browse a .php file and which compiler is used to compile?
|
|
|
|
|
If your PHP files are related to web sites, you can use a web server that supports PHP. Xampp[^] would be one example; it will interpret the required PHP files on the spot; it can also be used to just compile-and-run a PHP file, as PHP is a general programming language, not necessarily linked to web stuff. You'd have to look the details up in the manual of your PHP system.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hey Friends
I got a XP Machine, Active Perl Installed, Symbian SDK 0.9 installed & Carbide C++ installed & creating new symbian project.
When i compile the project, i get the error BLDMAKE ERROR: Can't find any RVCT installation.
Any idea what is that ? & how to fix it?
Regards
|
|
|
|
|
|
hello guys... I have an html page inwhich I collect some data using text boxes. Now in this page, I have button and I set the action attribute of <form> a php script like this
<form action="test.php" method="post">
-----
Now this does the job. But the problem is that I dont want to be redirected and want to stay on the same page but at the same time want to execute the test.php script. How can I do that? thnx
|
|
|
|
|
You can do that with an ajax call.
I.e create an HttpWebRequest object, ask for test.php and then display the results on your (already loaded & displayed) page.
I'll see if I can't fish out some old code I have lying about somewhere.
|
|
|
|
|
Perhaps it's your lucky day!
Couldn't find the old code that I had in mind, so quickly hacked something together that should demonstrate the principle for you.
Also helped improve my own code in the process of ensuring that this code would be pretty easy to re-use. The submitForm function is fresh off my neurons and axioms - wish I'd thought of doing that when I last coded in php.
You'll need to download AjaxRequest.js - I've not included it in this post due to it's size. (AjaxRequest[^)
Though everything else you need is here.
Apologies for the total lack of error handling, and the Mickey Mouse test.php. It should however be more than enough to demonstrate my approach. I'd be interested in seeing what devoutees of jQuery think (yeah, I know it's already written, but it's about 18 times the size of code performs the functionality that I need)
=================================
File #1, index.php
=================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<script type="text/javascript" src="ajaxRequestCompressed2.js"></script>
<script type="text/javascript">
function byId(el){return document.getElementById(el)}
function myGetAjaxResponse(target, url)
{
AjaxRequest.get(
{
'url':url,
'onSuccess':function(req){ target.innerHTML=req.responseText; }
}
);
}
function submitForm(formIdString, targetPhpFileString, pageTgtContainerIdString)
{
var theForm, curItem, url;
theForm = byId(formIdString);
for (curItem = 0; curItem<theForm.length; curItem++)
{
if (curItem == 0)
url = targetPhpFileString + "?";
else
url = url + "&";
url = url + theForm.elements[curItem].id + "=" + theForm.elements[curItem].value;
}
myGetAjaxResponse(byId(pageTgtContainerIdString), url)
}
</script>
</head>
<body>
<h1>Welcome to my CP test!</h1>
<form id="form1" name="form1">
<label>First Name<input id="firstName"/></label>
<label>Last Name<input id="lastName"/></label>
<input type=button onclick="submitForm('form1', 'test.php', 'ajaxTarget')" value="SubmitMe"/>
</form>
<div id="ajaxTarget"> </div>
</body>
</html>
=================================
File #2: test.php
=================================
<?php
$firstName = $_GET["firstName"];
$lastName = $_GET["lastName"];
printf("%s, %s<br>", $lastName, $firstName);
?>
|
|
|
|
|
Hello, guys!
I am a newbie in web building, but I want to make my personal web site by myself. I want to embed there a php login form, but it is difficult for me to write the correct code. I surfed the internet and found a program that builds any form you want. It is called php forms (http://phpforms.net/). But I don't know whether to try it or not.
Has anybody worked with this software? What would you suggest me to do?
Life is too short to be small
|
|
|
|
|
Hi,
I have a form that I am creating for my website, and its for people to use if they find a butterfly or moth and cannot identify it. Basically what I want is for the user to fill in the form and if they have an image to send, select an image and send the message. Code I have:
<form action="mailer.php" method="post" name="form1" id="form1" style="margin:0px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px; width:300px;" onsubmit="MM_validateForm('from','','RisEmail','subject','','R','verif_box','','R','message','','R');return document.MM_returnValue"><br />
<br />
Your Name:<br /><br />
<input name="name" type="text" id="name" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['name'];?>"/><br />
<br /><br />
<br /><br />
<br />
Your e-mail:<br /><br />
<input name="from" type="text" id="from" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['from'];?>"/><br />
<br /><br />
<br /><br />
<br />
Stage:<br /><br />
<select name="stage"><br />
<option value="Caterpillar">Caterpillar</option><br />
<option value="Pupa">Pupa</option><br />
<option value="Cocoon">Cocoon</option><br />
<option value="Adult">Cocoon</option><br />
<option value="Leaf Mine">Leaf Mine</option><br />
<option value="Leaf Mine Vaccated">Leaf Mine (Vaccated)</option><br />
</select><br /><br />
<br /><br />
Method:<br /><br />
<select name="method"><br />
<option value="UV Light Trap">UV Light Trap</option><br />
<option value="MV Lamp">Mercury Vapour Lamp</option><br />
<option value="Tungsten Light">Tungsten Light</option><br />
<option value="Actinic Light">Actinic light</option><br />
<option value="Household Bulb">Household Bulb</option><br />
<option value="Camping Lamp">Camping Lamp</option><br />
<option value="Infrared">Infrared Light</option><br />
<option value="LED Lights">LED Lights</option><br />
<option value="Carlights">Car Headlights</option><br />
<option value="Lighted Window">Attracted to Lighted Window</option><br />
<option value="Streetlight">At street light</option><br />
<option value="Security light">At security light</option><br />
<option value="Torch">Found via torchlight</option><br />
<option value="Dead Road">Found dead on road</option><br />
<option value="Spider Web">Found in Spider Web</option><br />
<option value="Nighttime">Night time observation</option><br />
<option value="Daytime">Daytime Observation</option><br />
<option value="Hibernating">In Hibernation</option><br />
<option value="Beaten">Beaten from vegetation</option><br />
<option value="Dusking">Found while dusking</option><br />
<option value="Netted">Netted</option><br />
<option value="Birdseed">Found in Bird Seed Bag</option><br />
<option value="Fruit/Veg">Found inside a fruit or vegetable</option><br />
<option value="Pheromone">Attracted via pheramone lures</option><br />
<option value="Feeding signs">Feeding signs</option><br />
<option value="Fish">Found inside a fish</option><br />
<option value="Indoors">Found Indoors</option><br />
<option value="Tree trunk">Found on Tree Trunk</option><br />
<option value="Wall">Found on Wall</option><br />
<option value="Other">Other Method</option><br />
</select><br /><br />
<br /><br />
Country:<br /><br />
<input name="country" type="text" id="country" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;" value="<?php echo $_GET['subject'];?>"/><br />
<br /><br />
<br /><br />
Town/City:<br /><br />
<input name="town/city" type="text" id="town/city" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;" value="<?php echo $_GET['subject'];?>"/><br />
<br /><br />
<br /><br />
Habitat:<br /><br />
<input name="Habitat" type="text" id="Habitat" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;" value="<?php echo $_GET['subject'];?>"/><br />
<br /><br />
<br /><br />
Habitat Information:<br /><br />
<br /><br />
<textarea name="Habitat Information" cols="6" rows="5" id="HabitatInformation" style="padding:2px; border:1px solid #CCCCCC; width:300px; height:100px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;"><?php echo $_GET['message'];?></textarea> <br />
<br />
<br /><br />
<br /><br />
If you have an image, select it here (JPEG image, max 5MB):<br />
<input type="file" name="datafile" size="40"><br /><br />
<br /><br />
<br />
Type verification image:<br /><br />
<input name="verif_box" type="text" id="verif_box" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;"/><br />
<img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="absbottom" /><br /><br />
<br /><br />
<br />
<!-- if the variable "wrong_code" is sent from previous page then display the error field --><br />
<?php if(isset($_GET['wrong_code'])){?><br />
<div style="border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px;width:295px;">Wrong verification code</div><br /> <br />
<?php ;}?><br />
<br />
Additional Information:<br /><br />
<br /><br />
<textarea name="message" cols="6" rows="5" id="message" style="padding:2px; border:1px solid #CCCCCC; width:300px; height:100px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;"><?php echo $_GET['message'];?></textarea> <br />
<br />
<input name="Submit" type="submit" style="margin-top:10px; display:block; border:1px solid #000000; width:100px; height:20px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; padding-left:2px; padding-right:2px; padding-top:0px; padding-bottom:2px; line-height:14px; background-color:#EFEFEF;" value="Send Message"/><br />
</form>
What I want is a way to make sure the user has filled in all fields (except the file input field) before sending, to make sure when they press send message, it sends with information on it. Second I want when the user uses the file input to upload a file, it has to be a JPEG with a max size of 5MB. Anyone know how I would do this?
In the end we're all just the same
|
|
|
|
|
Briefly, you will need to add a scrap of javascript to your page. In your <form ... > add something like
onsubmit="return check_fields()"
Somewhere in your page (I put it in the head section) put something like
<script type="text/javascript">
function check_fields() {
if (document.getElementById("xxx").checked || document.getElementById("yyy").checked)
return true;
alert("You must select either xxx or yyy!");
return false;
}
</script>
The function should return true if it's OK to submit. If there's something wrong, spit out an alert to say what the problem is, and return false so the form won't actually be submitted. Obviously, your checking will be more complex than this example which I ripped out of one of my sites.
Cheers,
Peter
If this answers your question, vote for it.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Thanks Peter, will try that.
In the end we're all just the same
|
|
|
|
|
Hi.
I'm using wampserver on my local machine for testing purposes.
The problem is apache wont start.
I can't get it to start and don't know why it won't start.
help me please.
Thank u.
|
|
|
|
|
Could you be any more vague? Apache will always list a reason as to why it won't start in the error log. Which WAMP should provide a link to.
The most likely reason is that you are already using the port that Apache wants to use (80) is already binded to another application. An application that blocks this port without telling you is Skype for example.
|
|
|
|
|
Hi All -
After shaking my head with the output of xml.Elementry(root).write(fp), which dumps the entire XML tree structure onto one line, I started doing some research. I checked out prettyprint from effbot.org, which sort of inspired me to write the following.. It handles stand alone XML tags and XML tag pairs, attributes, tag text and tag tails. I hope people find it useful...
import xml.etree.ElementTree as xml
def DumpXMLElem(e,deep=0):
noneg = 0
# indent the tag according to the depth in the element tree.
for i in range(0,deep):
print ' ',
# find out if the elment has children or a text field, if so
# this is part of a tag-pair, otherwise it's a single stand-
# alone tag.
c = e.getchildren()
# print the beginning of the open tag
print '<'+e.tag,
# print the tag attributes within the opening tag
for i in e.attrib:
print ' '+i+"="+e.attrib[i],
# if this is a stand-alone tag (no children and no text)
# print out the proper tag terminator
if(len(c)==0 and e.text==None):
print '/>',
# print the tail, if supplied
if(e.tail):
print e.tail
print ' '
noneg=1 # flag to avoid printing the closing tag
else:
# this is part of a tag pair
print '>',
# print the tag's text, usually that stuff between the opening and closing tag.
if(e.text):
print e.text,
# if the element has children, end this line and go process the children.
if(len(c)>0):
print ' '
for s in c:
DumpXMLElem(s,deep+1)
# back from dealing with the kids, go line-up the ending tag with the
# same indent as the opening tag.
for i in range(0,deep):
print ' ',
# print that ending tag, and any tail that the element had...
if(noneg==0):
print '</'+e.tag+'>',
if(e.tail):
print e.tail
print ' '
|
|
|
|
|
hello guys... I want to close an opened window with a button on it. I know how to close a window in javascript but the problem is I need to perform a task (writing to a file) before I close the window. How can I do that AFTER I perform the required task in php? thnx
|
|
|
|
|
i think you can perform your task then send window.close() in the response
Help people,so poeple can help you.
|
|
|
|
|
You could use the code I posted in one of your above questions about submiting a form to a php file.
You would also probably want to use this function that I hacked together some time ago.
Basically, you can run the php script, then get a callback once it's done. In the call-back you'd just close the window of concern.
function myGetAjaxResponseWithCallback(target, url, callbackFunc)
{
AjaxRequest.get(
{
'url':url,
'onSuccess':function(req){ target.innerHTML=req.responseText; callbackFunc();}
}
);
}
I suppose a to use it you'd just
1) define a function named myCloseWindow, or whatever.
2) form the url based from the php script you wish to run, along with any arguments given to it
3) create an element on the page that will serve as a container for any response text returned (or just delete "target.innerHTML=req.responseText;" from the above function)
4) call myGetAjaxResponseWithCallback(target, url, myCloseWindow)
Alternately, you can avoid defining a function myCloseWindow (globally) and can do so thusly:
myGetAjaxResponseWithCallback(target, url, function(){** do whatever you want in here **});
I seem to remember using this method to process results of ajaxRequests as they came back in.
Best regards.
|
|
|
|
|