Jump to content

Adding a radio button at start and "Edit" button at end of loop


mikebyrne

Recommended Posts

I want to have a radio button appear at the start of each line of my loop aswell as an edit button at the end.

 

My code at the minute is:

 

	<table width="850" border="0" cellspacing="0" cellpadding="0">
<?php
// let's get some data
include('adminconnect.php');
$query = "SELECT ProductNo,ProductName,Display,Price FROM Product WHERE Producttype = 'Game' ";
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result)){
// loop through and display
?>

<tr align="left">
<td width="33"> </td>
<td width="82"><a class="black"><?php echo $row['ProductNo'];?></a></td>
<td width="61"><?php echo $row['ProductName'];?></td>
<td width="61"><?php echo $row['Display'] ;?></td>
<td width="230"><?php echo $row['Price'];?></td>

</tr>

<?
}
?>

</table>

 

What i want to happen is that when the radio button is activted and the "Edit" button is pressed the page will be redirect to my edit.php page and the varibles will also be passed over

Link to comment
Share on other sites

 
<form method="post" action="edit.php">
<table width="850" border="0" cellspacing="0" cellpadding="0">
<?php
// let's get some data
include('adminconnect.php');
$query = "SELECT ProductNo,ProductName,Display,Price FROM Product WHERE Producttype = 'Game' ";
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result)){
// loop through and display
?>

<tr align="left">
<td width="33"><input type="radio" value="<?php echo $row['ProductNo'];?>" name="something" /></td>
<td width="82"><a class="black"><?php echo $row['ProductNo'];?></a></td>
<td width="61"><?php echo $row['ProductName'];?></td>
<td width="61"><?php echo $row['Display'] ;?></td>
<td width="230"><?php echo $row['Price'];?></td>
<td width="230"><input type="submit" name="submit" value="Edit" /></td>

</tr>

<?
}
?>

</table>
</form>

 

I would personally just use a simple link e.g.

<a href="edit.php?id=$id>Edit</a>

Link to comment
Share on other sites

Yeah that seems to work great. THANKS!!

 

I know its not a php issue but my figures aren't lined up with my headings. The headings are formatted as below:

 

<table width="850" border="0" cellspacing="0" cellpadding="0">
			<tr align="left">
				<td width="25"> </td>
				<td width="45" align="center">ftd</td>

				<td width="100"><a href="#">serial no.</a></td>
				<td width="333"><a href="#">product name</a></td>
				<td width="95" align="center">display order</td>
				<td width="46" align="center"><a href="#">display</a></td>
				<td width="66" align="right"><a href="#">pricet</a></td>
				<td width="30"> </td>

				<td width="110">action</td>

 

The results are formattted as below

 

<tr align="left">
<td width="33"><input type="radio" value="<?php echo $row['ProductNo'];?>" name="something" /></td>
<td width="82"><a class="black"><?php echo $row['ProductNo'];?></a></td>
<td width="61"><?php echo $row['ProductName'];?></td>
<td width="61"><?php echo $row['Display'] ;?></td>
<td width="230"><?php echo $row['Price'];?></td>
<td width="230"><input type="submit" name="submit" value="Edit" /></td>

</tr>

<?
}
?>

</table>

 

Any help would be great!!!

Link to comment
Share on other sites

<table width="850" border="0" cellspacing="0" cellpadding="0">
			<tr align="left">
				<td width="25"> </td>
				<td width="100"><a href="#">serial no.</a></td>
				<td width="333"><a href="#">product name</a></td>
				<td width="95">display order</td>
				<td width="46"><a href="#">display</a></td>
				<td width="66"><a href="#">pricet</a></td>
				<td width="30"> </td>
				<td width="110">action</td>
				</tr>

 

<tr align="left">
<td><input type="radio" value="ProductNo<?php echo $row['ProductNo']; ?>" name="something" /></td>
<td><a class="black"><?php echo $row['ProductNo'];?></a></td>
<td><?php echo $row['ProductName'];?></td>
<td>Display order results</td>
<td><?php echo $row['Display'] ;?></td>
<td><?php echo $row['Price'];?></td>
<td> </td>
<td><input type="submit" name="submit" value="Edit" /></td>
</tr>


<?
}
?>

</table>

Link to comment
Share on other sites

Thats a little better but still no right

 

serial no.  product name  display order  display  pricet    action

1 Call of Duty 4: Modern Warfare Display order results yes 55.99  

2 Assassin's Creed Display order results yes 55.99  

5 Ace Combat 6: Fires Of Liberat Display order results yes 55.99  

3 The Simpsons Game Display order results yes 57.99  

4 Need For Speed: ProStreet Display order results yes 55.99

 

Product name is too far to the left and display and pricet are too far to the left 

 

 

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.