trouble transfering results

  • (2 Pages)
  • +
  • 1
  • 2

24 Replies - 1010 Views - Last Post: 15 June 2009 - 03:21 PM Rate Topic: -----

#1 openinfinity  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 215
  • Joined: 25-March 09

trouble transfering results

Posted 15 June 2009 - 09:20 AM

Having trouble transfering results from one page to another I've tried two technique's that I have found but none have been successfull

while($row = mysql_fetch_array($result))
  {
$id = $row['id'];
$compname = $row['compname'];
$assetnum = $row['assetnum'];
$model = $row['model'];
$cuser = $row['cuser'];
$location = $row['location'];
$warranty = $row['warranty'];
$os = $row['os'];
$ipaddr = $row['ipaddr'];
$mem = $row['mem'];
$serial = $row['serial'];
$notes = $row['notes'];

  echo "<table width=75% align=left border=2>
		<tr bgcolor=#045FB4><th>Computer name</th>
		<th>Asset Number</th>
		<th>Model</th>
		<th>Current User</th>
		<th>Location</th>
		<th>Warranty</th>
		<th>Operating System</th>
		<th>IP address</th>
		<th>Memory</th>
		<th>Serial</th></tr>"; 
 
  echo "<tr><td><input type=\"text\" name=\"compname\" value=\"$compname\" size=\"10\" readonly=\"readonly\"/></td>";
  echo "<td> <input type=\"text\" name=\"assetnum\" value=\"".$row['assetnum']."\" size=\"6\" readonly=\"readonly\"/></td>";
  echo "<td> <input type=\"text\" name=\"model\" value=\"".$row['model']."\" size=\"10\" readonly=\"readonly\"/</td>";
  echo "<td> <input type=\"text\" name=\"cuser\" value=\"".$row['cuser']."\" size=\"10\" readonly=\"readonly\"/></td>";
  echo "<td> <input type=\"text\" name=\"location\" value=\"".$row['location']."\" size=\"10\" readonly=\"readonly\"/></td>";
  echo "<td><input type=\"text\" name=\"warranty\" value=\"".$row['warranty']."\" size=\"8\" readonly=\"readonly\"/></td>";  
  echo "<td> <input type=\"text\" name=\"os\" value=\"".$row['os']."\" size=\"10\" readonly=\"readonly\"/>";
  echo "<td> <input type=\"text\" name=\"ipaddr\" value=\"".$row['ipaddr']."\" size=\"10\" readonly=\"readonly\"/></td>";
  echo "<td> <input type=\"text\" name=\"mem\" value=\"".$row['mem']."\" size=\"6\" readonly=\"readonly\"/></td>";
  echo "<td> <input type=\"text\" name=\"serial\" value=\"".$row['serial']."\" size=\"8\" readonly=\"readonly\"/></td>"; 

echo "  <a href=\"edit.php?compnam=\"".$row['compname']."\">";

 echo "<a href=\"edit.php?id=$id&compname=$compname&assetnum=$assetnum&model=$model&cuser=$cuser&location=$location&warranty=$warranty&os=$os&ipaddr=$ipaddr&mem=$mem&serial=$serial&notes=$notes\">$id</a>";
  }

mysql_free_result($result); 
}
?>
</body>
</html>




<body>
<?php $_REQUEST['compname'];?>

<form method="post" action="editdb.php"> 

	<input type="submit" value="Edit">

	<input type="submit" value="Save">

	<input type="submit" value="Print"> 


<div id="datafield">
Computer Name<br />
<input type=text name=compname size=10 maxlength=100 value="<?php $_REQUEST['compname'];?>">
&nbsp;&nbsp;&nbsp;
<input type=text name=assetnum size=10 maxlength=100 value="<?php echo $assetnum;?>" />
&nbsp;&nbsp;&nbsp;
<input type=text name=model size=10 maxlength=100 value="<?php echo $model;?>" />
<br /><br />
&nbsp;&nbsp;&nbsp;
<input type=text name=cuser size=10 maxlength=100 value="<?php echo $cuser;?>" />
&nbsp;&nbsp;&nbsp;
<input type=text name=location size=10 maxlength=100 value="<?php echo $location;?>" />
&nbsp;&nbsp;&nbsp;
<input type=text name=warranty size=10 maxlength=100 value="<?php echo $warranty;?>" />
<br /><br />
&nbsp;&nbsp;&nbsp;
<input type=text name=os size=10 maxlength=100 value="<?php echo $os;?>" />
&nbsp;&nbsp;&nbsp;
<input type=text name=ipaddr size=10 maxlength=100 value="<?php echo $ipaddr;?>" />
&nbsp;&nbsp;&nbsp;
<input type=text name=mem size=10 maxlength=100 value="<?php echo $mem;?>" />
&nbsp;&nbsp;&nbsp;
<input type=text name=serial size=10 maxlength=100 value="<?php echo $serial;?>" />
<br /><br /><br /><br />Notes<br />
<textarea cols=80 rows=15 name=notes value="><?php echo $notes;?>"> 
</textarea>
</form></div>






</body>
</html>




any help greatly appreciated

Is This A Good Question/Topic? 0
  • +

Replies To: trouble transfering results

#2 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: trouble transfering results

Posted 15 June 2009 - 09:32 AM

You are going to probably want to utilize a simple PHP session ...

at the very top of your page before ANY HTML add

<?php 
   session_start();
?>



than change
$id = $row['id'];
$compname = $row['compname'];
$assetnum = $row['assetnum'];
$model = $row['model'];
$cuser = $row['cuser'];
$location = $row['location'];
$warranty = $row['warranty'];
$os = $row['os'];
$ipaddr = $row['ipaddr'];
$mem = $row['mem'];
$serial = $row['serial'];
$notes = $row['notes'];



to

$id = $_SESSION['id'] = $row['id'];
$compname = $_SESSION['compname'] = $row['compname'];
$assetnum = $_SESSION['assetnum'] = $row['assetnum'];
$model = $_SESSION['model'] = $row['model'];
$cuser = $_SESSION['cuser'] = $row['cuser'];
$location = $_SESSION['location'] = $row['location'];
$warranty = $_SESSION['warranty'] = $row['warranty'];
$os = $_SESSION['os'] = $row['os'];
$ipaddr = $_SESSION['ipaddr'] = $row['ipaddr'];
$mem = $_SESSION['mem'] = $row['mem'];
$serial = $_SESSION['serial'] = $row['serial'];
$notes =$_SESSION['notes'] =  $row['notes'];



than in your HTML echo the session var

<input type=text name=compname size=10 maxlength=100 value="<?php echo $_SESSION['compname'];?>">
<!-- continue with the rest of your form -->



you could also maybe utilize JQuery and create a form onclick would be cleaner and have a bit of eye candy instead of changing pages or make the first page a form itself and submit to the second page thereby bypassing the need for session vars

EDIT:
I also just saw this ....
echo "<a href=\"edit.php?id=$id&compname=$compname&assetnum=....


you could do a second DB pull based on the global $_GET and not have to transfer anything at all ... just re fill the fetch_array

This post has been edited by RPGonzo: 15 June 2009 - 09:36 AM

Was This Post Helpful? 0
  • +
  • -

#3 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3098
  • View blog
  • Posts: 10,883
  • Joined: 08-August 08

Re: trouble transfering results

Posted 15 June 2009 - 09:33 AM

Why not use a session variable and just send the whole array?
<?php
session_start();

// some code here...

$row = mysql_fetch_array($result);

$_SESSION['row'] = $row;
// then post or link to another page...

?>


Receiving page:

<?php
session_start();
$row = $_SESSION['row'];
// Do your stuff...


This post has been edited by CTphpnwb: 15 June 2009 - 09:33 AM

Was This Post Helpful? 0
  • +
  • -

#4 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: trouble transfering results

Posted 15 June 2009 - 09:36 AM

Yea im doing things the hard way today CT so :P
Was This Post Helpful? 0
  • +
  • -

#5 openinfinity  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 215
  • Joined: 25-March 09

Re: trouble transfering results

Posted 15 June 2009 - 09:42 AM

Thanks for the reply's you guy's are awesome I know I am going to have to use a session because I will have logins was just trying to get the base structure built first guess I may work on building the login page now. I saw a connector phpAD I want to try to use.

I'll have to investigate the jquery. ideally I want a sized popup with the data in fields for editing.

I know with the sized pop-up I would need javascript I had trouble combinding the javascript and php.
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3098
  • View blog
  • Posts: 10,883
  • Joined: 08-August 08

Re: trouble transfering results

Posted 15 June 2009 - 09:42 AM

Well, you beat me to it anyway!

@openinfinity,
Try to remember that this:
echo $row['compname'];

is easier than:
$compname = $row['compname'];
echo $compname;

especially when $row contains a lot of data!
Was This Post Helpful? 0
  • +
  • -

#7 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: trouble transfering results

Posted 15 June 2009 - 09:43 AM

Why a popup when with JQuery you can create a form on the fly ... similiar to the 'Quick Edit' with these forums ... quite simple :)
Was This Post Helpful? 0
  • +
  • -

#8 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3098
  • View blog
  • Posts: 10,883
  • Joined: 08-August 08

Re: trouble transfering results

Posted 15 June 2009 - 09:52 AM

Yes, and avoid popups. They're a great way to encourage people to use somebody else's site!
Was This Post Helpful? 0
  • +
  • -

#9 openinfinity  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 215
  • Joined: 25-March 09

Re: trouble transfering results

Posted 15 June 2009 - 10:02 AM

View PostCTphpnwb, on 15 Jun, 2009 - 08:42 AM, said:

Well, you beat me to it anyway!

@openinfinity,
Try to remember that this:
echo $row['compname'];

is easier than:
$compname = $row['compname'];
echo $compname;

especially when $row contains a lot of data!


I had it the previous way then I was tryinbg to follow an example so I tried there way. I will remember this

thanks


View PostCTphpnwb, on 15 Jun, 2009 - 08:52 AM, said:

Yes, and avoid popups. They're a great way to encourage people to use somebody else's site!



it's for an internal web site for keeping track of our computers I'm a desktop-support-gimp wanabe developer my boss said I could build a system to keep track of the computers and keep logs and stuff because right now it's on an excell sheet that is not kept up.

so this is really great experience for me and I think I can put together something cool that may help me get out of the rut im in
Was This Post Helpful? 0
  • +
  • -

#10 openinfinity  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 215
  • Joined: 25-March 09

Re: trouble transfering results

Posted 15 June 2009 - 10:08 AM

View PostRPGonzo, on 15 Jun, 2009 - 08:43 AM, said:

Why a popup when with JQuery you can create a form on the fly ... similiar to the 'Quick Edit' with these forums ... quite simple :)



I'll definitely check out the jquery every day I find 20 new things to learn :)
Was This Post Helpful? 0
  • +
  • -

#11 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3098
  • View blog
  • Posts: 10,883
  • Joined: 08-August 08

Re: trouble transfering results

Posted 15 June 2009 - 10:12 AM

View Postopeninfinity, on 15 Jun, 2009 - 01:02 PM, said:

quote name='CTphpnwb' post='674608' date='15 Jun, 2009 - 08:52 AM']
Yes, and avoid popups. They're a great way to encourage people to use somebody else's site!

it's for an internal web site for keeping track of our computers I'm a desktop-support-gimp wanabe developer my boss said I could build a system to keep track of the computers and keep logs and stuff because right now it's on an excell sheet that is not kept up.

so this is really great experience for me and I think I can put together something cool that may help me get out of the rut im in
[/quote]
That's another reason to avoid popups. You want this to be liked by the users so that your boss thinks you did a good job!
Was This Post Helpful? 0
  • +
  • -

#12 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: trouble transfering results

Posted 15 June 2009 - 10:27 AM

View Postopeninfinity, on 15 Jun, 2009 - 09:02 AM, said:

it's for an internal web site for keeping track of our computers I'm a desktop-support-gimp wanabe developer my boss said I could build a system to keep track of the computers and keep logs and stuff because right now it's on an excell sheet that is not kept up.

so this is really great experience for me and I think I can put together something cool that may help me get out of the rut im in


Sounds like me ... im in the internal IT Dept. for our ompany and i did the EXACT same thing with our old access db, i actually built a PHP version as well as a .NET version to interact with this MySQL DB now :)
Was This Post Helpful? 0
  • +
  • -

#13 openinfinity  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 215
  • Joined: 25-March 09

Re: trouble transfering results

Posted 15 June 2009 - 10:36 AM

View PostCTphpnwb, on 15 Jun, 2009 - 09:12 AM, said:

View Postopeninfinity, on 15 Jun, 2009 - 01:02 PM, said:

quote name='CTphpnwb' post='674608' date='15 Jun, 2009 - 08:52 AM']
Yes, and avoid popups. They're a great way to encourage people to use somebody else's site!

it's for an internal web site for keeping track of our computers I'm a desktop-support-gimp wanabe developer my boss said I could build a system to keep track of the computers and keep logs and stuff because right now it's on an excell sheet that is not kept up.

so this is really great experience for me and I think I can put together something cool that may help me get out of the rut im in

That's another reason to avoid popups. You want this to be liked by the users so that your boss thinks you did a good job!
[/quote]

so would you recommend the edit page load on the same page? I was thinking when you searched if a user has two computers or you search by dept you get a couple rows and you click the details to the right you would then have an option of updating the record and there will also be a notes field for loging maintenece I think the notes field would be two big for the row so I was going to have that appear in the details window something like this

Posted Image


thanks again for the advice
Was This Post Helpful? 0
  • +
  • -

#14 openinfinity  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 215
  • Joined: 25-March 09

Re: trouble transfering results

Posted 15 June 2009 - 10:43 AM

View PostRPGonzo, on 15 Jun, 2009 - 09:27 AM, said:

View Postopeninfinity, on 15 Jun, 2009 - 09:02 AM, said:

it's for an internal web site for keeping track of our computers I'm a desktop-support-gimp wanabe developer my boss said I could build a system to keep track of the computers and keep logs and stuff because right now it's on an excell sheet that is not kept up.

so this is really great experience for me and I think I can put together something cool that may help me get out of the rut im in


Sounds like me ... im in the internal IT Dept. for our ompany and i did the EXACT same thing with our old access db, i actually built a PHP version as well as a .NET version to interact with this MySQL DB now :)




Do you use Active directory authintication? I was curious as to how to keep track of who edits the changes to the MYSQL DB not sure if they would need a sql account or if the changes would be tracked through there login?
Was This Post Helpful? 0
  • +
  • -

#15 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: trouble transfering results

Posted 15 June 2009 - 10:48 AM

Ill show you a quick SS of how mine is set up ... but i just made the ticket editable as soon as you pulled it up ... this is from one of the original versions ... now i have JQuery doing the form on the fly

Posted Image
Posted Image

again just examples

You can sync with the AD but its a pain .. because AD is stored via a Access DB on the server ... i just don't like Access so i made a simple user table with the same credentials as the AD and set user permissions accordingly
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2