Jump to content

Problems w/ Edit, View, Delete Feature on SQL program


Jeannie109

Recommended Posts

I am using some script to create a Job List.  It works well to Add a new job and List all the jobs and the Search feature works also.  But, I can't get the Edit, View and Delete feature to work on this page:

 

http://bernardtransportation.com/jobboard/jobs.php?posting=yes&

 

Everything used to work but now I am getting error messages.  Can someone please help?

 

Thank you so much.

Link to comment
Share on other sites

what i can recommend is using a hidden text field to store a unique value of each record and then using a form to post the value to the desired page, eg. edit or delete.

 

Here is a sample script I've used before:

	while ($row = mysql_fetch_array($sql)) 
{
echo "
		<tr>
			<td  valign='center' align='center' width='300'><form method='post'><input type='hidden' name='product_id' value='$row[product_id]'><img src='$row[product_image]' border='0' alt='$row[product_name]' width='30%'></td>
			<td> </td>
			<td valign='top'><input type='hidden' name='product_name' value='$row[product_name]'>$row[product_name]<br><small><input type='hidden' name='product_price' value='$row[product_price]'>R $row[product_price]</small></td>
			<td> </td>
			<td valign='center'><input type='image' src='images/details.gif' value='View Details' alt='View Details' onclick=\"this.form.action='product_details.php';\"><br>
								<input type='image' src='images/placeorder.gif' value='Order' alt='Order' onclick=\"this.form.action='order.php';\"><br>
								<input type='hidden' name='qty' value='1'>
								<input type='image' src='images/addtocart.gif' value='Add To Cart' alt='Add To Cart' onclick=\"this.form.action='modcart.php?action=add';\"></form></td>
		</tr>
		<tr>
			<td colspan='5'> </td>
		</tr>
";}}

Link to comment
Share on other sites

Here is the URL:  http://bernardtransportation.com/jobboard/jobs.php?posting=yes& 

 

I had this site on IX Webhosting before and it worked perfectly.  Now, I just transfered everything to GoDaddy for webhosting and it is failing.  Adding a new record is no problem, so it is finding the database table and data just fine. 

 

Here is the error code: 

Editing Record

V E D 

Error Retrieving Records (9993SQLGET)

 

The whole process runs on the single page, job.php, but this is the code referencing the View Edit Delete portion of the page.

 

if ($post == "") { //THEN WE ARE EDITING A RECORD

echo "<table border=1 width=400 align=center><tr><td><DIV CLASS='PAGE_STATUS'>Editing Record</DIV>";

 

?>

<TABLE width=450 align=center><tr><td><DIV CLASS='PAGE_OPTIONS'>

<?php if ($allowview == "yes") { ?><a href="<?php echo $thispage; ?>?id=<?php echo $id; ?>&proc=View&<?php echo $pagevars; ?>">V</a>

<?php } //END ALLOWVIEW ?><?php if ($allowedit == "yes") { ?>

<a href="<?php echo $thispage; ?>?id=<?php echo $id; ?>&proc=Edit&<?php echo $pagevars; ?>">E</a>

<?php } //END ALLOWEDIT ?><?php if ($allowdelete == "yes") { ?>

<a href="<?php echo $thispage; ?>?id=<?php echo $id; ?>&proc=Delete&<?php echo $pagevars; ?>">D</a>

<?php } //END ALLOWDELETE ?></font><font face="arial" size="2">

</DIV></td>

</tr>

</table>

<?

 

/*-- SECTION: 9993SQLGET --*/

$sql = "SELECT * FROM loads WHERE (id = '$id') $addl_select_crit ";

if ($sql_debug_mode==1) { echo "<BR>SQL: $sql<BR>"; }

$result = mysql_query($sql,db() ) or die ("Error Retrieving Records (9993SQLGET)");

if ($myrow = mysql_fetch_array($result)) {

do

{

Link to comment
Share on other sites

Hi Blade,

 

Thank you so much for the suggestion.  Now, at least I can see what the problem is, but unfortunately, I do not know how to fix it.  This is the error for the "V" View link:

 

Editing Record

VED 

Unknown column 'id' in 'where clause'

 

I am not sure how to fix that.  Do I add another field called ID into my Loads table in the database?

 

Also, here is the error message if you click on "V" or View on the main jobs.php

 

Viewing Record

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/b/t/g/btginc/html/jobboard/jobs.php on line 921

 

And, here is the error for the "D" or Delete link from jobs.php

 

Once the box appears and you click on YES: 

 

Deleting Record

Error Deleting Record (9995SQL)

 

Jeannie

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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