randydg Posted July 23, 2013 Share Posted July 23, 2013 I am having an issue. I have a code that works fine, but I want to remove a link within a script to another page and bundle it within the main page script so it doesn't have to go to another page. Basicly I want it to post to itself and delete a line out of mysq limit 1. Currently the script looks up the items from the sql database and posts the count of them and next to it has a link with a add 1 or remove 1. that goes to another script that works fine, just want to add it to the one bellow. I know how to do it with a form & script, but since the link/image is already in a script, I am not sure what to do. Index.php: <?php include 'connect.php'; $query="SELECT * FROM inventory WHERE `Device` = 'item1' "; $result=mysql_query($query); $num=mysql_numrows($result); if ($num> 0){ $id=mysql_result($result,$i,"Id"); $name=mysql_result($result,$i,"Name"); $discription=mysql_result($result,$i,"Discription"); $cost=mysql_result($result,$i,"Cost"); $retail=mysql_result($result,$i,"Retail"); $amount=mysql_result($result,$i,"Amount"); $device=mysql_result($result,$i,"Device"); print "<tr>"; print "<td bgcolor='#00ff00'>$num</td>"; print "<td>item 1 name</td>"; print "<td>item 1 discription</td>"; print "<td><a href='addcount.php'><img src='addcount.png'></a></td>"; print "<td><a href='deletecount.php'><img src='RenderedImage.png'></a></td>"; print "</tr>"; }else{ print "<tr>"; print "<td bgcolor='#FF0033'>0</td>"; print "<td>item 1 name</td>"; print "<td>item 1 discription</td>"; print "<td><a href='addcount.php'><img src='addcount.png'></a></td>"; print "<td>Nothing to Delete</td>"; print "</tr>"; } ?> addcount.php: <?php if (isset($_POST['submitadd'])) { $addnew = trim(stripslashes($_POST['addnew'])); include 'connect.php'; $query="SELECT `id`,`device` FROM `inventory`"; $result=mysql_query($query); $num=mysql_numrows($result); $sql = "INSERT INTO inventory VALUES('','','','','','','$addnew')"; $result = mysql_query($sql); if (!$result) { die('Invalid query: '.mysql_error()); } print "$addnew added successfully.<br />"; } ?> <form method="POST" action="<?=$PHP_SELF;?>"> ADD New:<br /> Enter Device ID: <input type="text" name="addnew"> <input type="submit" name="su'submitadd'value="SUBMIT"/> </form> These work fine separatly, but I was really wanting to combine them into 1 script, but the link to add/delete needs to be where it currently is in index.php or it will screw up the tables. Thanks for any advice Quote Link to comment https://forums.phpfreaks.com/topic/280438-php-how-to-have-an-image-within-a-script-link-to-itself-with-a-script/ Share on other sites More sharing options...
randydg Posted July 23, 2013 Author Share Posted July 23, 2013 (edited) Correction at the end of addcount.php: <form method="POST" action="<?=$PHP_SELF;?>"> Add Count from<br /> Enter Device Name: <input type="text" name="addnew"> <input type="submit" name="submitadd" value="SUBMIT"/> </form> Edited July 23, 2013 by randydg Quote Link to comment https://forums.phpfreaks.com/topic/280438-php-how-to-have-an-image-within-a-script-link-to-itself-with-a-script/#findComment-1441856 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.