Jump to content

not passing all variables


shroder300

Recommended Posts

I am new to this site and php in general. I made a database a few years ago and it has been working fine ever since. I have recently needed to add a variable that I need to pass.

[code]
$s = $HTTP_GET_VARS["sort"];
$id = $HTTP_GET_VARS["id"];
$i_order = $HTTP_GET_VARS["i_order"];
[/code]

only $s will pass. $id and $i_order will not pass. (my register globals is off). I have found enough help and references about not being able to pass variables at all. But, nothing on getting one to pass and not the others.
Link to comment
https://forums.phpfreaks.com/topic/30790-not-passing-all-variables/
Share on other sites

ok here is the code. the code above is in itemlist.php it is called at the bottom of this code.

[code]
<?php

$m = $HTTP_GET_VARS["mode"];
$sort = $HTTP_GET_VARS["sort"];
$id = $HTTP_GET_VARS["id"];
$s = $HTTP_GET_VARS["status"];

include("listheader.php");
require("configlist.php");

/* for debug echo "$id<br>";*/
    $dbh1 = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Could not connect");
    mysql_select_db($dbname,$dbh1) or die("Could not select database");
if ($m == 'edit') {
    $q1 = "SELECT * FROM orders WHERE o_id=$id";
    $rslt1 = mysql_query($q1, $dbh1) or die("Query failed<p>$q1");
    $row1 = mysql_fetch_array($rslt1, MYSQL_ASSOC);
    /* Free resultset */
    mysql_free_result($rslt1);   
} else {
    $id = 0;
}
/* Closing connection */

$backurl = "orderlist.php";
$posturl = "orderpost.php";
$addurl = "orderdetail.php?mode=add";
$today = getdate();
       
if (isset($sort)) {
    $backurl .= "?sort=$sort";
    $posturl .= "?sort=$sort";
    $addurl .= "&sort=$sort";
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
echo "<a href=$backurl>Back</a>&nbsp;&nbsp;<a href=$addurl>Add New Order</a>";   
echo '<form name="form1" method="POST" action="'.$posturl.'">';
echo "<input type='hidden' name='id' value='$id'>";
echo "<table>";
echo "<tr><th colspan=2>Part Detail</th></tr>";
//---------------------------------------------------------------------------------------
echo "<tr><td>ID:</td><td>$id</td></tr>";
//---------------------------------------------------------------------------------------
echo "<tr><td>Type:</td><td><select name='type'>
<option value'order'>order</option>
<option value'project'>project</option>
<option value'damaged'>damaged</option>";
if ($m == 'edit') {
    echo " value='".htmlentities($row1['o_type'],ENT_QUOTES)."'";
}

echo "</td></tr>";
//---------------------------------------------------------------------------------------
echo '<tr><td>Supplier:</td><td>';
echo "<select name='supplier'>";
$query="SELECT * FROM supplier ORDER BY s_name";
$result=mysql_query($query) or die("unable to make the query:".mysql_error());
while($row=mysql_fetch_array($result)){
echo"<option value= '".$row['s_id']."'";
if (($m == 'edit') and ($row['s_id']==$row1['o_supplier'])) {
echo " selected ";
}
echo ">".$row['s_name']."</option>";
}
echo "<select>";
echo "</td></tr>";
//---------------------------------------------------------------------------------------
echo '<tr><td>Description:</td><td><input type="text" name="desc" size="80" maxlength="80"';
if ($m == 'edit') {
    echo " value='".htmlentities($row1['o_desc'],ENT_QUOTES)."'";
}
echo "></td></tr>";
//---------------------------------------------------------------------------------------
echo '<tr><td>Date:</td><td><input type="date" name="date" size="80" maxlength="80"';
if ($m == 'edit') {
    echo " value='".htmlentities($row1['o_date'],ENT_QUOTES)."'";
} else {
echo " value='".$today['year']."-".$today['mon']."-".$today['mday']."'";
}
echo "></td></tr>";
//---------------------------------------------------------------------------------------
echo '<tr><td>Project:</td><td>';
echo "<select name='project'>";
$query="SELECT * FROM project ORDER BY j_name";
$result=mysql_query($query) or die("unable to make the query:".mysql_error());
while($row=mysql_fetch_array($result)){
echo"<option value= '".$row['j_id']."'";
if (($m == 'edit') and ($row['j_id']==$row1['o_project'])) {
echo " selected ";
}
echo ">".$row['j_name']."</option>";
}
echo "<select>";
echo "</td></tr>";
//---------------------------------------------------------------------------------------
echo '<tr><td>Item Quantity:</td><td><input type="text" name="qty" size="80" maxlength="80"></td></tr>';
//---------------------------------------------------------------------------------------
echo '<tr><td>Comment:</td><td><textarea name="comment" cols=80 rows=3>';
if ($m == 'edit') {
    echo $row1['o_comment'];
}
echo "</textarea>";
echo "</td></tr>";
//---------------------------------------------------------------------------------------
echo "<tr><td colspan=2 align=center><input type='submit' name='SubmitFrm' value='Save'></td></tr>";
echo "</table>";
echo "</form>";
if (isset($s)) {
    echo "Edit Status: $s ";
}   
if ($m == 'edit') {
    $addUrl = "partdetail.php?mode=add&id=$id";
    if (isset($s))
        $addUrl .= "&sort=$s";   
}
echo "<p><a href=itemlist.php?i_order=$id>Add Item List</a>";
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.