Jump to content

Select rows using title rather than ID?


jmd87

Recommended Posts

Hi,
Currently I have the below code which grabs the tables and the correct row when i load my website using my row ID (for example: mydomain.com/page.php?ID=1)
What I would like it to do is rather than put a number in that I can put the page title in so its displayed like this:
Mydomain.php?ID=Home
How can I do this please? As I can change this:
SELECT * FROM system_setup, menu_item JOIN dow ON dow.id_content = menu_item.id WHERE id = %s
to:
SELECT * FROM system_setup, menu_item JOIN dow ON dow.id_content = menu_item.id WHERE title = %s
but what it does is I can now type in "Mydomain.php?ID=Home" but if I move to another page like "Mydomain.php?ID=contact" it just shows the home page content not the contact content if that makes sense?
Can any help please?
$maxRows_DetailRS1 = 10;$pageNum_DetailRS1 = 0;if (isset($_GET['pageNum_DetailRS1'])) {  $pageNum_DetailRS1 = $_GET['pageNum_DetailRS1'];}$startRow_DetailRS1 = $pageNum_DetailRS1 * $maxRows_DetailRS1; $colname_DetailRS1 = "-1";if (isset($_GET['ID'])) {  $colname_DetailRS1 = $_GET['ID'];}mysql_select_db($database_design_online_connection, $design_online_connection);$query_DetailRS1 = sprintf("SELECT * FROM system_setup, menu_item JOIN dow ON dow.id_content = menu_item.id WHERE id = %s", GetSQLValueString($colname_DetailRS1, "int"));$query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1);$DetailRS1 = mysql_query($query_limit_DetailRS1, $design_online_connection) or die(mysql_error());$row_DetailRS1 = mysql_fetch_assoc($DetailRS1); if (isset($_GET['totalRows_DetailRS1'])) {  $totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];} else {  $all_DetailRS1 = mysql_query($query_DetailRS1);  $totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1);}$totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1;
Kind Regards
Joe
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...