• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can you change Layout of php and filter?

Guest
May 25, 2009 May 25, 2009

Copy link to clipboard

Copied

HI All,

I have some code:

function tc($v) {

if (!$v) {

return 'NULL';

} else {

return '\''.mysql_real_escape_string($v).'\'';

}

}


$field = array(

array("surname", "Surname"),

array("forename", "Forename(s)"),

array("address", "Address"),

array("post_code", "Post Code"),

array("telephone1", "Telephone Number"),

array("telephone2",  "Alternative Number 1"),

array("telephone3", "Alternative Number 2"),

array("dob", "Date of Birth"),

array("gender", "Gender"),

array("religion", "Religion"),

array("special", "Disabilities / Special Needs"),

array("mother_name", "Mother Name"),

array("mother_occ", "Mother Occupation"),

array("mother_crb", "Mother CRB?"),

array("father_name", "Father Name"),

array("father_occ", "Father Occupation"),

array("father_crb", "Father CRB?"),

array("email", "Email Address"),

array("subs", "Subs"),

array("GA", "Gift Aid Signed?"),

array("dpa", "DPA Signed?"),

array("editby", "Record last edited by"),

array("edittime", "Record last edited at"),

array('datejoined', 'Date Joined'),

array('year1', 'Year One Badge'),

array('year2', 'Year Two Badge'),

array('year3', 'Year Three Badge'),

array('year4', 'Year Four Badge'),

array('year5', 'Year Five Badge'),

array('year6', 'Year Six Badge'),

array('year7', 'Year Seven Badge'),

array('year8', 'Year Eight Badge'),

array('year9', 'Year Nine Badge'),

array('EA1', 'Emergency Aid Stage 1'),

array('EA2', 'Emergency Aid Stage 2'),

array('EA3', 'Emergency Aid Stage 3'),

array('EA4', 'Emergency Aid Stage 4'),

array('EA5', 'Emergency Aid Stage 5'),

array('HA1', 'Hikes Away Stage 1'),

array('HA2', 'Hikes Away Stage 2'),

array('HA3', 'Hikes Away Stage 3'),

array('HA4', 'Hikes Away Stage 4'),

array('HA5', 'Hikes Away Stage 5'),

array('HA6', 'Hikes Away Stage 6'),

array('IT1', 'IT Stage 1'),

array('IT2', 'IT Stage 2'),

array('IT3', 'IT Stage 3'),

array('IT4', 'IT Stage 4'),

array('IT5', 'IT Stage 5'),


array('music1', 'Musician Stage 1'),

array('music2', 'Musician Stage 2'),

array('music3', 'Musician Stage 3'),

array('music4', 'Musician Stage 4'),

array('music5', 'Musician Stage 5'),


array('NAtotal', 'Total Nights Away'),

array('NA1', 'Nights Away Stage 1'),

array('NA2', 'Nights Away Stage 2'),

array('NA3', 'Nights Away Stage 3'),

array('NA4', 'Nights Away Stage 4'),

array('NA5', 'Nights Away Stage 5'),

array('NA6', 'Nights Away Stage 6'),

array('NA7', 'Nights Away Stage 7'),

array('NA8', 'Nights Away Stage 8'),

array('NA9', 'Nights Away Stage 9'),

array('NA10', 'Nights Away Stage 10'),

array('NA11', 'Nights Away Stage 11'),

array('NA12', 'Nights Away Stage 12'),


array('swim1', 'Swimming Stage 1'),

array('swim2', 'Swimming Stage 2'),

array('swim3', 'Swimming Stage 3'),

array('swim4', 'Swimming Stage 4'),

array('swim5', 'Swimming Stage 5'),

array('OCDATE', 'SCOUTS: Outdoor Challenge'),

array('OPCDATE', 'SCOUTS: Outdoor Plus Challenge'),

array('ACDATE', 'SCOUTS: Adventure Challenge'),

array('CCDATE', 'SCOUTS: Creative Challenge')

);


if ($user = User()) {


if ($_POST['section'])  {

if (UserRead($_POST['section']) || UserAdmin()) {

echo '<h1>1st Chalfont St Giles Scout Group - ';

$lsec_query = mysql_query('SELECT * FROM csg_section WHERE section='.tc($_POST['section'])) or die("<b>MySql Error:</b>".mysql_error());

if ($lsec = mysql_fetch_array($lsec_query)) {

echo $lsec['name']."\n</h1>";

} else {

echo 'Section Not Found</h1>';

die();

}

echo '<table border="2"><tr>'."\n";

foreach ($field as $item) {

if ($_POST[$item[0]]==1) {

$fielddo[] = $item;

echo '<td>'.$item[1].'</td>'."\n";

}

}

echo '</tr>';

switch($_POST['sort']) {

case 'a':

$sort = 'surname ASC, forename ASC';

break;

default:

$sort = 'dob ASC';

}


$ypl_query = mysql_query("SELECT * FROM csg_yp WHERE section=".tc($_POST['section'])." ORDER BY $sort") or die('<b>MySql Error:</b>'.mysql_error());

while ($ypl = mysql_fetch_array($ypl_query)) {

echo '<tr>'."\n";

foreach ($fielddo as $item)

echo '<td>'.$ypl[$item[0]].'</td>'."\n";

echo '</tr>'."\n";

}

echo '</table>'."\n";


} else {

?>

<p><b>Access Denied.</b> You are not authorised to view this section.

<?

}

} else {

?>

All this does is produce a list of all the fields in the database in a long list so we can choose which fields to print.

As this list is now growing as we have added a lot more fields to the database ... is there anyway we could split it into say 3 columns?

Ideally the first column would be all the personal details - i.e. down to DPA Signed - Second column would be the other badges and the third column different depending on the section.

On the data input page we have different badges depending on section. Using the following code:

if ($action=='add' || ($action=='edit' && (UserRead($yp['section']) || UserAdmin()))) {


$yp_section_query = mysql_query("SELECT name FROM csg_section WHERE section=".tc($yp['section'])) or die("<b>MySql Error:</b>".mysql_error());

$yp_name = mysql_fetch_assoc($yp_section_query);

$yp_name = $yp_name['name'];

$yp_section = (strstr($yp_name,"Scout")) ? 1 : (strstr($yp_name,"Cub") ? 2 : 3) //If has word 'scout' -> 1. Else If has word 'cub' -> 2 Else 3 (beaver)

?>

<form action="yp2.php" method="post">

<input type="hidden" name="yp" value="<?php echo $yp['yp_id']; ?>">

<input type="hidden" name="section" value="<?php echo $yp['section']; ?>">

could we use this on the print page to show different badge list depending on section in the third column??

Many Thanks,

Steve

TOPICS
Server side applications

Views

711

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 26, 2009 May 26, 2009

Copy link to clipboard

Copied

Mmh, dèja-vu? Looks familiar somehow. A simple way would be to split the array, then put sections into the separate table columns. The proper way would be to expand your database with categories and sort based on that...

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 26, 2009 May 26, 2009

Copy link to clipboard

Copied

I am not sure how it looks familiar ... are you in Scouting too?

So can i just create columns and put the different bits in each column?

How can I sort by database - sorry I am a bit of a novice when it comes to php and coding, etc.

Also was it able to filter depending on section?

Many Thanks,

Steve

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 26, 2009 May 26, 2009

Copy link to clipboard

Copied

Thread moved to Dreamweaver Application Development.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 27, 2009 May 27, 2009

Copy link to clipboard

Copied

LATEST

Hi David,

Sorry for putting my question in the wrong forum.

I am sure what I am trying to do is very easy to you - is there any chance you could help me?

Many Thanks,

Steve

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines