Re: [PHP-DB] Displaying Results
Ethan Rosenberg wrote: Dear List - I have a form. In one field, the customer types the name of a product. The first seven(7) results of the MySQL query that the entry generates should be displayed as a clickable drop down list. How do I do it? Thanks. Ethan MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)] You said you have a form.. do have anything else. ;-).. ie, the mysql query etc.. (not sure what you are needing an answer to.. retrieving records from mysql, or how to display them) Anyway, I think you mean you want to have "7 option's in a select form element"? print ""; //Your loop of found records starts here print "$otherdbfield"; //Your loop ends here print ""; .. Me thinks we need more input.. maybe post the code that you have. Donovan -- D Brooke -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Displaying Results
Dear List - I have a form. In one field, the customer types the name of a product. The first seven(7) results of the MySQL query that the entry generates should be displayed as a clickable drop down list. How do I do it? Thanks. Ethan MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Displaying results from a query properly.
On Fri, Mar 24, 2006 at 04:19:10PM +, Alex Major wrote: > Hi there. > This isn't a major problem, more of a matter of aesthetics. > Basically, I have a query which pulls a list of usernames from the database > (based on their user level). > > These users should then listed in this fashion. > > Administrators: allydm, alex, mike, dave > Moderators: big 'd', frank, william > > However, the loop that I have returns the results like this... > > Administrators: allydm, alex, mike, dave, > Moderators: big 'd', frank, william, As an alternative to what the others have said you could use trim() also. Specifically the second, and optional, parameter. http://www.us2.php.net/trim --Greg -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Displaying results from a query properly.
On 24 March 2006 16:40, Alex Major wrote: > Thanks, works like a charm (had to make is -2 instead of -1 > as it added a > space after each result). Hadn't thought of something so simple. > > On 24/3/06 16:22, "Bastien Koert" <[EMAIL PROTECTED]> wrote: > > > Build it up as a string and remove the trailing comma at the end of > > the loop > > > > do { $sHTML .= ''.$administrators['username'].', ';} > > while ($administrators = mysql_fetch_assoc($administrators_result)) > > > > $sHTML = substr($sHTML, 0, strlen($sHTML)-1); You don't need a strlen() call here, as substr understands "count from the right" notation: $sHTML = substr($sHTML, 0, -1); ... or, with Alex's correction: $sHTML = substr($sHTML, 0, -2); Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Displaying results from a query properly.
Thanks, works like a charm (had to make is -2 instead of -1 as it added a space after each result). Hadn't thought of something so simple. Regards, Alex. On 24/3/06 16:22, "Bastien Koert" <[EMAIL PROTECTED]> wrote: > Build it up as a string and remove the trailing comma at the end of the loop > > do { $sHTML .= ''.$administrators['username'].', ';} > while ($administrators = mysql_fetch_assoc($administrators_result)) > > $sHTML = substr($sHTML, 0, strlen($sHTML)-1); > > echo $sHTML; > > ?> > > Bastien > > > >> From: Alex Major <[EMAIL PROTECTED]> >> To: >> Subject: [PHP-DB] Displaying results from a query properly. >> Date: Fri, 24 Mar 2006 16:19:10 + >> >> Hi there. >> This isn't a major problem, more of a matter of aesthetics. >> Basically, I have a query which pulls a list of usernames from the database >> (based on their user level). >> >> These users should then listed in this fashion. >> >> Administrators: allydm, alex, mike, dave >> Moderators: big 'd', frank, william >> >> However, the loop that I have returns the results like this... >> >> Administrators: allydm, alex, mike, dave, >> Moderators: big 'd', frank, william, >> >> There is a , after each username, including the last one in that list. I'm >> after a way of making the usernames display with a , after them, apart from >> the last username in that set of results. >> >> My current display code is: >> >> > do {echo ''.$administrators['username'].', ';} >> while ($administrators = mysql_fetch_assoc($administrators_result)) >> ?> >> >> How could I change to display the results in the fashion that I'd like? >> Many thanks for any suggestions. >> >> -- >> 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
RE: [PHP-DB] Displaying results from a query properly.
Build it up as a string and remove the trailing comma at the end of the loop do { $sHTML .= ''.$administrators['username'].', ';} while ($administrators = mysql_fetch_assoc($administrators_result)) $sHTML = substr($sHTML, 0, strlen($sHTML)-1); echo $sHTML; ?> Bastien From: Alex Major <[EMAIL PROTECTED]> To: Subject: [PHP-DB] Displaying results from a query properly. Date: Fri, 24 Mar 2006 16:19:10 + Hi there. This isn't a major problem, more of a matter of aesthetics. Basically, I have a query which pulls a list of usernames from the database (based on their user level). These users should then listed in this fashion. Administrators: allydm, alex, mike, dave Moderators: big 'd', frank, william However, the loop that I have returns the results like this... Administrators: allydm, alex, mike, dave, Moderators: big 'd', frank, william, There is a , after each username, including the last one in that list. I'm after a way of making the usernames display with a , after them, apart from the last username in that set of results. My current display code is: How could I change to display the results in the fashion that I'd like? Many thanks for any suggestions. -- 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] Displaying results from a query properly.
Hi there. This isn't a major problem, more of a matter of aesthetics. Basically, I have a query which pulls a list of usernames from the database (based on their user level). These users should then listed in this fashion. Administrators: allydm, alex, mike, dave Moderators: big 'd', frank, william However, the loop that I have returns the results like this... Administrators: allydm, alex, mike, dave, Moderators: big 'd', frank, william, There is a , after each username, including the last one in that list. I'm after a way of making the usernames display with a , after them, apart from the last username in that set of results. My current display code is: How could I change to display the results in the fashion that I'd like? Many thanks for any suggestions. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Displaying results from JOIN
Hello, With some help from the mysql list, I've been able to get this query working from the command line SELECT * FROM outings as o INNER JOIN pics AS p1 ON o.pic1_id=p1.pic_id INNER JOIN pics AS p2 ON o.pic2_id=p2.pic_id INNER JOIN pics AS p3 ON o.pic3_id=p3.pic_id INNER JOIN pics AS p4 ON o.pic4_id=p4.pic_id; But when I plug it in to my script ?php $result = mysql_query("SELECT * FROM outings as o INNER JOIN pics AS p1 ON o.pic1_id=p1.pic_id INNER JOIN pics AS p2 ON o.pic2_id=p2.pic_id INNER JOIN pics AS p3 ON o.pic3_id=p3.pic_id INNER JOIN pics AS p4 ON o.pic4_id=p4.pic_id",$db) or die(mysql_error()); if ($myrow = mysql_fetch_array($result)) { do { print "; } while ($myrow = mysql_fetch_array($result)); } ?> It will display only one of the paths not all four. I think I have to somehow alias in the SELECT part of the query, but I haven't been able to figure out how. Thanks in advance for the help, Mike --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.330 / Virus Database: 184 - Release Date: 2/28/02 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php