JamesCliff
Programmer
Hi all,
I need abit of help on a couple of things:
1. Ive created two pages edit.php and delete.php. For now we will concentrate on delete.php. I have a list.php which sends the specific SaleID variable to delete.php for a selected record. Below is a portion of code that exists in list.php:-
As you can see above when examining the code, for each record there is an edit and delete link, these links are generated by php, which specifies the SaleID for each record. The variables are passed through the URL to the specific page. So for example a record with the SaleID of 3, is then specified to be deleted by clicking the delete link, the php passes the url of: delete.php?SaleID=1
This giving the SaleID to delete.php, so the passed SaleID is deleted. The query code for the delete.php is:
However when i click the delete link for any record on the list.php the link works and the delete success message is displayed. However the record is not deleted from the database, this leads me to believe that there is a problem with the query.
You can view and test the above at:
2. Is is possible to pass multiple variables to multiple pages within a url?
For example my site is structered using php and the include function. There is an index.php which is coded to include pages passed within the url. So to view the sales page the URL would be: index.php?page=sales
However the script im working on above also requires variables to be passed within the URL eg.
delete.php?SaleID=19
The list.php and delete.php would be displayed within the index.php as you can tell when you view the site on the link posted above.
So im confused at whether i can pass both of these variables in the URL at the same time, and if possible how would i do this? For example would it be something along these lines:
index.php?page=admin/sales/delete?SaleID=19
I am probably completly wrong, and would be greatful if someone could shed some light on this for me.
I hope it is possible to address both of my issues.
Thanks alot
Jim
I need abit of help on a couple of things:
1. Ive created two pages edit.php and delete.php. For now we will concentrate on delete.php. I have a list.php which sends the specific SaleID variable to delete.php for a selected record. Below is a portion of code that exists in list.php:-
Code:
while($result = mysql_fetch_array($rslt))
{
echo "<table>";
echo "<tr>";
echo "<td width=\"50\"><a href=\"photos/" . $result['Image_Ref'] . "\" target=\"_blank\">View Picture</a></td>";
echo '<td width="150">' . $result['Title'] . '</td>
<td width="260">' . $result['Description'] . '</td>
<td width="120">' . $result['Price'] . '</td>
<td width="110">' . $result['Date'] . '</td>
</tr>';
echo "<tr>";
echo '<td colspan="5"> </td>
</tr>';
echo "<tr>";
echo '<td><a href="admin/sales/edit.php?SaleID=' . $result['SaleID'] .'">edit</a> | <a href="admin/sales/delete.php?SaleID='. $result['SaleID'] .'">delete</a></td>
</tr>';
As you can see above when examining the code, for each record there is an edit and delete link, these links are generated by php, which specifies the SaleID for each record. The variables are passed through the URL to the specific page. So for example a record with the SaleID of 3, is then specified to be deleted by clicking the delete link, the php passes the url of: delete.php?SaleID=1
This giving the SaleID to delete.php, so the passed SaleID is deleted. The query code for the delete.php is:
Code:
$query = "DELETE FROM sales WHERE SaleID = '$SaleID'";
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());
// close database connection
mysql_close($connection);
// print result
echo "<font size=-1>Sale item has been deleted from the database. <a href=[URL unfurl="true"]http://www.briskfire.com/gb/index.php?page=admin/sales/admin>Go[/URL] back to the
admin menu</a>.</font>";
However when i click the delete link for any record on the list.php the link works and the delete success message is displayed. However the record is not deleted from the database, this leads me to believe that there is a problem with the query.
You can view and test the above at:
2. Is is possible to pass multiple variables to multiple pages within a url?
For example my site is structered using php and the include function. There is an index.php which is coded to include pages passed within the url. So to view the sales page the URL would be: index.php?page=sales
However the script im working on above also requires variables to be passed within the URL eg.
delete.php?SaleID=19
The list.php and delete.php would be displayed within the index.php as you can tell when you view the site on the link posted above.
So im confused at whether i can pass both of these variables in the URL at the same time, and if possible how would i do this? For example would it be something along these lines:
index.php?page=admin/sales/delete?SaleID=19
I am probably completly wrong, and would be greatful if someone could shed some light on this for me.
I hope it is possible to address both of my issues.
Thanks alot
Jim