i'm new in php, and i'm making my first db driven site.
it's something similar to "news" cms concept.
i made pages for uploading images, and inserting data into db table.
it works.
now i'm making a page where i want to display that content.
here, i need some hints.
i want to display only titles stored in one row of table, and make them to be a links to page that will show other content about that title.
can someone help me, or
is there some good tutorial where i can see how to do this?
thanks in advance

8 Years
Discussion Span
Last Post by overwise

Show us how your data is stored and which pages you have (not complete code, unless pertinent!)


ok, pages i already made:

- add.html (html forms)

- submit.php
connection to db and than:

if(isset($_POST['submit'])) {

if ($model == "" || $opis == "" || $ime == "" || $email == "" || $file  == "" ){
echo "Niste uneli sve obavezne podatke. \n <a href='java script:history.go(-1)'>Vratite se na prethodnu stranu.</a>";
else {
$max_filesize = 262144;
 if(filesize($_FILES['file']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.');
else {
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
if ($file) 
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))	
echo '<h1>Unknown extension!</h1>';

else {
$uploads = dirname(__FILE__)."/slike_oglasi/";
$filename = rand(1000,99000).$_FILES['file']['name'];
copy($_FILES['file']['tmp_name'],$uploads.$filename) or die("Greška! Slika nije poslata. <a href='java script:history.go(-1)'>Nazad</a>");
$sql=mysql_query("INSERT INTO `proba` VALUES ('', '$model', '$opis', '$ime', '$telefon', '$email', '$filename','$datum')") or die(mysql_error()); 
echo "Vaš oglas je postavljen. Hvala";

and inserted data is sent in db that contains 8 raws:
id, model, opis, ime, telefon, email, filename and datum

this 2 pages are ok, data is properly inserted in table.

now, index.php
i didn't create this code still, but i think i can handle it. this page will show list of values from "model" row, but what i don't know is- is it possible to make that values (models) to be links to the page called models.php? this page would show other values for wanted model. also, how to send information to models.php what particular model to show.


OK, before I give you more hints, what type of models are you talking about here? Cars, women? I'm not comfortable with something about the latter.


i'm just getting in php, it's practice and there is no real meaning, it's not for particular website. just learning and testing my ability.


You can retrieve data from the DB to produce a series of links.

Here's some pseudocode
$r = result of select query
loop through the resultset
extract the modelname and id values
build the links: <a href="model.php?id=<?php echo $data;?>"><?php echo $data;?></a>

Your model.php page can display dynamic data based on the 'id':

$id = $_GET;
run a query to extract the data based on that id value, e.g.

"SELECT * FROM table WHERE id = $id"

when code works, i feel like wizard, and i'm happy like a child.
thnx again!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.