Jump to content

[SOLVED] edit article fields - how can i dedicate the id ?


redpedia

Recommended Posts

Hello

 

I've a problem , I've made a insert page and edit page for simple article, in the edit page , I've put a article name and edit , delete links

 

first problem is when i move the mouse above the edit link it gives this link in the IE status bar

 

http://localhost/news/edit_outputarticle.php?=0000000001

 

Why there is many of zeros ! , while i just have to records in the database !

 

Problem two , I've made an Output edit article page to edit the article fields , the problem is i can't dedicate to the code that i need article number 1 or 2 or 3 ... with where syntax .

 

here is the code

 

 

<?php

include "config.php";

$query=mysql_query("select * from article where id=");

$fetch=mysql_fetch_array($query);
?>

 

what should i put in where syntax here ?

 

thanks in advance

 

Link to comment
Share on other sites

Not sure what the zero's are for but you might want to fix that first. There should also be a name for the value.

http://localhost/news/edit_outputarticle.php?id=0000000001

 

As far a getting the id for your query

use this

<?php
include "config.php";
$id = $_GET['id'];
$query=mysql_query("select * from article where id='$id'");

$fetch=mysql_fetch_array($query);
?>

 

Ray

Link to comment
Share on other sites

add some error checking

<?php
include "config.php";
$id = $_GET['id'];
$query=mysql_query("select * from article where id='$id'") or die(mysql_error());

$fetch=mysql_fetch_array($query);
?>

 

Ray

 

 

Link to comment
Share on other sites

preg_match the id mate..

<?php
include "config.php";
$id =$_GET['id'];
if(preg_match("/[0-9]/",$id)){
$query=mysql_query("select * from article where id='$id'") or die(mysql_error());
$fetch=mysql_fetch_array($query);
}
?>

Link to comment
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.