thanks for the repley however i did correct that error and no luck it still doesn't pass the value of cat_no through. Looking at the source it has found the cat_no for that vinyl.
Code: Select all
<table><tr><td><a href ="edit_vinyl_form.php?cat_no="100003">Edit</a></td>
<td> </td>
<td><a href = "admin.php">Adminstration Menu</a></td>
<td> </td>
<td><a href = "stock.php?action=newrecord">Add Vinyl</a></td>
<td> </td>
<td><a href = "logout.php">Logout</a></td>
</tr>
<table> </body>
however selecting the edit link the value of cat_no still doesn't get passed through. I've included the edited scripts.
Code: Select all
<?php
//display_vinyl_form.php
require_once('shopping_cart_fns.php');
function display_vinyl_form($vinyl = '')
{
$edit = is_array($vinyl);
?>
<form align="center" name="newrecord" method="post" action="<?php echo $edit?'edit_vinyl.php' : 'insert_vinyl.php';?>">
<table bordercolor="#FFFFFF" border="1" bgcolor="#FFFFFF">
<font color="#000000" size="2" face="Courier New, Courier, mono">
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Title: </font></td>
<td><input name="title" type="text" maxlength="40" value="<?php echo $edit?$vinyl['title']:' '; ?>"></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Artist: </font></td>
<td><select name="artist_id">
<?php
$artist_array=get_artists();
foreach ($artist_array as $thisartist)
{
echo '<option value="';
echo $thisartist['artist_id'];
echo '"';
if ($edit && $thisartist['artist_id'] == $vinyl['artist_id'])
echo 'selected';
echo '>';
echo $thisartist['artist_id'];
echo'</option>';
echo"\n";
}
?>
</select>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Release Date: </font></td>
<td><select name="date"><?php
$nums = range(1, 31);
foreach ($nums as $num)
{
echo '<option value="';
echo $num;
echo '"';
if ($edit && $num['date'] == $vinyl['date'])
echo 'selected';
echo '>';
echo $num;
echo '</option>';
echo "\n";
} ?>
</select>
<select name="month"><?php
$nums = range(1, 12);
foreach ($nums as $num)
{
echo '<option value="';
echo $num;
echo '"';
if ($edit && $num['month'] == $vinyl['month'])
echo 'selected';
echo '>';
echo $num;
echo '</option>';
echo "\n";
} ?>
</select>
<select name="year"><?php
$nums = range(1998, 2005);
foreach ($nums as $num)
{
echo '<option value="';
echo $num;
echo '"';
if ($edit && $num['year'] == $vinyl['year'])
echo 'selected';
echo '>';
echo $num;
echo '</option>';
echo "\n";
} ?>
</select></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Genre: </font></td>
<td><select name="genre_ref">
<?php
$genre_array=get_genres();
foreach ($genre_array as $thisgenre)
{
echo '<option value="';
echo $thisgenre['genre_ref'];
echo '"';
if ($edit && $thisgenre['genre_ref'] == $vinyl['genre_ref'])
echo 'selected';
echo '>';
echo $thisgenre['genre_ref'];
echo'</option>';
echo"\n";
}
?>
</select>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Price: </font></td>
<td><input name="price" type="text" maxlength="5" id="price" value="<?php echo $edit?$vinyl['price']: ' '; ?>"></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Qty: </font></td>
<td><input name="qty" type="text" maxlength="3" id="qty" value="<?php echo $edit?$vinyl['stock_level']: ' '; ?>"></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Vinyl Information</font></td><td><textarea name="comments" maxlength="225" cols="60" rows="10" value="<?php echo $edit?$vinyl['vinyl_description']: ' '; ?>"></textarea></td>
</tr>
<tr>
<td <?php if(!$edit) echo 'colspan="2"'; ?> align="center">
<?php
if ($edit)
echo '<input type="hidden" name="oldcatno" value="'.$vinyl['cat_no'].'">';
?>
<input type="submit" value="<?php echo $edit?'Update' : 'Add';?>Vinyl"></td><td><input type="reset" value="Reset"></td>
</tr>
<table></form>
<div align="left"></div></td>
</tr>
</table></td>
<?php
if($edit)
{
echo '<td>';
echo'<form method="post" action="delete_vinyl.php">';
echo'<input type="hidden" name="catno" value="'.$vinyl['cat_no'].'">';
echo '<input type="submit" value="delete vinyl">';
echo '</form></td>';
}
?>
</tr>
</table>
<?
}
do_html_footer();
?>
and the edit_vinyl_form is:
Code: Select all
<?php
session_start();
require_once('display_vinyl_form.php');
$catno = $_GET['cat_no'];
if ($vinyl = get_vinyl_details($catno))
{
display_vinyl_form($vinyl);
}
else
echo 'Could not retrieve vinyl details.<br />';
?>
and the show_vinyls form where the value of cat_no should get passed from.
Code: Select all
<?php
require_once('useful_stock_fns.php');
function display_vinyl_details($vinyl)
{
$catno = $_GET['cat_no'];
if(!is_array($vinyl))
{
echo 'No Details on this record Currently Available<br />';
return;
}
{
?>
<table bgcolor="#7b9815" border="0" bordercolor="FFFFFF">
<tr>
<td><font color="#7b9815" size="2" face="Arial, Helvetica, sans-serif">
<tr>
<td align="center">
<b>Vinyl Details</b>
</td>
</td>
<tr>
<tr>
<td bgcolor="#44802c">
<b>Artist:</b>
</td>
</tr>
<tr>
<td >
<?
}
echo $vinyl['artist_id'];
echo '</td>';
echo '</tr>';
echo '<tr>';
{
?>
<td bgcolor="#44802c">
<?
}
echo '<b>Title:</b> ';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo $vinyl['title'];
echo '</td>';
echo '</tr>';
echo '<tr>';
{
?>
<td bgcolor="#44802c">
<?
}
echo '<b>Our Price:</b> ';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo number_format($vinyl['price'], 2);
echo '</td>';
echo '</tr>';
echo '<tr>';
{
?>
<td bgcolor="#44802c">
<?
}
echo '<b>Description:</b> ';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo $vinyl['vinyl_information'];
echo '</td></tr></table>';
if ($_SESSION['rank'] == '2'){
?>
<table><tr><td><a href ="edit_vinyl_form.php?cat_no="<?php echo $catno; ?>">Edit</a></td>
<td> </td>
<td><a href = "admin.php">Adminstration Menu</a></td>
<td> </td>
<td><a href = "stock.php?action=newrecord">Add Vinyl</a></td>
<td> </td>
<td><a href = "logout.php">Logout</a></td>
</tr>
<?
}
if ($_SESSION['rank'] == '1'){
echo '<table><tr><td><a href =>Add to Basket</a></td>
<td> </td>
<td><a href = >View Basket</a></td>
<td> </td>
<td><a href = >Continue Shopping</a></td>
<td> </td>
<td><a href = >Save Changes</a></td>
<td> </td>
<td><a href = "logout.php">Logout</a></td>
</tr>';
}
echo '<table>';
}
session_start();
require('page.inc');
require_once('shopping_cart_fns.php');
$vinylform = new Page();
$vinylform -> Display();
display_main_menu();
$catno = $_GET['cat_no'];
$vinyl = get_vinyl_details($catno);
display_vinyl_details($vinyl);
do_html_footer();
?>