mercredi 7 février 2018

change php dynamic pages url

i just started learning php and i created a simple php website which contains posts, users.. and i made posts links looks like : http://localhost/?post=3
my question is there any way to make the url looks differents like http://localhost/post/252155, without creating php pages for it.

my code

$results = mysqli_query($conn, "SELECT * FROM projects");
$project = array();
if (mysqli_num_rows($results) > 0) {
    while($row = mysqli_fetch_assoc($results)){
        $project[] = $row;
    }
}

$projects = 0;
$maxprojects = 14;
while ($projects < $maxprojects) {
    $projectId = $project[$projects]["project_id"];
    $projectURL = "../basic/?project=".$projectId ;
    $projectTitle = $project[$projects]["project_title"];
    $projectThumb = $project[$projects]["project_thumbnail"];
    $projectPrice = $project[$projects]["project_price"];
    echo "
        <li class='gig'>
            <div class='gig-content'>
                <span class='thumbnail'>
                    <a href='$projectURL'><img src='".$projectThumb."'></a>
                </span><!-- Gig Thumbnail -->
                <span class='title'>
                    <h2><a href='$projectURL'>".$projectTitle."</a></h2>
                </span><!-- Gig Title -->
                <div class='meta'>
                    <span class='price'>
                        <h1>".$projectPrice."$</h1>
                        <h4>Startin at</h4>
                    </span><!-- price -->
                </div>
            </div>
        </li><!-- Gig -->
    ";
    ++$projects;
}

thanks in advance!




Aucun commentaire:

Enregistrer un commentaire