Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Managing User Interaction With Checkboxes
Old 06-26-2005, 11:04 AM Managing User Interaction With Checkboxes
Junior Talker

Posts: 1
Trades: 0
This is the basics! i am creating a site inwhere people are able
to post ads. these ads are displayed for all to see in a displaying page. so through a form they fill in the data, this data goes to the database and because the displaying page queries the database, the content will immidiately be displayed! I need to have a sort of content management system here in where one of my database field is a hidden field in the form itself but visiable in my updating page, as a checkbox. so that i may check or uncheck this field which contains the data inserted into the table before it would be displayed.
So thats it. its just that i don't know how to go about it! whether this query would go into the displaying page and or in the updating page or just in the form page! and what would be the query itself. I would deffinitely appreacite any step by step that you can provide!
vaughn555 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-26-2005, 08:08 PM
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
Add a column to your classified table in your database called 'authorized', make it datatype 'tinyint' with a default value of 0.

Hopefully you've incorporated some form of administration login so that your pages can recognize you as being logged on. If this is the case follow the generic steps below;

1. Instantiate a var for authorized users being logged in.

e.g.

PHP Code:
$auth 0
2. Do a test to check if your logged.

e.g.

PHP Code:
if(isset($_SESSION['access']) && $_SESSION['access'] == 'admin'){

$auth 1;


3. Apply some self administration to the classifieds which display on the page. If $auth == 0, only authorised classifieds display. If $auth == 1, all classifieds display with the inclusion of a radio group in each record carrying the checked values '1' for approved and '0' for declined. Each form instance includes a hidden form value that carries the recordID for your table row.

e.g.

PHP Code:


<?php 

if($auth == 1){

$sql "SELECT * FROM table_name";

}else{

$sql "SELECT * FROM table_name WHERE authorized = 1";

}

$rsClassifieds mysql_query($sql) or die(mysql_error());
$row_rsClassifieds mysql_fetch_assoc($rsClassifieds);


// start record display

if($auth == 1){
?>

<form name="approval" method="POST">
<input type="hidden" name="recordID" value="<?php echo $recordID?>" />
<label><input type="radio" name="approve" value="1" />
Approve :: </label>
<label><input type="radio" name="approve" value="0" />
<input name="Submit" type="submit" value="Submit" />
Decline</label>
<input name="doRecord" type="hidden" value="ok" />
<input name="Submit" type="submit" value="Submit" />
</form>

<?php 

// end if conditional for displaying admin form

}

// end record display ?>
4. Code in your record management at the top of the page.

i.e.

PHP Code:
if(isset($_POST['doRecord']) && $_POST['doRecord'] == 'ok'){

$recordID 0;

if(
$_POST['approve'] == 1){

$sql "UPDATE table_name SET authorized = 1 WHERE recordID = ".$recordID;
$query mysql_query($sql) or die(mysql_error());

}

if(
$_POST['approve'] == 0){

$recordID $_POST['recordID'];

$sql "DELETE FROM table_name WHERE recordID = ".$recordID;
$query mysql_query($sql) or die(mysql_error());

}

// end if form submitted condition


That shoud give an idea of one approach.
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Reply     « Reply to Managing User Interaction With Checkboxes
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10498 seconds with 12 queries