Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7596129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:50:41+00:00 2026-05-30T21:50:41+00:00

This is a rewrite of a question that was closed because it was too

  • 0

This is a rewrite of a question that was closed because it was too vague and I hadn’t inserted the code correctly. Hopefully this makes more sense.

I have a large SQL database containing ‘title’ and ‘author’. I’ve set up a query using PHP that will select only titles beginning with A – (title LIKE ‘A%’) – on one page:

$result = mysql_query("SELECT * FROM table WHERE (title LIKE 'A%') ORDER BY title ASC");

//fetch the data from the database
while ($row = mysql_fetch_array($result)) {
$DirPath = $row{'filename'};
//To get the innermost dir 'display just mp3'
$InnermostDir = basename(rtrim($DirPath, '/'));

echo "<tr><td align='justify'>";
echo $row{'title'} ;
echo "</td><td align='center'>";
echo $row{'author'} ;
echo "</td><td align='center'>";
echo $row{'publisher'} ;
echo "</td><td align='center'>";
echo $row{'pages'} ;
echo "</td><td align='center'>";
echo $row{'year'} ;
echo "</td><td align='center'>";
echo $row{'type'} ;
echo "</td><td align='center'>";
echo $row{'genre'} ;
echo "</td><td align='center'>";
echo $row{'location'} ;
echo "</td><td align='center'>";
echo $row{'id'} ;
echo "</td><td align='center'>";
echo $row{'shortauthor'} ;
echo "</td></tr>";
}
?>
</table>
<?php
//close the connection
mysql_close($dbhandle);
?>

http://sanctuary-westminster.org/library/epa.php

At the moment I’ve simply copied the page 25 time, where the only difference is that the letter changes (and the page title changes to reflect the letter), and then just use a simple a href=”epb.php” to join them together. So on the epb.php page:

$result = mysql_query("SELECT * FROM table WHERE (title LIKE 'B%') ORDER BY title ASC");

http://sanctuary-westminster.org/library/epb.php

This is a very long winded and unattractive approach, any changes require changing all the pages. I’ve tried using $letter instead of the link and have LIKE ‘A%’ be LIKE ‘$letter%’ instead:

$result = mysql_query("SELECT * FROM table WHERE (title LIKE 'row{'letter'}%') ORDER BY title ASC");

But that fails; it doesn’t give any error messages, the query is not happening as the input value is not correct, so nothing is being returned.
Hopefully that makes better sense and apologies for before.

(I’ve also looked at ways of using a dropdown menu where the “Submit” command stores the letter chosen from the options and then it’s used in the query, but when ever I look dropdown menus and SQL the only examples seem to relate to populating a menu with a table, not creating a query using one. Not sure if that would work better)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:50:42+00:00Added an answer on May 30, 2026 at 9:50 pm

    Have one page, titled lib.php and pass it an argument, like lib.php?letter=A

    Change your code to:

    $result = mysql_query("SELECT * FROM table WHERE (title LIKE '" . mysql_real_escape_string($_GET['letter']) . "%') ORDER BY title ASC");
    

    Now the same file, lib.php, can generate all the pages from before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to rewrite this messy code, so that I only make one
I have a really strong feeling that this question will either be closed or
I thought I would rewrite this question (same iteration). The original was how to
At this question: mod rewrite to remove file extension, add trailing slash, remove www
I think this is a pretty simple question. How do you an apache rewrite
How can I rewrite this code to check for all characters including the swedish
Can someone rewrite this javascript. The problem now is that 1 regex is only
I'm pretty sure that this is the right site for this question, but feel
I know from reading this Stackoverflow question that the complier will look at your
I'm sorry for this straightforward question that has doubtless been answered countless times on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.