To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Coding

Coding Help with PHP coding

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-03-2009, 03:45 PM   #1
BuzzStPoint
Junior Member
 
Join Date: Nov 2009
Posts: 17
Need help with coding.

I'm working on a project. I have a pool test log I use and I am now making it out of php and mysql.

I am new to php and sql but I have most of it working. But I have ran into a few issues.

In my Index.php file i have an includesfor a
connect.php, a header and 31 includes for day1-31

This This brings out a nice monthly tables. In each day php file is a simple table that pulls data from the database and an update link. Then it goes to an update file where I can change the values.

It works.. But I have found a problem. What happens when the month is over?
The way i have is set up, I would have to change the include days in the index.php.

Is there a way I can have a drop down on the index to select the month and year. Once selected, it would only use the include files. January for Jan, February for feb.. and so on..

I'm not sure how to approach this, but I was thinking an If statement.
If I am correct in this, how would I go about writing this out?
BuzzStPoint is offline   Reply With Quote
Old 11-03-2009, 04:30 PM   #2
jaql
Member
 
Join Date: Jun 2009
Posts: 58
Post what you have so far.

And don't forget to wrap the code so it's easier to read
jaql is offline   Reply With Quote
Old 11-03-2009, 05:11 PM   #3
BuzzStPoint
Junior Member
 
Join Date: Nov 2009
Posts: 17
Ok here's what I have:

index.php
Code:
<?php
include("connect.php");
?>


<html>
  <head>
  <link rel="stylesheet" type="text/css" href="style1.css" />
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <meta name="generator" content="PSPad editor, www.pspad.com">
  <title>Pool Log Report</title>
  </head>
  <body class="body">
  <center>
<table class="main1">

<?php
// header information files. 
include("header.php");

// Body information files below. 
include("month/1/day1.php");
include("month/1/day2.php");
include("month/1/day3.php");
include("month/1/day4.php");
include("month/1/day5.php");
include("month/1/day6.php");
include("month/1/day7.php");
include("month/1/day8.php");
include("month/1/day9.php");
include("month/1/day10.php");

// Footer information, reserved for calulations.

?> 

 </table>
</center>
  </body>
</html>
Daily php files.
day1.php
Code:
<?php

include("connect.php");
// Query information to pull information from database
 
$query="SELECT * FROM January_Whirl WHERE Dayid=1";
$result=mysql_query($query);
$num = mysql_num_rows ($result);
mysql_close();

if ($num > 0 ) {
$i=0;
while ($i < $num) {
$patron_loading_max_1 = mysql_result($result,$i,"patron_loading_max");
$patron_loading_24hr_1 = mysql_result($result,$i,"patron_loading_24hr");
$water_clearity__clear_1 = mysql_result($result,$i,"water_clearity__clear");
$water_clearity__turbid_1 = mysql_result($result,$i,"water_clearity__turbid");
$water_temp_1 = mysql_result($result,$i,"water_temp");
$psi_1 = mysql_result($result,$i,"psi");
$gpm_1 = mysql_result($result,$i,"gpm");
$drain_back_1 = mysql_result($result,$i,"drain_back");
$chlorine_am1_1 = mysql_result($result,$i,"chlorine_am1");
$chlorine_am2_1 = mysql_result($result,$i,"chlorine_am2");
$chlorine_pm1_1 = mysql_result($result,$i,"chlorine_pm1");
$chlorine_pm2_1 = mysql_result($result,$i,"chlorine_pm2");
$ph_am1_1 = mysql_result($result,$i,"ph_am1");
$ph_am2_1 = mysql_result($result,$i,"ph_am2");
$ph_pm1_1 = mysql_result($result,$i,"ph_pm1");
$ph_pm2_1 = mysql_result($result,$i,"ph_pm2");
$combined_chl_1 = mysql_result($result,$i,"combined_chl");
$alkalinity_1 = mysql_result($result,$i,"alkalinity");
$chemicals_add_1 = mysql_result($result,$i,"chemicals_add");
$chemicals_qty_1 = mysql_result($result,$i,"chemicals_qty");
$super_oxidation_1 = mysql_result($result,$i,"super_oxidation");
$Dayid = mysql_result($result,$i,"Dayid");

++$i; } } else { echo "The database is empty"; }

// below is the HTML table information for the day
?>

  <tr>
    <td class="main2">1</td>
    <td class="main3">&nbsp;</td>
    <td class="main3"><?php echo "$patron_loading_max_1"; ?></td>
    <td class="main3"><?php echo "$patron_loading_24hr_1"; ?></td>
    <td class="main3"><?php echo "$water_clearity__clear_1"; ?></td>
    <td class="main3"><?php echo "$water_clearity__turbid_1"; ?></td>
    <td class="main3"><?php echo "$water_temp_1"; ?></td>
    <td class="main3"><?php echo "$psi_1"; ?></td>
    <td class="main3"><?php echo "$gpm_1"; ?></td>
    <td class="main3"><?php echo "$drain_back_1"; ?></td>
    <td class="main3"><?php echo "$chlorine_am1_1"; ?></td>
    <td class="main3"><?php echo "$chlorine_am2_1"; ?></td>
    <td class="main3"><?php echo "$ph_am1_1"; ?></td>
    <td class="main3"><?php echo "$ph_am2_1"; ?></td>
    <td class="main3"><?php echo "$chlorine_pm1_1"; ?></td>
    <td class="main3"><?php echo "$chlorine_pm2_1"; ?></td>
    <td class="main3"><?php echo "$ph_pm1_1"; ?></td>
    <td class="main3"><?php echo "$ph_pm2_1"; ?></td>
    <td class="main3"><?php echo "$combined_chl_1"; ?></td>
    <td class="main3"><?php echo "$alkalinity_1"; ?></td>
    <td class="main3"><?php echo "$chemicals_add_1"; ?></td>
    <td class="main3"><?php echo "$chemicals_qty_1"; ?></td>
    <td class="main3"><?php echo "$super_oxidation_1"; ?></td>
    <td class="main3">&nbsp;</td>
    <td class="main3"><? echo "<a href=\"month/1/day1_update.php?id=$Dayid\"> Update</a> - <a href=\"delete.php?id=$id\">Delete</a>"; ?>
  </tr>

day1_update.php

Code:
<?php

include("../../connect.php");
// Not sure if I need the Get command.
$Dayid = $_GET['Dayid'];

$qProfile = "SELECT * FROM January_Whirl WHERE Dayid='1'  ";
$rsProfile = mysql_query($qProfile); 
$row = mysql_fetch_array($rsProfile);
extract($row);
$patron_loading_max = stripslashes($patron_loading_max);
$patron_loading_24hr = stripslashes($patron_loading_24hr);
$water_clearity__clear = stripslashes($water_clearity__clear);
$water_clearity__turbid = stripslashes($water_clearity__turbid);
$water_temp = stripslashes($water_temp);
$psi = stripslashes($psi);
$gpm = stripslashes($gpm);
$drain_back = stripslashes($drain_back);
$chlorine_am1 = stripslashes($chlorine_am1);
$chlorine_am2 = stripslashes($chlorine_am2);
$ph_am1 = stripslashes($ph_am1);
$ph_am2 = stripslashes($ph_am2);
$chlorine_pm1 = stripslashes($chlorine_pm1);
$chlorine_pm2 = stripslashes($chlorine_pm2);
$ph_pm1 = stripslashes($ph_pm1);
$ph_pm2 = stripslashes($ph_pm2);
$combined_chl = stripslashes($combined_chl);
$alkalinity = stripslashes($alkalinity);
$chemicals_add = stripslashes($chemicals_add);
$chemicals_qty = stripslashes($chemicals_qty);
$super_oxidation = stripslashes($super_oxidation);

mysql_close();?>


<html>
  <head>
  <link rel="stylesheet" type="text/css" href="../../style1.css" />
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <meta name="generator" content="PSPad editor, www.pspad.com">
  <title>Pool Log Report</title>
  </head>
  <body class="body">
  <center>
<table class="main1">
<?php
include("../../update_header.php");
?>

<form id="FormName" action="day1_updated.php" method="post" name="FormName"> 
<tr>
    <td class="main2">1</td>
    <td class="main3">&nbsp;</td>
    <td class="main3"><input id="patron_loading_max" name="patron_loading_max" type="text" size="1" value="<?php echo $patron_loading_max ?>" maxlength="2"></td>
    <td class="main3"><input id="patron_loading_24hr" name="patron_loading_24hr" type="text" size="1" value="<?php echo $patron_loading_24hr ?>" maxlength="2"></td>
    <td class="main3"><input id="water_clearity__clear" name="water_clearity__clear" type="checkbox" <?php if ($water_clearity__clear == "Y") { echo "checked";} ?> value="Y"></td>
    <td class="main3"><input id="water_clearity__turbid" name="water_clearity__turbid" type="checkbox" <?php if ($water_clearity__turbid == "Y") { echo "checked";} ?> value="Y"></td>
    <td class="main3"><input id="water_temp" name="water_temp" type="text" size="1" value="<?php echo $water_temp ?>" maxlength="3"></td>
    <td class="main3"><input id="psi" name="psi" type="text" size="1" value="<?php echo $psi ?>" maxlength="3"></td>
    <td class="main3"><input id="gpm" name="gpm" type="text" size="1" value="<?php echo $gpm ?>" maxlength="3"></td>
    <td class="main3"><input id="drain_back" name="drain_back" type="text" size="1" value="<?php echo $drain_back ?>" maxlength="5"></td>
    <td class="main3"><input id="chlorine_am1" name="chlorine_am1" type="text" size="1" value="<?php echo $chlorine_am1 ?>" maxlength="5"></td>
    <td class="main3"><input id="chlorine_am2" name="chlorine_am2" type="text" size="1" value="<?php echo $chlorine_am2 ?>" maxlength="5"></td>
    <td class="main3"><input id="ph_am1" name="ph_am1" type="text" size="1" value="<?php echo $ph_am1 ?>" maxlength="5"></td>
    <td class="main3"><input id="ph_am2" name="ph_am2" type="text" size="1" value="<?php echo $ph_am2 ?>" maxlength="5"></td>
    <td class="main3"><input id="chlorine_pm1" name="chlorine_pm1" type="text" size="1" value="<?php echo $chlorine_pm1 ?>" maxlength="5"></td>
    <td class="main3"><input id="chlorine_pm2" name="chlorine_pm2" type="text" size="1" value="<?php echo $chlorine_pm2 ?>" maxlength="5"></td>
    <td class="main3"><input id="ph_pm1" name="ph_pm1" type="text" size="1" value="<?php echo $ph_pm1 ?>" maxlength="5"></td>
    <td class="main3"><input id="ph_pm2" name="ph_pm2" type="text" size="1" value="<?php echo $ph_pm2 ?>" maxlength="5"></td>    
    <td class="main3"><input id="combined_chl" name="combined_chl" type="text" size="1" value="<?php echo $combined_chl ?>" maxlength="4"></td>
    <td class="main3"><input id="alkalinity" name="alkalinity" type="text" size="1" value="<?php echo $alkalinity ?>" maxlength="3"></td>
    <td class="main3"><input id="chemicals_add" name="chemicals_add" type="text" size="1" value="<?php echo $chemicals_add ?>" maxlength="55"></td>
    <td class="main3"><input id="chemicals_qty" name="chemicals_qty" type="text" size="1" value="<?php echo $chemicals_qty ?>" maxlength="55"></td>
    <td class="main3"><input id="super_oxidation" name="super_oxidation" type="text" size="1" value="<?php echo $super_oxidation ?>" maxlength="3"></td>
    <td class="main3">&nbsp;</td>
</tr>
<tr>
    <td colspan="24" align="center" class="main2">Make your changes and click the update button below.</td>
</tr>
<tr>     
     <td colspan="24" align="center" class="main2"><input type="submit" name="submitButtonName" value="Update"><input type="hidden" name="id" value="<?php echo $id ?>"></td>
</tr>
</table>
</form>
</center>
See next post...
BuzzStPoint is offline   Reply With Quote
Old 11-03-2009, 05:11 PM   #4
BuzzStPoint
Junior Member
 
Join Date: Nov 2009
Posts: 17
day1_updated.php
Code:
<a href="../../index.php">Back to List</a><br>
<br>
<?php

include("../../connect.php");

$Dayid = $_POST['1'];
$patron_loading_max = $_POST['patron_loading_max'];
$patron_loading_24hr = $_POST['patron_loading_24hr'];
$water_clearity__clear = $_POST['water_clearity__clear'];
$water_clearity__turbid = $_POST['water_clearity__turbid'];
$water_temp = $_POST['water_temp'];
$psi = $_POST['psi'];
$gpm = $_POST['gpm'];
$drain_back = $_POST['drain_back'];
$chlorine_am1 = $_POST['chlorine_am1'];
$chlorine_am2 = $_POST['chlorine_am2'];
$chlorine_pm1 = $_POST['chlorine_pm1'];
$chlorine_pm2 = $_POST['chlorine_pm2'];
$ph_am1 = $_POST['ph_am1'];
$ph_am2 = $_POST['ph_am2'];
$ph_pm1 = $_POST['ph_pm1'];
$ph_pm2 = $_POST['ph_pm2'];
$combined_chl = $_POST['combined_chl'];
$alkalinity = $_POST['alkalinity'];
$chemicals_add = $_POST['chemicals_add'];
$chemicals_qty = $_POST['chemicals_qty'];
$super_oxidation = $_POST['super_oxidation'];

$update = "UPDATE January_Whirl SET patron_loading_max = '$patron_loading_max', patron_loading_24hr = '$patron_loading_24hr', water_clearity__clear = '$water_clearity__clear', water_clearity__turbid = '$water_clearity__turbid', water_temp = '$water_temp', psi = '$psi', gpm = '$gpm', drain_back = '$drain_back', chlorine_am1 = '$chlorine_am1', chlorine_am2 = '$chlorine_am2', chlorine_pm1 = '$chlorine_pm1', chlorine_pm2 = '$chlorine_pm2', ph_am1 = '$ph_am1', ph_am2 = '$ph_am2', ph_pm1 = '$ph_pm1', ph_pm2 = '$ph_pm2', combined_chl = '$combined_chl', alkalinity = '$alkalinity', chemicals_add = '$chemicals_add', chemicals_qty = '$chemicals_qty', super_oxidation = '$super_oxidation' WHERE Dayid='1' ";
$rsUpdate = mysql_query($update);
if ($rsUpdate)
{
echo "Update successful.";
} mysql_close();
?>
[





Then each row of the table has it's own 3 files as I show above, Instead of day1.php it would be day2.php, through day31.php
BuzzStPoint is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 04:23 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.