in reply to Q & A
2nd case:my $statement = $dbh->prepare( "SELECT Questions, ID from QA;" ); $statement->execute(); my ($question, $id); $statement->bind_columns( \$question, \$id ); print "<ul>\n"; while ($statement->fetch) { print qq` <li><a href="[script_name]?case=2&id=$id">$question</li>` }
The script calls itself, passing the ID of the question selected. This way both output pages will have the same format, regardless of future changes made, without having to update multiple files. Using fetch() also retrieves the information one line at a time, so your query won't give you a 10gig hash (as Ovid pointed out).my $id = $cgi->param( 'id' ); my $statement = $dbh->prepare( qq`SELECT Questions, Answers from QA wh +ere ID = "$id";` ); $statement->execute(); my ($question, $answer); $statement->bind_columns( \$question, \$answer ); while ($statement->fetch) { print qq` <h2>$question</h2> <p>$answer</p>` }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Q & A
by repson (Chaplain) on Dec 15, 2000 at 10:46 UTC |