473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using checkboxes instead of a link

Hi,

On my site I give users to option to subscribe to certain articles. When
they choose to subscribe the necessary addition is made to the database.
When they go to the Unsubscribe section it lists the articles that they are
subscribed to and gives a link next to it letting them unsubscribe. However,
rather than having the text, I want to have a checkbox instead. Then I want
to have a button at the bottom that when clicked unsubscribes them from any
articles whose checkbox is ticked. This is similar to the way that My eBay
works, if you are still unclear.

Is there an easy way of doing this? I know that it can be done, but dont
know how, so any help would be much appreciated!

Cheers,

Paul
Mar 2 '06 #1
5 1426
Sorry, meant to put in the code that I am using:

<?php
// Make table if member has specific injustice subscriptions
$sql = "SELECT i.type, i.title , s.inj_id FROM inj_subscription s,
injustices i WHERE s.member_id = '$user' AND i.inj_id = s.inj_id AND
s.inj_id IS NOT null" ;
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result) ;
if ($row) {
echo "<div><span>Specific Injustice Subsriptions:</span><br/>" ;
$table_start ='<table width="90%" align="center" cellspacing="0"
border="0">
<tr>
<th width="20%">Type</th>
<th width="70%">Title</th>
<th width="10%"></th>
</tr>';
echo $table_start;
$rownum = 0;
while($row) {
$rownum++;
$style = rowcolor($rownum);
$table_rows = "<td id=\"td\" align=\"center\" style=\" $style
;padding:5px\" >" .$row['type'] . "</td>";
$table_rows .= "<td id=\"td\" align=\"center\" style=\" $style
;padding:5px\" >" . $row['title']. "</td> \n\t";
$table_rows .= "<td id=\"td\" align=\"center\" style=\" $style
;padding:5px\" ><a href=\"stop_subscription.php?id=" . $row['inj_id'] .
"\">Unsubscribe</a> </td>\n\t";
echo "<tr>" . $table_rows . "</tr>";
$row = mysql_fetch_assoc($result) ;
}
echo '</table><Br/></div><br/>';
}
?>
Mar 2 '06 #2
Paul Morrison wrote:
Sorry, meant to put in the code that I am using: <?php
// Make table if member has specific injustice subscriptions
$sql = "SELECT i.type, i.title , s.inj_id FROM inj_subscription s,
injustices i WHERE s.member_id = '$user' AND i.inj_id = s.inj_id AND
s.inj_id IS NOT null" ;
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result) ;
if ($row) {
echo "<div><span>Specific Injustice Subsriptions:</span><br/>" ;
$table_start ='<table width="90%" align="center" cellspacing="0"
border="0">
<tr>
<th width="20%">Type</th>
<th width="70%">Title</th>
<th width="10%"></th>
</tr>';
echo $table_start;
$rownum = 0;
while($row) {
$rownum++;
$style = rowcolor($rownum);
$table_rows = "<td id=\"td\" align=\"center\" style=\" $style
;padding:5px\" >" .$row['type'] . "</td>";
$table_rows .= "<td id=\"td\" align=\"center\" style=\" $style
;padding:5px\" >" . $row['title']. "</td> \n\t";
$table_rows .= "<td id=\"td\" align=\"center\" style=\" $style
;padding:5px\" ><a href=\"stop_subscription.php?id=" . $row['inj_id'] .
"\">Unsubscribe</a> </td>\n\t";
echo "<tr>" . $table_rows . "</tr>";
$row = mysql_fetch_assoc($result) ;
}
echo '</table><Br/></div><br/>';
}
?>
instead of using<a href=\"stop_subscription.php?id=" . $row['inj_id'] .

"\">Unsubscribe</a>

use
<input type="checkbox" name=deletethis[] value=" . $row['inj_id'] .

where deletethis[] is an array of row id's that you pass to
stop_subscription and delete all of the id's in the array for multiple
id's if you only want them to do one at time then remove the [] from
deletethis.


Mar 2 '06 #3
> instead of using
<a href=\"stop_subscription.php?id=" . $row['inj_id'] .

"\">Unsubscribe</a>

use <input type="checkbox" name=deletethis[] value=" . $row['inj_id'] .

where deletethis[] is an array of row id's that you pass to
stop_subscription and delete all of the id's in the array for multiple
id's if you only want them to do one at time then remove the [] from
deletethis.

Hi,

I have now changed it to be

$table_rows .= "<td id=\"td\" align=\"center\" style=\" $style
;padding:5px\" ><input type="checkbox" name=deletethis[] value=" .
$row['inj_id'] . "\"></td>\n\t";

but it will not accept this, the page doesnt load. Is there something that I
am missing, or am I doing it the wrong way?

Cheers,

Paul
Mar 3 '06 #4
Paul Morrison wrote:
instead of using
<a href=\"stop_subscription.php?id=" . $row['inj_id'] . "\">Unsubscribe</a>

use <input type="checkbox" name=deletethis[] value=" . $row['inj_id'] .

where deletethis[] is an array of row id's that you pass to
stop_subscription and delete all of the id's in the array for multiple
id's if you only want them to do one at time then remove the [] from
deletethis.


Hi, I have now changed it to be $table_rows .= "<td id=\"td\" align=\"center\" style=\" $style
;padding:5px\" ><input type="checkbox" name=deletethis[] value=" .
$row['inj_id'] . "\"></td>\n\t"; but it will not accept this, the page doesnt load. Is there something that I
am missing, or am I doing it the wrong way? Cheers, Paul

reformated for readability

$table_rows .= "<td id=\"td\" align=\"center\" style=\"". $style;
$table_rows .= "padding:5px\" ><input type=\"checkbox\" name=deletethis[]";
$table_rows .= " value=\"" . $row['inj_id'] . "\"></td>\n\t";
hopefully I got all of the missing quotes and dots.
Mar 3 '06 #5
noone wrote:
reformated for readability

$table_rows .= "<td id=\"td\" align=\"center\" style=\"". $style;
$table_rows .= "padding:5px\" ><input type=\"checkbox\" name=deletethis[]";
$table_rows .= " value=\"" . $row['inj_id'] . "\"></td>\n\t";

hopefully I got all of the missing quotes and dots.


You missed a few quotes in there (that's why I refuse to use
double-quotes for outputting HTML):

$table_rows .=
'<td id="td" align="center" style="' . $style . 'padding:5px">' .
'<input type="checkbox" name="deletethis[]"' .
' value="' . $row['inj_id'] . '"></td>' . "\n\t";

This will only return the boxes that are checked, so once you get
the array from the unsubscribe page, you'll need to get the original
list from the database, compare the two, then delete the ones that
appear in the original list, but not in the new list.

- Ryan
Mar 4 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: LRW | last post by:
I did a Web search, and a deja.com search on this...and I'm finding how to make checkboxes act like radiobuttons, and other interesting behaviors, but nothing that quite answers my question. If...
8
by: DylanM | last post by:
I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the...
8
by: John Banta | last post by:
Hi, I have created a 12 month calendar where each day has a check box whereby the user can indicate if that day is available or not available for a certain event. The calendar is 'drawn' in a...
0
by: Kent | last post by:
THe page in question can be viewed here: http://sourcepost.sytes.net/sourceview.aspx?source_id=17723 it is otherwise known as "documentupload.aspx" and can only be accessed if you have an account...
11
by: shree | last post by:
Hello everyone, I'm writing a form which will have a group of checkboxes. When user selects one checkbox, it will automatically disable the rest of the checkboxes in the group. I'm able to...
22
by: Bradley | last post by:
Has anyone else noticed this problem? I converted the back-end to A2000 and the performance problem was fixed. We supply a 97 and 2000 version of our software so we kept the backend in A97 to make...
2
by: Mortar | last post by:
i have a datagrid with a column of html checkboxes which are created dynamically. The id/name of the checkboxes comes from a value in the database. on a postback, i would like to get all the...
4
by: Maarten | last post by:
i have the folowing code to setup my datagrid collumns Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load gridsetup() end sub
1
by: aspnoob | last post by:
hello i just started off with asp.net , needed some help on how to display the state of checkboxes from a SQL database. my database table has the following format seat.dbo ( db design) (...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.