Jump to content

adding a single digit to a previous one.


jbrill

Recommended Posts

hey, just need to get this last question solved and my project is done!!  ;D

 

Basically what i need to do is get the last entry from table "job_part" WHERE quote_id=$quoteid

 

It will pull a digit, if there was one in the database.

I would then like to have text field that is given the value that we just got from the database, and add 1 to it. so if it pulled a "1" it would  " + 1" and set the value of the text box to "2" quite simple probably. I just need to have someone show me how it is done. I need to present this to my client today and this is the final step to have it working!. Heres the code for the page.

 

<?php
include 'admin_header.php';
$jobid = $_GET['jobid'];
if($_SESSION['type'] != "admin")
{
echo "You are either not logged in, or logged in but with no authority to access this page.<br>please visit the log in page <a href=index.php>here</a>.";
}




else
{
// execute the real stuff if the login is valid

include 'admin_jobmenu.php';


?>


				<div align="center">

					<!-- end header -->
<?php

if($_POST['drawing_number']!="")
{
// process the data load scheme




$update = 'INSERT INTO job_part (quote_id, step_id, drawing_number, quantity, material, purchased_by, supplier, status) VALUES ("'.$_GET['jobid'].'","'.$_POST['step_id'].'","'.$_POST['drawing_number'].'","'.$_POST['quantity'].'","'.$_POST['material'].'","'.$_POST['purchased_by'].'","'.$_POST['supplier'].'","'.$_POST['status'].'")';

echo $update."<br>";

$check = mysql_query($update);

$lastid = mysql_insert_id();

echo "<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"tableoutline\">
<tr>
<td>";
echo "New Job Part Created<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=admin_findparts.php?idr=$jobid\"></td></tr></table>";


}

// data load scheme ends here

else
{// if no data loaded, run this..
?>
<br>
<form name="createpart" method="post">
						<br>
						<table border="0" width="100%" align="center">

		<td align="center">
		<?php
			if ($msg == "") {
				echo(" ");					
			} else {
				echo($msg);
			}
		?>
		</td>
	</tr>
</table>
    <input type="text" name="stepid" value="<? // This is where the new number will go, this will be a hidden field eventually ?>"/>
						<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableoutline">
<tr>
<td>
<table align="center" border="0" cellpadding="10" cellspacing="0" bgcolor="#ffffff" style="border:1px solid #000000">
<tr class="colorheader">
	<td align="center" colspan="2" class="colorhedr"><font class="section">Create A New Job Part</font></td>
</tr>
<tr class="tablelight">
	<td align="right" class="editpdL"><strong>Drawing Number</strong></td>
	<td class="editpdR"><input type="text" name="drawing_number" size="20"></td>
</tr>
	<tr class="tablelight">
	<td align="right" class="editpdL"><strong>Quantity</strong></td>
	<td class="editpdR"><input type="text" name="quantity" size="20"></td>
</tr>
<tr class="tabledark">
	<td align="right" class="editpdL"><strong>Material</strong></td>
	<td class="editpdR">
        <select name="material">
<option selected value=''>-- Select Category --</option>
<?

$statussql = "SELECT * FROM materials ORDER BY cat";
$cats = mysql_query($statussql);
$status = mysql_fetch_array($cats);

do

{
echo "<option value='".$status["material"]."'>".$status["cat"]." - ".$status["material"]."</option>";


} while ($status = mysql_fetch_array($cats));



?>
</select>
</td>
</tr>

<tr class="tabledark">
	<td align="right" class="editpdL"><strong>Purchased By</strong></td>
	<td class="editpdR">
        <input type="Checkbox" name="purchased_by" value="MGM"> MGM<br>
	<input type="Checkbox" name="purchased_by" value="Customer"> Customer
        </td>
</tr>

	<tr class="tabledark">
	<td align="right" class="editpdL"><strong>Supplier</strong></td>
	<td class="editpdR">
        <select name="supplier">
<option selected value=''>-- Select Supplier --</option>
<?

$supplysql = "SELECT * FROM suppliers ORDER BY name";
$supplier = mysql_query($supplysql);
$supply = mysql_fetch_array($supplier);

do

{
echo "<option value='".$supply["name"]."'>".$supply["name"]."</option>";


} while ($supply = mysql_fetch_array($supplier));



?>
</select>

        </td>
</tr>

	<tr class="tabledark">
	<td align="right" class="editpdL"><strong>Status</strong></td>
	<td class="editpdR">
                <select name="status">
<option selected value=''>-- Select Supplier --</option>
<?

$statussql = "SELECT * FROM complete";
$status = mysql_query($statussql);
$stat = mysql_fetch_array($status);

do

{
echo "<option value='".$stat["status"]."'>".$stat["status"]."</option>";


} while ($stat = mysql_fetch_array($status));



?>
</select>
        </td>
</tr>

<tr class="tabledark">
	<td class="editfootSingle" colspan="2" align="center">

		<input type="submit" name="Create" value="Create Job Part" class="inputsubmit">
	</td>
</tr>
</table>

</td>
</tr>	  
    </table>		

	</form>
        
        

					<br>
					<!-- begin footer --></div>
			<?
				 }
}


			include 'admin_footer.php';




			?>



Link to comment
https://forums.phpfreaks.com/topic/61719-adding-a-single-digit-to-a-previous-one/
Share on other sites

i think we are getting closer, this is what i have put in now...

    
    <?
$partquery="SELECT * FROM job_part WHERE quote_id=$jobid";
$partinfo = mysql_query($partquery);
$row = mysql_fetch_array($partinfo);

    ?>

<input type="text" name="step_id" value="<? echo $row['step_id']+1;?>">

 

 

however, now it is only displaying a "1" and it is not adding up with every new part

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.