Jump to content

Azyrus

New Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Azyrus

  1. Sorry for not clarifying guys, the ELSE statement is working correctly as it is intended the first part of the IF statement is not displaying ALL records as it is expected. Any ideas?
  2. Hello, my code below seems to work great when you enter a value into the input however it does not return all values when the input is empty. It shows rows 1-5 and 79-95 does anyone know how this is happening? Thank you ! <div id="main"> <form method="post" action=""> <div id="search_query"> Keyword: <input type="text" name="brand"> <input type="submit" name="submit" value="submit"> </div> </form> <div id="main_container"> <?php $db_con = mysql_connect('localhost', 'hwsuser', 'password'); if (!$db_con) { die('Could not connect: ' . mysql_error()); } mysql_select_db('hws', $db_con); if(!isset($_POST['submit'])) { $sql = sprintf("SELECT * FROM hws"); $result = mysql_query($sql); echo "<table>"; echo "<tr>"; echo "<th scope='col'>ID</th>"; echo "<th scope='col'>Brand</th>"; echo "<th scope='col'>Model</th>"; echo "<th scope='col'>Capacity</th>"; echo "<th scope='col'>Loading</th>"; echo "<th scope='col'>Elements</th>"; echo "<th scope='col'>Type</th>"; echo "<th scope='col'>Warranty</th>"; echo "<th scope='col'>Reece</th>"; echo "<th scope='col'>Coop</th>"; echo "<th scope='col'>Samios</th>"; echo "<th scope='col'>KR</th>"; echo "<th scope='col'>BBK</th>"; echo "<th scope='col'>Supply</th>"; echo "<th scope='col'>Continuous</th>"; echo "<th scope='col'>Offpeak</th>"; echo "</tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>$row[ID]</td>"; echo "<td>$row[Brand]</td>"; echo "<td>$row[Model]</td>"; echo "<td>$row[Capacity]</td>"; echo "<td>$row[Loading]</td>"; echo "<td>$row[Elements]</td>"; echo "<td>$row[Type]</td>"; echo "<td>$row[Warranty]</td>"; echo "<td>$row[Reece]</td>"; echo "<td>$row[Coop]</td>"; echo "<td>$row[Samios]</td>"; echo "<td>$row[KR]</td>"; echo "<td>$row[BBK]</td>"; echo "<td>$row[Supply]</td>"; echo "<td>$row[Continuous]</td>"; echo "<td>$row[Offpeak]</td>"; echo "</tr>"; } echo "</table>"; } else { $brand = mysql_real_escape_string($_POST['brand']); $sql = sprintf("SELECT * FROM units WHERE Brand LIKE'$brand' OR Model LIKE'$brand' OR Capacity LIKE'$brand' OR Type LIKE'$brand'"); $result = mysql_query($sql); echo "<table class='altrowstable' id='alternatecolor'>"; echo "<tr>"; echo "<th scope='col'>ID</th>"; echo "<th scope='col'>Brand</th>"; echo "<th scope='col'>Model</th>"; echo "<th scope='col'>Capacity</th>"; echo "<th scope='col'>Loading</th>"; echo "<th scope='col'>Elements</th>"; echo "<th scope='col'>Type</th>"; echo "<th scope='col'>Warranty</th>"; echo "<th scope='col'>Reece</th>"; echo "<th scope='col'>Coop</th>"; echo "<th scope='col'>Samios</th>"; echo "<th scope='col'>KR</th>"; echo "<th scope='col'>BBK</th>"; echo "<th scope='col'>Supply</th>"; echo "<th scope='col'>Continuous</th>"; echo "<th scope='col'>Offpeak</th>"; echo "</tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>$row[ID]</td>"; echo "<td>$row[Brand]</td>"; echo "<td>$row[Model]</td>"; echo "<td>$row[Capacity]</td>"; echo "<td>$row[Loading]</td>"; echo "<td>$row[Elements]</td>"; echo "<td>$row[Type]</td>"; echo "<td>$row[Warranty]</td>"; echo "<td>$row[Reece]</td>"; echo "<td>$row[Coop]</td>"; echo "<td>$row[Samios]</td>"; echo "<td>$row[KR]</td>"; echo "<td>$row[BBK]</td>"; echo "<td>$row[Supply]</td>"; echo "<td>$row[Continuous]</td>"; echo "<td>$row[Offpeak]</td>"; echo "</tr>"; } echo "</table>"; }
  3. SHOW CREATE TABLE reservations *thanks kicken Table Create Table reservations CREATE TABLE `reservations` ( `resid` char(16) NOT NULL, `machid` char(16) NOT NULL, `scheduleid` char(16) NOT NULL, `start_date` int(11) NOT NULL DEFAULT '0', `end_date` int(11) NOT NULL DEFAULT '0', `starttime` int(11) NOT NULL, `endtime` int(11) NOT NULL, `created` int(11) NOT NULL, `modified` int(11) DEFAULT NULL, `parentid` char(16) DEFAULT NULL, `is_blackout` smallint(6) NOT NULL DEFAULT '0', `is_pending` smallint(6) NOT NULL DEFAULT '0', `summary` text, `allow_participation` smallint(6) NOT NULL DEFAULT '0', `allow_anon_participation` smallint(6) NOT NULL DEFAULT '0', `environment` char(50) DEFAULT NULL, `last_name` char(50) DEFAULT NULL, `company` char(50) DEFAULT NULL, `phone_number` char(50) DEFAULT NULL, `site_address` char(50) DEFAULT NULL, `site_suburb` char(50) DEFAULT NULL, `site_postcode` char(50) DEFAULT NULL, `postal_address` char(50) DEFAULT NULL, `postal_suburb` char(50) DEFAULT NULL, `postal_postcode` char(50) DEFAULT NULL, `job_type` char(50) DEFAULT NULL, `payment_type` char(50) DEFAULT NULL, `payment_status` char(50) DEFAULT NULL, `job_source` char(50) DEFAULT NULL, `quote_outcome` char(50) DEFAULT NULL, `quote_amount` char(50) DEFAULT NULL, `quote_employee` char(50) DEFAULT NULL, `job_income` char(50) DEFAULT NULL, `job_materials` char(50) DEFAULT NULL, `invoice_number` char(50) DEFAULT NULL, `job_notes` char(50) DEFAULT NULL, PRIMARY KEY (`resid`), KEY `res_machid` (`machid`), KEY `res_scheduleid` (`scheduleid`), KEY `reservations_startdate` (`start_date`), KEY `reservations_enddate` (`end_date`), KEY `res_startTime` (`starttime`), KEY `res_endTime` (`endtime`), KEY `res_created` (`created`), KEY `res_modified` (`modified`), KEY `res_parentid` (`parentid`), KEY `res_isblackout` (`is_blackout`), KEY `reservations_pending` (`is_pending`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1
  4. Currently we have a Microsoft Access database which we use to display a report, we are rolling over to PHP/SQL online for greater control e.t.c. So far we have the report pulling all the information from the database however we need to group this information by Day followed by Employee, sorted by time and then totaled for each Employee for each day. Below is the code we have so far which only prints columns how do we go about displaying it like the access screenshot. Attached is an example of the Microsoft Access report we have. <?php $username='admin'; $password='password'; $database='planner'; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM reservations ORDER BY start_date, machid, starttime"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <?php $i=0; while ($i < $num) { $f0=mysql_result($result,$i,"machid"); $f1=mysql_result($result,$i,"start_date"); $f2=mysql_result($result,$i,"end_date"); $f3=mysql_result($result,$i,"starttime"); $f4=mysql_result($result,$i,"endtime"); $f5=mysql_result($result,$i,"first_name"); $f6=mysql_result($result,$i,"last_name"); $f7=mysql_result($result,$i,"company"); $f8=mysql_result($result,$i,"phone_number"); $f9=mysql_result($result,$i,"site_address"); $f10=mysql_result($result,$i,"site_suburb"); $f11=mysql_result($result,$i,"site_postcode"); $f12=mysql_result($result,$i,"postal_address"); $f13=mysql_result($result,$i,"postal_suburb"); $f14=mysql_result($result,$i,"postal_postcode"); $f15=mysql_result($result,$i,"job_type"); $f16=mysql_result($result,$i,"payment_type"); $f17=mysql_result($result,$i,"payment_status"); $f18=mysql_result($result,$i,"quote_outcome"); $f19=mysql_result($result,$i,"quote_amount"); $f20=mysql_result($result,$i,"quote_employee"); $f21=mysql_result($result,$i,"job_income"); $f22=mysql_result($result,$i,"job_materials"); $f23=mysql_result($result,$i,"invoice_number"); $f24=mysql_result($result,$i,"job_notes"); /* START TIME */ $stime = $f3; $shour = floor($stime/60); $smin = str_pad($stime % 60,2,0,STR_PAD_LEFT); //echo $hour.':'.$min; //echo '<br><br>'; // For AM/PM $shalf = 'am'; if( $shour > 12 ) { $shalf = 'pm'; $shour -= 12; } $stime = $shour.':'.$smin.' '.$shalf; /* END TIME */ $etime = $f4; $ehour = floor($etime/60); $emin = str_pad($etime % 60,2,0,STR_PAD_LEFT); //echo $hour.':'.$min; //echo '<br><br>'; // For AM/PM $ehalf = 'am'; if( $ehour > 12 ) { $ehalf = 'pm'; $ehour -= 12; } $etime = $ehour.':'.$emin.' '.$ehalf; ?> <table width="3500px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="125px"><?php echo $f0; ?></td> <td width="80px"><?php echo date('d-m-y', "$f1"); ?></td> <td width="50px" style="text-align:right;"><?php echo $stime; ?></td> <td width="50px" style="text-align:right; padding-right:20px;"><?php echo $etime; ?></td> <td width="100px"><?php echo $f5; ?></td> <td width="100px"><?php echo $f6; ?></td> <td width="100px"><?php echo $f7; ?></td> <td width="100px"><?php echo $f8; ?></td> <td width="100px"><?php echo $f9; ?></td> <td width="100px"><?php echo $f10; ?></td> <td width="100px"><?php echo $f11; ?></td> <td width="100px"><?php echo $f12; ?></td> <td width="100px"><?php echo $f13; ?></td> <td width="100px"><?php echo $f14; ?></td> <td width="100px"><?php echo $f15; ?></td> <td width="100px"><?php echo $f16; ?></td> <td width="100px"><?php echo $f17; ?></td> <td width="100px"><?php echo $f18; ?></td> <td width="100px"><?php echo $f19; ?></td> <td width="100px"><?php echo $f20; ?></td> <td width="100px"><?php echo $f21; ?></td> <td width="100px"><?php echo $f22; ?></td> <td width="100px"><?php echo $f23; ?></td> <td width="100px"><?php echo $f24; ?></td> <?php $i++; } ?> Once again thanks everyone at phpfreaks!
  5. Thank you very much xyph! It looks so technical! I would never have got it myself...
  6. Hi guys, Thanks so much for your help I'll try my best to remember to use php.net from now on! The format is perfect but I think I need to do something to the time value. In the database seems to store time in minutes the value for 6am is an integer of 360, 7am would be 420 and so on... (This is my understanding which could be wrong). Using the code below: <?php echo date("g:ia","$f4"); ?> The output for 360 which is 6am = 1:06am. Does anyone know how to do this? Thanks a lot! I really appreciate your help guys
  7. Hi everyone I have a column in an sql database which stores time in minutes. I'm trying to turn these minutes into this kind of format: 1:00pm 12:30am 6:15pm I looked on W3C and there was the %r which seemed to format this way but I cant get it to work >.< $time1=$f3/60; $time2= date_format($f4, '%r'); Does anyone know how to achieve this? THANKS!!!
  8. Requinix I love you! You are my HERO! This works 100%
  9. Hello everyone I'm modifying an open source software called phpScheduleIt, I'm trying to change the machid function based on the $type variable and I'm getting this error below: Parse error: syntax error, unexpected T_IF, expecting T_FUNCTION in C:\xampp\htdocs\phpScheduleIt\lib\Reservation.class.php on line 1122 1122 if ($type == RES_TYPE_ADD) 1123 function get_machid() { 1124 return $this->resource->get_property('machid'); 1125 } 1126 if ($type == RES_TYPE_MODIFY) 1127 function get_machid() { 1128 return $this->machid; 1129 } I don't understand why this isn't working :\ phpSchedule it is a really great free open source scheduling software if anyone is interested, full credits to Nick Korbel. http://php.brickhost.com
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.