Current location: Hot Scripts Forums » Programming Languages » PHP » using ?id=$id from a mysql table in php


using ?id=$id from a mysql table in php

Reply
  #11 (permalink)  
Old 06-30-04, 02:08 PM
kasper's Avatar
kasper kasper is offline
Newbie Coder
 
Join Date: Jun 2004
Location: CA
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, I have a database with employee names, id numbers and crew id's, and rand_order()..
I am making a page so that admin can edit,delete,update,add employee info. and then have the ability to draw an employee "out of a hat" if you will, randomly.
the rand_order is for a "random" drawing from the database. that part is done, the add employee part is done, but i can't get the update/delete portion to work.
here is the sql dump:


# Host: localhost
# Generation Time: Jun 30, 2004 at 01:02 PM
# Server version: 4.0.16
# PHP Version: 4.1.2
#
# Database : `safety`
#

# --------------------------------------------------------

#
# Table structure for table `EmpInfo`
#

CREATE TABLE `EmpInfo` (
`ID` int(11) NOT NULL auto_increment,
`Employee` varchar(255) NOT NULL default '',
`EmployeeID` int(11) NOT NULL default '0',
`CrewID` int(11) NOT NULL default '0',
`rand_order` float default NULL,
PRIMARY KEY (`ID`,`EmployeeID`)
) TYPE=MyISAM AUTO_INCREMENT=276 ;


*************************
and here is the update.php code:
*************************

<?
include("dbinfo.inc.php");
$ID=$_GET['ID'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT Employee,EmployeeID,CrewID FROM EmpInfo WHERE ID=$ID";
$result=mysql_query($query);
$num=mysql_num_rows($result);
mysql_close();

$i=0;
while ($i < $num) {
$Employee=mysql_result($result,$i,"Employee");
$EmployeeID=mysql_result($result,$i,"EmployeeID");
$CrewID=mysql_result($result,$i,"CrewID");


?>

<form action="updated.php" method="post">
<input type="hidden" name="ud_ID" value="<? echo "$ID"; ?>">
Employee: <input type="text" name="ud_Employee" value="<? echo "$Employee"?>"><br>
Employee ID: <input type="text" name="ud_EmployeeID" value="<? echo "$EmployeeID"?>"><br>
Crew ID: <input type="text" name="ud_CrewID" value="<? echo "$CrewID"?>"><br>
<input type="Submit" value="Update">
</form>

<?
++$i;
}
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #12 (permalink)  
Old 06-30-04, 07:19 PM
kasper's Avatar
kasper kasper is offline
Newbie Coder
 
Join Date: Jun 2004
Location: CA
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Any Ideas IL?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #13 (permalink)  
Old 06-30-04, 07:38 PM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
Yeap

change
$ID=$_GET['ID'];
to
$ID=$_GET['id'];

array keys are case-senisitive.

for good measure also change this
$result=mysql_query($query)
to
$result=mysql_query($query) or die(mysql_error() . ':' . $query);

Hope that helps.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #14 (permalink)  
Old 09-16-10, 03:04 PM
coolbent016 coolbent016 is offline
New Member
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
using test_page.php?id=id

hello guys,i newbie here and i need help about my problem, i'm using test_page.php?id=id and i want to redirect to the 404 error page if the id was doesn't exist anymore, so please help me...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error when trying to create MySQL table via PHP HasansWeb PHP 5 05-19-11 07:59 AM
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 03:22 AM
Database table contents to email problem (PHP and MySQL) blokeofftheinternet PHP 2 04-29-04 10:34 AM
cant add more than 1 mysql table with php script chrisb62 PHP 1 04-27-04 05:00 AM
Newbie MySQL fccolon PHP 2 03-16-04 11:54 AM


All times are GMT -5. The time now is 07:03 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.