Page 1 of 1

show of hide a record using php

Posted: Thu May 10, 2012 3:05 am
by jonnyfortis
let me explaine the process

a student fill in an application form, here they select an accomodation the wish to rent.

when the application is submitted this accodation is then assigned to them.

In the DB PHPmyadmin the users table has a column called prop_id this is linked to a column called prop_id in the property table

in the admin section i want a checkbox to display or hide the property once it has been assigned so that knowone else can chose it

i know its a toggle 0 for show 1 for hide but i dont know what to do after this

i know i need to post code but again there is lots of it so let me know what

any help would be appreciated

thanks

Re: show of hide a record using php

Posted: Thu May 10, 2012 8:14 am
by Grizzzzzzzzzz
Like you've said, when the student submits the application, set the availability toggle to 1 to indicate that it's no longer available.

Then you only need to change the sql query on the application process slightly to something like this

Code: Select all

SELECT * FROM available_properties WHERE available = 0
then it'll only be retrieving properties that are currently available

Re: show of hide a record using php

Posted: Thu May 10, 2012 8:57 am
by jonnyfortis
having a think about it. once the property has been taken it still needs to be used by the applicant as this will be associated with the ID.

i have a dropdown list on the application form that shows the properties. I think i only need to hide it in this list

below is the dynamic select list

<select name="Select Property" id="Select Property" onchange="loadFields(this.value)">
<option value="select your property">select your property</option>
<?php
do {
?>
<option value="<?php echo $row_rsApplyNow['prop_id'] . '|' . $row_rsApplyNow['prop_add1'] . '|' . $row_rsApplyNow['rental_price'] . '|' . $row_rsApplyNow['town'] . '|' . $row_rsApplyNow['county'] . '|' . $row_rsApplyNow['postcode'];?>"><?php echo $row_rsApplyNow['prop_id'] . " , " . $row_rsApplyNow['prop_add1']; ?></option>
<?php
} while ($row_rsApplyNow = mysql_fetch_assoc($rsApplyNow));
$rows = mysql_num_rows($rsApplyNow);
if($rows > 0) {
mysql_data_seek($rsApplyNow, 0);
$row_rsApplyNow = mysql_fetch_assoc($rsApplyNow);
}
?>
</select>

and below is the sql

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO plus_signup (terms, prop_id, StartDate, weeks, EndDate, Title, userid, password, sex, DOBDate, DOBMonth, DOBYear, Nationality, `Marital Status`, PhoneDay, PhoneEvening, PhoneMobile, email, Smoker, NextKin, CurrentAddress, PrevAddress, LivingStatus, Student, BankFinCCJ, BankFinArrears, BankFinBankR, BankFinNone, BankName, BankAccNum, BankSortCode, BankDuration, BankDCard, BankElectoral, LLName, LLTele, LLEmail, LLHost, LLAddress, GuName, GuTitle, GuDobDate, GuDobMonth, GuDobYear, GuSex, GuMarital, GuPhoneDay, GuPhoneEven, GuPhoneMob, GuPhoneEmail, GuCurrentAdd, GuPrevAdd, GuBankName, GuBankAccNu, GuBankSort, GuBankDurat, GuBankDebit, GuBankElect, GuEmpProffes, GuEmpAnnWa, GuEmpPayroll, GuSelfEmp, GuHaveAcc, GuAccName, GuAccContName, GuAccAdd, GuAccDayTel, GuAccMobTel, GuAccEmail, GuAccAdditional, GuEmployerNam, GuEmployerAdd, GuEmployerContactName, GuEmployerTele, GuEmployerEmail, GuEmployerCCj, GuEmployerArr, GuEmployerBankR, GuEmployerNone) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString(isset($_POST['terms']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['prop_id'], "text"),
GetSQLValueString($_POST['StartDate'], "text"),
GetSQLValueString($_POST['weeks'], "text"),
GetSQLValueString($_POST['EndDate'], "text"),
GetSQLValueString($_POST['Title'], "text"),
GetSQLValueString($_POST['userid'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['sex'], "text"),
GetSQLValueString($_POST['DOBDate'], "text"),
GetSQLValueString($_POST['DOBMonth'], "text"),
GetSQLValueString($_POST['DOBYear'], "text"),
GetSQLValueString($_POST['Nationality'], "text"),
GetSQLValueString($_POST['Marital_Status'], "text"),
GetSQLValueString($_POST['PhoneDay'], "text"),
GetSQLValueString($_POST['PhoneEvening'], "text"),
GetSQLValueString($_POST['PhoneMobile'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['Smoker'], "text"),
GetSQLValueString($_POST['NextKin'], "text"),
GetSQLValueString($_POST['CurrentAddress'], "text"),
GetSQLValueString($_POST['PrevAddress'], "text"),
GetSQLValueString($_POST['LivingStatus'], "text"),
GetSQLValueString($_POST['Student'], "text"),
GetSQLValueString(isset($_POST['BankFinCCJ']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['BankFinArrears']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['BankFinBankR']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['BankFinNone']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['BankName'], "text"),
GetSQLValueString($_POST['BankAccNum'], "text"),
GetSQLValueString($_POST['BankSortCode'], "text"),
GetSQLValueString($_POST['BankDuration'], "text"),
GetSQLValueString($_POST['BankDCard'], "text"),
GetSQLValueString($_POST['BankElectoral'], "text"),
GetSQLValueString($_POST['LLName'], "text"),
GetSQLValueString($_POST['LLTele'], "text"),
GetSQLValueString($_POST['LLEmail'], "text"),
GetSQLValueString($_POST['LLHost'], "text"),
GetSQLValueString($_POST['LLAddress'], "text"),
GetSQLValueString($_POST['GuName'], "text"),
GetSQLValueString($_POST['GuTitle'], "text"),
GetSQLValueString($_POST['GuDobDate'], "text"),
GetSQLValueString($_POST['GuDobMonth'], "text"),
GetSQLValueString($_POST['GuDobYear'], "text"),
GetSQLValueString($_POST['GuSex'], "text"),
GetSQLValueString($_POST['GuMarital'], "text"),
GetSQLValueString($_POST['GuPhoneDay'], "text"),
GetSQLValueString($_POST['GuPhoneEven'], "text"),
GetSQLValueString($_POST['GuPhoneMob'], "text"),
GetSQLValueString($_POST['GuPhoneEmail'], "text"),
GetSQLValueString($_POST['GuCurrentAdd'], "text"),
GetSQLValueString($_POST['GuPrevAdd'], "text"),
GetSQLValueString($_POST['GuBankName'], "text"),
GetSQLValueString($_POST['GuBankAccNu'], "text"),
GetSQLValueString($_POST['GuBankSort'], "text"),
GetSQLValueString($_POST['GuBankDurat'], "text"),
GetSQLValueString($_POST['GuBankDebit'], "text"),
GetSQLValueString($_POST['GuBankElect'], "text"),
GetSQLValueString($_POST['GuEmpProffes'], "text"),
GetSQLValueString($_POST['GuEmpAnnWa'], "text"),
GetSQLValueString($_POST['GuEmpPayroll'], "text"),
GetSQLValueString($_POST['GuSelfEmp'], "text"),
GetSQLValueString($_POST['GuHaveAcc'], "text"),
GetSQLValueString($_POST['GuAccName'], "text"),
GetSQLValueString($_POST['GuAccContName'], "text"),
GetSQLValueString($_POST['GuAccAdd'], "text"),
GetSQLValueString($_POST['GuAccDayTel'], "text"),
GetSQLValueString($_POST['GuAccMobTel'], "text"),
GetSQLValueString($_POST['GuAccEmail'], "text"),
GetSQLValueString($_POST['GuAccAdditional'], "text"),
GetSQLValueString($_POST['GuEmployerNam'], "text"),
GetSQLValueString($_POST['GuEmployerAdd'], "text"),
GetSQLValueString($_POST['GuEmployerContactName'], "text"),
GetSQLValueString($_POST['GuEmployerTele'], "text"),
GetSQLValueString($_POST['GuEmployerEmail'], "text"),
GetSQLValueString(isset($_POST['GuEmployerCCj']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['GuEmployerArr']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['GuEmployerBankR']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['GuEmployerNone']) ? "true" : "", "defined","'Y'","'N'"));

mysql_select_db($database_hostprop, $hostprop);
$Result1 = mysql_query($insertSQL, $hostprop) or die(mysql_error());


so are you saying i need to add another colomn to the property DB and call it availibilty, mark it has 0 when it has been selected.?

where would the sql query go that you provided?

thanks

would it be easier to do this automatically so as soon as the form is submitted it changes the column to 1?

thanks

Re: show of hide a record using php

Posted: Thu May 10, 2012 9:32 am
by x_mutatis_mutandis_x
jonnyfortis wrote:so are you saying i need to add another colomn to the property DB and call it availibilty, mark it has 0 when it has been selected.?
If you want the property to be marked 0 (or "unavailable") for all students. The column should be in your property table.
where would the sql query go that you provided?
Whereever you are obtaining the $row_rsApplyNow array from
would it be easier to do this automatically so as soon as the form is submitted it changes the column to 1?
You can but when you refresh the page with fresh data from database, it will be lost.

On a separate note, have you looked into the possiblity of normalizing your "plus_signup" table?

Re: show of hide a record using php

Posted: Thu May 10, 2012 9:44 am
by jonnyfortis
jonnyfortis wrote:
so are you saying i need to add another colomn to the property DB and call it availibilty, mark it has 0 when it has been selected.?

If you want the property to be marked 0 (or "unavailable") for all students. The column should be in your property table.

>>>OK i will add this to the db


where would the sql query go that you provided?
Whereever you are obtaining the $row_rsApplyNow array from

ok i need to look at this then


would it be easier to do this automatically so as soon as the form is submitted it changes the column to 1?
You can but when you refresh the page with fresh data from database, it will be lost.

On a separate note, have you looked into the possiblity of normalizing your "plus_signup" table?

No whats that?

Re: show of hide a record using php

Posted: Thu May 10, 2012 9:50 am
by x_mutatis_mutandis_x

Re: show of hide a record using php

Posted: Thu May 10, 2012 9:53 am
by jonnyfortis
maybe next time.

Re: show of hide a record using php

Posted: Thu May 10, 2012 9:58 am
by jonnyfortis
getting back to

Whereever you are obtaining the $row_rsApplyNow array from


this is the sql

mysql_select_db($database_hostprop, $hostprop);
$query_rsApplyNow = "SELECT * FROM host_editprop";
$rsApplyNow = mysql_query($query_rsApplyNow, $hostprop) or die(mysql_error());
$row_rsApplyNow = mysql_fetch_assoc($rsApplyNow);
$totalRows_rsApplyNow = mysql_num_rows($rsApplyNow);


so i would change it to

mysql_select_db($database_hostprop, $hostprop);
$query_rsApplyNow = "SELECT * FROM host_editprop WHERE available = 0";
$rsApplyNow = mysql_query($query_rsApplyNow, $hostprop) or die(mysql_error());
$row_rsApplyNow = mysql_fetch_assoc($rsApplyNow);
$totalRows_rsApplyNow = mysql_num_rows($rsApplyNow);

Re: show of hide a record using php

Posted: Thu May 10, 2012 1:32 pm
by jonnyfortis
yes that worked, thanks for you help :D