Hello there!
Thank you for your reply valerik but i'm a newb and i don;t know how to develop that code you gived.
What i need is a a way to edit/update a row via an html/php form. To explain better i'll give an example:
I have a php page that retrieves datas from db. At that page i have a link that offer the delete option for the respective row and i need to have another link that offers me a way to edit that row.
The delete link, when i click on it, redirects me on a delete.php?delete=true?id=$id page where $id is a number that the delete.php page recognize when i clicked on the row that i want to delete. Working with $_GET[ID].
In the same wai, i need a page that offers me a way to modify a db row that is listed on the showpage.
What i have now is this mess :
edit.php
PHP Code:
<?php
session_start();
if(!isset($_SESSION['loggedin'])) {
header('Location: '.$domain.'index.php?error=1');
exit();
}
?>
<?php
include 'D:/Program Files/VertrigoServ/www/live/admini/includet/variabla.php';
include (BPATH_ADM . 'includet/dbconfig.php');
include (BPATH_ADM . 'includet/dblidhja.php');
$query="SELECT * FROM ndeshje";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$id=mysql_result($result,$i,"ID");
$ndeshja=mysql_result($result,$i,"ndeshja");
$ora=mysql_result($result,$i,"ora");
$kodi=mysql_result($result,$i,"kodi");
$data=mysql_result($result,$i,"data");
$menyra=mysql_result($result,$i,"menyra");
$sporti=mysql_result($result,$i,"sporti");
$permalink=mysql_result($result,$i,"permalink");
?>
<form method="post" name="shtondeshje" action="modulet/ndeshje/p.edit.php">
<p><label for="ndeshja">Ndeshja : <input name="ndeshja" type="text" id="ndeshja" value="<?php echo $ndeshja; ?>" size="50" maxlength="255" />
</label></p>
<p><label for="menyra">Permalink : <input name="menyra" type="text" id="menyra" value="<?php echo $permalink; ?>" size="50" maxlength="255" />
</label>
<p>
<label for="sporti">Sporti :
<select name="sporti" id="sporti">
<option value="/imazhet/ikona/football.gif" selected="selected">Football</option>
<option value="/imazhet/ikona/basketball.gif">Basketball</option>
<option value="/imazhet/ikona/baseball.gif">Baseball</option>
<option value="/imazhet/ikona/tennis.gif">Tennis</option>
<option value="/imazhet/ikona/motorsports.gif">Motorsports</option>
<option value="/imazhet/ikona/cycling.gif">Cycling</option>
<option value="/imazhet/ikona/cricket.gif">Cricket</option>
<option value="/imazhet/ikona/americanfootball.gif">American Football</option>
<option value="/imazhet/ikona/other.gif">Other</option>
</select>
</label>
</p>
<p><label for="ora">Ora : <input name="ora" type="text" id="ora" value="<?php echo $ora; ?>" />
</label>
</p>
<p><label for="data">Data : <input name="data" type="text" id="data" value="<?php echo $data; ?>" />
</label>
</p>
<p><label for="menyra">Menyra : <input name="menyra" type="text" id="menyra" value="<?php echo $menyra; ?>" />
</label>
</p>
<p><label for="kodi">Kodi : <textarea name="kodi" cols="50" rows="8" id="kodi"> <?php echo $kodi; ?></textarea>
</label></p>
<p><input class="buton" type="submit" name="submit" value="Modifikoje" /> <input class="buton" type="reset" name="reset" value="Rifillo" /></p>
</form>
<?php
if (isset($_GET['error']) AND !empty($_GET['error']))
{
echo 'Ndodhi nje Gabim. Provoje Serish';
echo '<form><input type="button" class="buton" value="Kthehu Mbrapa"
ONCLICK="history.go(-1)"></form>';
}
?>
p.edit.php
PHP Code:
<?php
session_start();
if(!isset($_SESSION['loggedin'])) {
header('Location: '.$domain.'index.php?error=1');
exit();
}
?>
<?php
include 'D:/Program Files/VertrigoServ/www/live/admini/config.php';
$ndeshja = $_POST['ndeshja'];
$ora = $_POST['ora'];
$data = $_POST['data'];
$kodi = $_POST['kodi'];
$menyra = $_POST['menyra'];
// $permalink = preg_replace("#[^a-z0-9\-]#i", "", str_replace(" ", "_", strtolower($ndeshja))); - Nese dua linkun me shkronja te vogla
$permalink = preg_replace("#[^a-z0-9\-_]#i", "",str_replace(' ', '_', $ndeshja));
$db = mysql_connect($dbHost,$dbUser,$dbPass);
mysql_select_db($dbname,$db);
$sql="INSERT INTO ndeshje (`ndeshja`, `ora`, `data`, `kodi`, `menyra`, `permalink`, `sporti` ) VALUES ('$ndeshja', '$ora', '$data', '$kodi', '$menyra', '$permalink', '$sporti')";
// mysql_query($sql, $db) or die('Gabim! Shtimi i ndeshjes deshtoi.');
mysql_query($sql, $db) or die('Gabim! Shtimi i ndeshjes deshtoi.<br / > ' . mysql_error());
mysql_close();
ob_start();
header('Location: '.$domain.'admin.php?sukses=1');
ob_flush();
?>
When i manually load the edit.php page, it loads the values for the first entry on the database :P ... i tried to access edit.php?id=44 (where 44 is an id on my db) and nothing happens; the page loads the first id on the db :P
Can you help me?
Thank you in advance!