Jump to content

Recommended Posts

Heres what I've got:

product.html?id={SOMENUMBER}

What I am trying for is to get the product url to look like this

product{SOMENUMBER}.html

and actually get the information based on that number from MySQL. I've tried a mod_rewrite that looks like this

RewriteEngine On
# mod_rewrite store directives
RewriteRule ^product-([0-9]).html$       index.php?%{QUERY_STRING}&page=product&id=$1   [PT,L]

 

I'm sure this is in the wrong area but who knows :( Any help would be appreciated :)

Link to comment
https://forums.phpfreaks.com/topic/64472-phpmysql-help/
Share on other sites

The first bit of code you wrote will produce a get variable and send it to product.html (Why not product.php?).  Here's what I'd do based on what I interpret what you are trying to do.

 

use a link to send a get variable to our page

 

<?php
echo "<a href='product.php?id=2">Product</a>"
?>

 

Then on the product.php page

 


<?php

IF (isset($_GET['id'])) {
    $id = $_GET['id'];
    $table = // whatever the table name is in your database.;
    $sql = "SELECT product FROM $table WHERE id ='$id'";
    $result = mysql_query($sql)or die(mysql_error());

    $row=mysql_fetch_assoc($result);
    echo $row['product'];
}

?>

       

 

 

Link to comment
https://forums.phpfreaks.com/topic/64472-phpmysql-help/#findComment-321409
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.