Code Comments
Programming Forum and web based access to our favorite programming groups.Hi, I am working on a Perl script which queries a MySQL table and displays the results in a table in the web page. Everything works fine, but I would like to get a message if the query does not return anything. The MySQL table contains books in a library. For examply, if I do a search by ISBN and choose 3333 as keyword (suppose there is no such ISBN number in the ISBN field), the result of the query is null; however I would like to display a message. Thank you.
Post Follow-up to this messageIn article <bX0ob.7046$Tf.878203@news20.bellglobal.com>, DM wrote: >Hi, > >I am working on a Perl script which queries a MySQL table and displays the >results in a table in the web page. Everything works fine, but I would like >to get a message if the query does not return anything. > >The MySQL table contains books in a library. For examply, if I do a search >by ISBN and choose 3333 as keyword (suppose there is no such ISBN number in >the ISBN field), the result of the query is null; however I would like to >display a message. Thank you for telling us what you're doing and how you want it to work. Of course, we're missing a few key pieces of information, like what you actually want anyone to -do- about it, how much you're willing to pay to have anything done (if you indeed do want someone to do anything), or if you just want information how much you're willing to pay for that, etc. But thanks for updating us on the status of your project. I know we're all short enough on things to read that we didn't at all mind the gratuitous explanation. :) -- Vorxion - Member of The Vortexa Elite
Post Follow-up to this messageDM (dm@nospam.com) wrote: : Hi, : I am working on a Perl script which queries a MySQL table and displays the : results in a table in the web page. Everything works fine, but I would lik e : to get a message if the query does not return anything. : The MySQL table contains books in a library. For examply, if I do a search : by ISBN and choose 3333 as keyword (suppose there is no such ISBN number i n : the ISBN field), the result of the query is null; however I would like to : display a message. I don't know your variables and etc, so I can only show pseudo code, but what about something like if no_results_found then print "<font color:red>Not found</font>"; end if;
Post Follow-up to this messageIn article <3fa15be2@news.victoria.tc.ca>, Malcolm Dew-Jones wrote: >DM (dm@nospam.com) wrote: >: Hi, > >: I am working on a Perl script which queries a MySQL table and displays th e >: results in a table in the web page. Everything works fine, but I would li ke >: to get a message if the query does not return anything. > >: The MySQL table contains books in a library. For examply, if I do a searc h >: by ISBN and choose 3333 as keyword (suppose there is no such ISBN number in >: the ISBN field), the result of the query is null; however I would like to >: display a message. > >I don't know your variables and etc, so I can only show pseudo code, but >what about something like > > > > if no_results_found > then > print "<font color:red>Not found</font>"; > end if; Non-sarcastically (boy, he hit me wrong last night!), I don't think that's his problem. I was betting that he doesn't know how to check for a failed lookup from MySQL. That's how the post hit me. This is a poster child for how -not- to ask for help. Hell, send -him- to the Indian or Russian programmers! :) -- Vorxion - Member of The Vortexa Elite
Post Follow-up to this messageWell... that's what I was thinking of, but I was not sure how to implement "no_results_found"... Actually I just thought of something... I'll try it tomorrow, too late now, time to go to bed :) "Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message news:3fa15be2@news.victoria.tc.ca... > DM (dm@nospam.com) wrote: > : Hi, > > : I am working on a Perl script which queries a MySQL table and displays the > : results in a table in the web page. Everything works fine, but I would like > : to get a message if the query does not return anything. > > : The MySQL table contains books in a library. For examply, if I do a search > : by ISBN and choose 3333 as keyword (suppose there is no such ISBN number in > : the ISBN field), the result of the query is null; however I would like to > : display a message. > > I don't know your variables and etc, so I can only show pseudo code, but > what about something like > > > > if no_results_found > then > print "<font color:red>Not found</font>"; > end if; >
Post Follow-up to this messageIn article <jXkob.8840$Tf.1070415@news20.bellglobal.com>, DM wrote:
>Well... that's what I was thinking of, but I was not sure how to implement
>"no_results_found"...
Assuming you're being smart and using DBI and DBD::mysql, try:
if ($db_sth->rows == 0) {
# We had no matching rows, do whatever
}
perldoc DBI
perldoc DBD::mysql
It's all right there.
$75 - answer
$100 - not RTFM before asking
Total: $175
--
Vorxion - Member of The Vortexa Elite
Post Follow-up to this messageThank you.
"Vorxion" <vorxion@knockingshopofthemind.com> wrote in message
news:3fa29b52$1_1@news.iglou.com...
> In article <jXkob.8840$Tf.1070415@news20.bellglobal.com>, DM wrote:
implement
>
> Assuming you're being smart and using DBI and DBD::mysql, try:
>
> if ($db_sth->rows == 0) {
> # We had no matching rows, do whatever
> }
>
> perldoc DBI
> perldoc DBD::mysql
>
> It's all right there.
>
> $75 - answer
> $100 - not RTFM before asking
>
> Total: $175
>
> --
> Vorxion - Member of The Vortexa Elite
Post Follow-up to this messageVorxion (vorxion@knockingshopofthemind.com) wrote:
: In article <jXkob.8840$Tf.1070415@news20.bellglobal.com>, DM wrote:
: >Well... that's what I was thinking of, but I was not sure how to implemen
t
: >"no_results_found"...
Assuming you're being smart and using DBI and DBD::mysql, try:
perldoc DBI
: if ($db_sth->rows == 0) {
: # We had no matching rows, do whatever
: }
: perldoc DBI
: perldoc DBD::mysql
: It's all right there.
: $75 - answer
: $100 - not RTFM before asking
: Total: $175
: --
: Vorxion - Member of The Vortexa Elite
--
Post Follow-up to this messageIn article <3fa42e9f@news.victoria.tc.ca>, Malcolm Dew-Jones wrote: >Vorxion (vorxion@knockingshopofthemind.com) wrote: >: In article <jXkob.8840$Tf.1070415@news20.bellglobal.com>, DM wrote: >: >Well... that's what I was thinking of, but I was not sure how to impleme nt >: >"no_results_found"... > >Assuming you're being smart and using DBI and DBD::mysql, try: > >perldoc DBI We're -such- bastards. We expect people to RTFM. :) I think we should put a moratorium on helping anyone who isn't willing to pay, period. It's not alt.comp.perlcgi.helpdesk, you know. And then, they not only don't want to pay, they don't want to bother reading the docs. Do the words, "Sod off!" mean anything to them, you think? -- Vorxion - Member of The Vortexa Elite
Post Follow-up to this messageVorxion <vorxion@knockingshopofthemind.com> wrote: > We're -such- bastards. We expect people to RTFM. :) That's what TFM is for, methinks. > I think we should put a moratorium on helping anyone who isn't willing to > pay, period. It's not alt.comp.perlcgi.helpdesk, you know. The part that has always concerned me when "helping" someone who obviously has no business writing apps that are exposed to the world is that one day the inevitable crack will happen, and it will be one that was preventable had the employer/school/dad's buddy from work/whatever simply accepted that he could only expect professional results if he were to hire a professional. > And then, they not only don't want to pay, they don't want to bother > reading the docs. Which is why learning the hard way is in their best interest. If falling didn't hurt, none of us would have bothered learning to walk. > Do the words, "Sod off!" mean anything to them, you > think? Nope. They'll repost, and repost, then massively cross-post, until finally someone gives an almost accurate answer, then cry about how unfriendly we are. -- Art Sackett, Patron Saint of Drunken Fornication
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.