PHP - Document_root Help Needed
Hi
I have this bit of code: Code: [Select] defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('SITE_ROOT') ? null : define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes'); That i'm using so all systems can always find my class and important files. This works fine on on of my websites, but I have just moved it over to another website (exact setup & on same server) and it is not working!!! I'm getting the error: Warning: require_once(/includes/functions.php) [function.require-once]: failed to open stream: No such file or directory in /home/a/d/adele/web/public_html/includes/initialize.php on line 9 Fatal error: require_once() [function.require]: Failed opening required '/includes/functions.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/a/d/adele/web/public_html/includes/initialize.php on line 9 Basically, all my important files are in the initialize.php file. So I only need to call that one file on any of my html pages. I know it's DOCUMENT_ROOT, as when I remove this and link direct it works fine. Thanks for any help Similar TutorialsHi i call $_SERVER['DOCUMENT_ROOT'] which returns C:/xampp/htdocs how would i make it return C:/xampp/ instead? Hi there, I am working on a website which has a sub-domain set as a folder and not an actual sub-domain (as my client does not want to do this which is another story). Anyway, all of my links which relate to the DOCUMENT_ROOT are not working. Example below: www.website.com www.website.com/admin - my sub-domain in a folder I can access a page within www.website.com/admin however all links to files, css files etc will not work because the DOCUMENT_ROOT does not inlcude the /admin/. My question is therefore is there some way of adding in this /admin/ step or fooling php/apache to include this in all files within the /admin/ folder. Many thanks Sim I am trying to figure out the exact path to my file. Right now I've been using: $_SERVER['DOCUMENT_ROOT'] This works if my file is currently uploaded into the root directory. However document root doesn't take into account any extra folders my file location might be loaded. For example: /home/users/web/b888/nf.vbpointmarketcom/public_html/forum/admin Printing out the $_SERVER['DOCUMENT_ROOT'] would only show me: /home/users/web/b888/nf.vbpointmarketcom/public_html Is there any premade function or way that I can quickly figure out what the subdirectories are as well so I can output it or assign it to a variable? Hey, I'm in the process of making a site that involves multiple layers of folders. I have a form that uploads an image which i then try to move to the image folder using a define function using the document root + image folder but the image never gets saved to the defined location and the location isnt inserted into the sql query. Its a simple thing I want to do but since Im making a bigger site I want to maximize includes to reduce duplicate code. Include File - defines the document root Code: [Select] srvRoot = $_SERVER['DOCUMENT_ROOT']; $serverRoot = str_replace('/', '\/', $serverRoot); define('SRV_ROOT', $srvRoot); Image Upload Code: [Select] $image = $_FILES["catImage"]["name"]; $image = addImage($image, SRV_ROOT . "images/shop/img_cat"); function addImage($image, $path){ // FIX FIX FIX $fileExtension = getExtension($image); //this function works fine have tested in previous scripts so not needed $image = substr(md5(rand() * time()), 0, 10).".".$fileExtension; $imgDestination = $path.$image; if($_FILES['catImage']['type'] != "image/gif" && $_FILES['catImage']['type'] != "image/jpg" && $_FILES['catImage']['type'] != "image/jpeg" && $_FILES['catImage']['type'] !="image/png" ){ echo "You may only upload image files"; }else{ //Moves the uploaded file to destination folder via the variable which includes image filename if(move_uploaded_file($_FILES["catImage"]["tmp_name"],$imgDestination)){ return($imgDestination); }else{ header("Location: ../../home.php"); } echo $imgDestination; } } Hi I run versions of sites on a local server. For these the path to a mysql connection script is pretty simple: mysql_connec.php On my live server, I put things out of the public directory - so this time the path is ../mysql_connect.php I therefore have to have sections like this in my files = and whilst not complex, its a pain having to uncomment/comment lines depending on which server I am working because I keep forgetting! Code: [Select] // require_once('../../workRecord/mysql_connect.php'); //online require_once('mysql_connect.php'); //local Is there some way I can identify which server I am on so I don't keep having to do this. I was thinking of using something like this: Code: [Select] if ($_SERVER['DOCUMENT_ROOT']=="c:/web_root/blah/blah"){ require_once('mysql_connect.php'); }else{ require_once('../../workRecord/mysql_connect.php'); } I am pretty sure this would work, but does this method present any security issues??? Hi all. Working on a nav system using the document_root variable. I can't figure out why the links won't execute when I click them. When I mouse over a link, it shows the correct URL, but nothing happens when I click the links. The browser remains on the same page. The page <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>vCTO-Home</title> <link rel="stylesheet" type="text/css" href="css/style.css" media="screen" /> <?php include($_SERVER['DOCUMENT_ROOT'] . '/php/var.php');?> </head> <body> <?php include($_SERVER['DOCUMENT_ROOT'] . "/php/t1.php");?> </body> </html> t1.php <div class="tier"> <a href="<?php echo $docroot;?>/index.php">Home</a> <a href="<?php echo $docroot;?>/demand_management.php">Demand Management</a> <a href="<?php echo $docroot;?>/engineering.php">Engineering</a> <a href="<?php echo $docroot;?>/steady_state.php">Steady State</a> <a href="<?php echo $docroot;?>/communications.php">Communications</a> <a href="<?php echo $docroot;?>/business_management.php">Business Management</a> <a href="<?php echo $docroot;?>/risk_management.php">Risk Management</a> <a href="<?php echo $docroot;?>/other.php">Other</a> </div> var.php <?php $docroot=$_SERVER['DOCUMENT_ROOT']; ?> Hi I am new here and I am not a PHP specialist. I run a website (www.theowl.com) and last week I upgraded from PHP 4.X to 5.x on the Namesco server. Everything worked except one thing.... I commissioned an EDI link to DHL, and this was setup using PHP FTP. This system works automatically plus I have a manual link to trigger orders. Since upgrading PHP the automatic process has stopped but the manual process still works fine. Would anybody be able to help. I have attached what I think is the correct file. I am happy to pay for peoples time. i have a piece of code which subtracts credits every time a button is clicked. the original code works fine. I have since added a bonus_credit column, where i want it to function like this. if buy_credit = 0 and bonus_credit>0 then subtract from the bonus credit, but still do everything else its supposed to do.. here is the original code i had $selRes=mysql_query("SELECT buy_credit from user where id='".$hb_id."' and buy_credit>0"); if(mysql_affected_rows()>0) { $b_comm=0; $bc_updqry=mysql_query("UPDATE user set buy_credit=buy_credit-1 where id='".$hb_id."'"); $updqry=mysql_query("UPDATE cars set b_fee_paid_status='1' where id='".$aid."'"); } here is my modified code, but it doesn't seem to subtract from buy_credit if buy_credit is >0.. it should only kick in the bonus_credit usage if buy_credit is 0 $selRes=mysql_query("SELECT buy_credit,bonus_credit from user where id='".$hb_id."' and buy_credit>0 OR bonus_credit>0"); if(mysql_affected_rows()>0) { $b_comm=0; if($selRes['buy_credit']!=0) { $bc_updqry=mysql_query("UPDATE user set buy_credit=buy_credit-1 where id='".$hb_id."'"); } else { $bc_updqry=mysql_query("UPDATE user set bonus_credit=bonus_credit-1 where id='".$hb_id."'"); } $updqry=mysql_query("UPDATE cars set b_fee_paid_status='1' where id='".$aid."'"); } your help is appreciated. Helo dear people, I need some halp with mine script. This is part of it that works: function msan_getxmlinfo() { //global $local; //msan_download(); $path = dirname(__FILE__).'/xml/pricelist.xml'; $doc = new DOMDocument(); $doc->load($path); $msan = $doc->getElementsByTagName( "Table" ); $result = array(); foreach( $msan as $table ) { $codes = $table->getElementsByTagName( "ProductCode" ); $code = $codes->item(0)->nodeValue; $prices = $table->getElementsByTagName( "ProductPartnerPrice" ); $price = $prices->item(0)->nodeValue; $price = sprintf('%6f',$price); $availables = $table->getElementsByTagName( "ProductAvailability" ); $available = $availables->item(0)->nodeValue; $result[$code] = array('code'=>$code,'price'=>$price,'available'=>$available); } //echo "<pre>"; //print_r($result); //@unlink($path); return $result; } But now i need to insert one more element called "ProductDiscount" And aditional condition for proper price setting related so that when "ProductDiscount" is 0 (zero) then increase price by 3% and if theres any other value than 0 (zero) leave price as is. I was trying somthing like this but i cant get price increase: function msan_getxmlinfo() { $path = dirname(__FILE__).'/xml/pricelist.xml'; $doc = new DOMDocument(); $doc->load($path); $msan = $doc->getElementsByTagName( "Table" ); $result = array(); foreach( $msan as $table ) { $codes = $table->getElementsByTagName( "ProductCode" ); $code = $codes->item(0)->nodeValue; $prices = $table->getElementsByTagName( "ProductPartnerPrice" ); $price = $prices->item(0)->nodeValue; $discounts = $table->getElementsByTagName( "ProductDiscount"); if($discounts->item(0)=="0") { $price = $price*1.03; } else { $price = $prices->item(0)->nodeValue; } $price = sprintf('%6f',$price); $availables = $table->getElementsByTagName( "ProductAvailability" ); $available = $availables->item(0)->nodeValue; $result[$code] = array('code'=>$code,'price'=>$price,'available'=>$available,'discount'=>$discount); } return $result; } Help needed! Hello, I'm working on a project that will let users access a website to view results. I getting via a FTP server CSV files. Files look like that (in French): "ARTICLES; BOISSONS 5.50% ; 1; ORANGINA ; 2.50; 2; PERRIER ; 5.00; 2; SCHWEPPES ; 5.00; ----------------------------------------; 5; BOISSONS 5.50% ; 12.50; RATIO %; 6.94; BOISSONS 19.60% ; 4; PELFORTH ; 10.00; 1; CHIVAS ; 7.00; 1; LIQUEUR ; 5.50; ----------------------------------------; 6; BOISSONS 19.60% ; 22.50; RATIO %; 12.50; RESTAURANT ; 1; BOUILLON POT AU FEU ; 7.00; 2; JAMBON D'AUVERGNE ; 20.00; 2; TERRINE PIED DE PORC; 16.00; 1; CASSOULET ; 20.00; 2; CONFIT DE CANARD ; 46.00; 1; CUISSE DE LAPIN ; 18.00; 1; MOURTAYROL ; 18.00; ----------------------------------------; 10; RESTAURANT ; 145.00; RATIO %; 80.56; ----------------------------------------; TOTAL ; ARTICLES ; 180.00; ------------------------------------------; ------------------------------------------; ------------------------------------------; REGLEMENTS; 2; ESPECES ; 109.50; 1; CARTE ; 70.50; ------------------------------------------; TOTAL ; REGLEMENTS; 180.00;" Basically, I'm trying to write code to "sort" each categorie (ARTICLES, REGLEMENTS....) Here is what I'd like to get: A B C D E ARTICLES; BOISSONS 5.50% ; 1; ORANGINA ; 2; PERRIER ; 2; SCHWEPPES ; BOISSONS 19.60% ; 4; PELFORTH ; 1; CHIVAS ; 1; LIQUEUR ; RESTAURANT ; 1; BOUILLON POT AU FEU ; 2; JAMBON DE DINDE ; 2; TERRINE PIED DE PORC; 1; CASSOULET ; 2; CONFIT DE CANARD ; 1; CUISSE DE LAPIN ; 1; MOURTAYROL ; TOTAL ; 5; BOISSONS 5.50% ; 12.50; 6; BOISSONS 19.60% ; 22.50; 10; RESTAURANT ; 145.00; REGLEMENTS; 2; ESPECES ; 109.50; 1; CARTE ; 70.50; A, B, D only names C, E only numbers These datas will be used to generate pie charts Thanks for your attention This code is supposed to pull data from a mysql database so I can edit it. that part works. The other part of this code is, it's supposed to send an email to an email address based off of the "location" field. If I choose "Office1, it will send the data to the mysql database as well as send an email to the email address in listed for office1 with the data that went to the mysql database. Can someone take a look & correct my code issues? Code: [Select] <p> To go to the main page <a href="http://tnep-g-psrflow/flow/index.html">click here</a>.</p> <?php # edit_dqa.php $page_title = 'Edit a Record'; $con = mysql_connect("localhost","uname","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("psrflow", $con); //$result = mysql_query("SELECT * FROM psrinfo "); // Check for a valid user ID, through GET or POST. if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { // Accessed through view_users.php $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form has been submitted. $id = $_POST['id']; } else { // No valid ID, kill the script. echo '<h1 id="mainhead">Page Error</h1> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; include ('./includes/footer.html'); exit(); } // Check if the form has been submitted. if (isset($_POST['submitted'])) { $errors = array(); // Initialize error array. if (empty($_POST['pacts'])) { $errors[] = 'You forgot to enter your PACTS number. If there is no PACTS # you can enter 0000'; } else { $pt = $_POST['pacts']; } if (empty($_POST['fname'])) { $errors[] = 'You forgot to enter the first name.'; } else { $fn = $_POST['fname']; } if (empty($_POST['lname'])) { $errors[] = 'You forgot to enter the last name.'; } else { $ln = $_POST['lname']; } if (empty($_POST['status'])) { $errors[] = 'You forgot to enter a status.'; } else { $st = $_POST['status']; } if (empty($_POST['assgn_date'])) { $errors[] = 'You forgot to enter an assign date.'; } else { $ad = $_POST['assgn_date']; } if (empty($_POST['interv_date'])) { $errors[] = 'You forgot to enter an interview date.'; } else { $iv = $_POST['interv_date']; } if (empty($_POST['due_rev'])) { $errors[] = 'You forgot to enter a due to reviewer date.'; } else { $rv = $_POST['due_rev']; } if (empty($_POST['due_suspo'])) { $errors[] = 'You forgot to enter a due to SUSPO date.'; } else { $sus = $_POST['due_suspo']; } if (empty($_POST['due_clerk'])) { $errors[] = 'You forgot to enter a due to clerk date.'; } else { $clk = $_POST['due_clerk']; } if (empty($_POST['due_owner'])) { $errors[] = 'You forgot to enter a due to owner date.'; } else { $jdg = $_POST['due_owner']; } if (empty($_POST['location'])) { $errors[] = 'You forgot to enter a location.'; } else { $loc = $_POST['location']; } if (empty($_POST['employee'])) { $errors[] = 'You forgot to enter a employee.'; } else { $off = $_POST['employee']; } if (empty($_POST['sent_date'])) { $errors[] = 'You forgot to enter a sentence date.'; } else { $sd = $_POST['sent_date']; } if (empty($_POST['oth_date'])) { $errors[] = 'You forgot to enter an other date.'; } else { $oth = $_POST['oth_date']; } if (empty($_POST['due_attny'])) { $errors[] = 'You forgot to enter an date.'; } else { $atn = $_POST['due_attny']; } if (empty($errors)) { // If everything's OK. // Make the query. $query = "UPDATE psrinfo SET pacts='$pt', fname='$fn', lname='$ln', status='$st', location='$loc', employee='$off', sent_date='$sd', oth_date='$oth', assgn_date='$ad', interv_date='$iv', due_rev='$rv', due_suspo='$sus', due_clerk='$clk', due_attny='$atn', due_owner='$jdg' WHERE fid=$id"; //$query = "UPDATE psrinfo SET pacts='$pt', fname='$fn', lname='$ln', status='$st', location='$loc', assgn_date='$ad', interv_date='$iv', due_rev='$rv', due_suspo='$sus', due_clerk='$clk', due_attny='$atn', due_owner='$jdg', oth_date='$oth', employee='$off' WHERE fid=$id"; $result = @mysql_query ($query); // Run the query. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); if ((substr($url, -1) == '/') OR (substr($url, -1) == '//')) { $url = substr ($url, 0, -1); } $url ='/flow/index.html'; header("Location: $url"); exit(); } else { // Report the errors. echo '<h1 id="mainhead">Error!</h1> <p class="error">The following error(s) occurred:<br />'; foreach ($errors as $msg) { // Print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } // End of if (empty($errors)) IF. } // End of submit conditional. // Retrieve the user's information. $query = "SELECT pacts, fname, lname, status, employee, location, assgn_date, interv_date, sent_date, oth_date, due_rev, due_suspo, due_clerk, due_attny, due_owner FROM psrinfo WHERE fid = " . $_REQUEST['id']; $result = @mysql_query ($query); // Run the query. if (mysql_num_rows($result) == 1) { // Valid user ID, show the form. // Get the user's information. $row = mysql_fetch_array ($result, MYSQL_NUM); ?> <script type="text/javascript"> var valid; function d2(v) { return (v<10)?("0"+v):v; } function dcheck(form) { var a = form.assgn_date.value; var s = form.sent_date.value; var i = form.interv_date.value; var dr = form.due_rev.value var su = form.due_suspo var clk = form.due_clerk var att = form.due_attny var jdg = form.due_owner var assn = new Date(a); var sent = new Date(s); var intv = new Date(i); var due_rev = new Date(dr); var due_suspo = new Date(su); var due_clerk = new Date(clk); var due_attny = new Date(att); var due_owner = new Date(jdg); if (isNaN(intv)) { intv = new Date(assn.getFullYear(),assn.getMonth(),assn.getDate()+0); } if (isNaN(assn)) { assn = new Date(assn.getFullYear(),assn.getMonth(),assn.getDate()+0); } if (isNaN(due_rev)) { due_rev = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-42); } if (isNaN(due_suspo)) { due_suspo = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-40); } if (isNaN(due_clerk)) { due_clerk = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-38); } if (isNaN(due_attny)) { due_attny = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-36); } if (isNaN(due_owner)) { due_owner = new Date(sent.getFullYear(),sent.getMonth(),sent.getDate()-7); } switch(due_rev.getDay()){ case 0: due_rev.setDate(due_rev.getDate() - 1); // take one for Sunday case 6: due_rev.setDate(due_rev.getDate() - 1); // take two for Sunday or one for Saturday } switch(due_suspo.getDay()){ case 0: due_suspo.setDate(due_suspo.getDate() - 1); // take one for Sunday case 6: due_suspo.setDate(due_suspo.getDate() - 1); // take two for Sunday or one for Saturday } switch(due_clerk.getDay()){ case 0: due_clerk.setDate(due_clerk.getDate() - 1); // take one for Sunday case 6: due_clerk.setDate(due_clerk.getDate() - 1); // take two for Sunday or one for Saturday } switch(due_attny.getDay()){ case 0: due_attny.setDate(due_attny.getDate() - 1); // take one for Sunday case 6: due_attny.setDate(due_attny.getDate() - 1); // take two for Sunday or one for Saturday } switch(due_owner.getDay()){ case 0: due_owner.setDate(due_owner.getDate() - 1); // take one for Sunday case 6: due_owner.setDate(due_owner.getDate() - 1); // take two for Sunday or one for Saturday } switch(due_rev.getDay()){ case 0: due_rev.setDate(due_rev.getDate() - 1); // take one for Sunday case 6: due_rev.setDate(due_rev.getDate() - 1); // take two for Sunday or one for Saturday } //form.assgn_date.value = (assn.getFullYear()+0) + "-" + d2(assn.getMonth()+1) + "-" + d2(assn.getDate()); //form.interv_date.value = (intv.getFullYear()+0) + "-" + d2(intv.getMonth()+1) + "-" + d2(intv.getDate()); form.sent_date.value = (sent.getFullYear()+0) + "-" + d2(sent.getMonth()+1) + "-" + d2(sent.getDate()); form.due_rev.value = (due_rev.getFullYear()+0) + "-" + d2(due_rev.getMonth()+1) + "-" + d2(due_rev.getDate()); form.due_suspo.value = (due_suspo.getFullYear()+0) + "-" + d2(due_suspo.getMonth()+1) + "-" + d2(due_suspo.getDate()); form.due_clerk.value = (due_clerk.getFullYear()+0) + "-" + d2(due_clerk.getMonth()+1) + "-" + d2(due_clerk.getDate()); form.due_attny.value = (due_attny.getFullYear()+0) + "-" + d2(due_attny.getMonth()+1) + "-" + d2(due_attny.getDate()); form.due_owner.value = (due_owner.getFullYear()+0) + "-" + d2(due_owner.getMonth()+1) + "-" + d2(due_owner.getDate()); return true; } </script> <?php if (isset($_REQUEST['Submit'])) { # THIS CODE TELL MYSQL TO INSERT THE DATA FROM THE FORM INTO YOUR MYSQL TABLE $sql = "INSERT INTO $db_table(fname,lname,pacts,assgn_date,interv_date) values ('".mysql_real_escape_string(stripslashes($_REQUEST['fname']))."','".mysql_real_escape_string(stripslashes($_REQUEST['lname']))."','".mysql_real_escape_string(stripslashes($_REQUEST['pacts']))."','".mysql_real_escape_string(stripslashes($_REQUEST['assgn_date']))."','".mysql_real_escape_string(stripslashes($_REQUEST['interv_date']))."')"; if($result = mysql_query($sql ,$db)) { ##################################################################### switch($_REQUEST['location']) { case "Office1": $email = "office1@email.com"; break; case "Office2": $email = "office2@email.com"; break; default: echo "Error, no location selected!!!"; break; } $message = "<p>A date has changed. Please check the database</p><br> First Name: {$_REQUEST['fname']}<br>Last Name : {$_REQUEST['lname']}<br>PACTS No : {$_REQUEST['pacts']}<br>Date Assigned : {$_REQUEST['assgn_date']}<br>Date Interviewed : {$_REQUEST['interv_date']}<br>}"; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $subject = "Please Review the Changed Data"; $headers .= "To: DQA <$email>\n"; $headers .= "From: PODDS <sender email>\n"; if (mail($email, $subject, $message, $headers)) { echo "<p><center><h2>The Office</h2></center></p>"; echo "<p><h3><center>Our Town</center></h3></p>"; echo "<center>An email has been sent to someone for editing and "; } else { echo "This system is not working properly. Please contact IT so he can fix it."; } ########################################################################## echo '<form action="edit_dqa.php" method="post"> <fieldset><legend><h1> You are editing a record!</h1></legend> <b>PACTS No:</b> <br><input type="text" name="pacts" size="15" maxlength="30" value="'.$row[0].'" /><br> <b>First Name:</b> <br><input type="text" name="fname" size="15" maxlength="30" value="'.$row[1].'" /><br /> <b>Last Name:</b> <br><input type="text" name="lname" size="15" maxlength="30" value="'.$row[2].'" /><br /> <b>Status: </b><br><input type="text" name="status" size="15" maxlength="30" value="'.$row[3].'" /> <br> <b>Location: </b><br><input type="text" name="location" size="15" maxlength="30" value="'.$row[5].'" /><br> <b>employee: </b><br><input type="text" name="employee" size="15" maxlength="30" value="'.$row[4].'" /> <br> <b>Sentence Date: MM/DD/YYYY </b><br><input type="text" name="sent_date" size="15" maxlength="30" value="'.$row[8].'" /> <br> <p><input type="button" value="Calculate" onclick="return dcheck(this.form);"> <b>-----------------------------------------------------------</b> <br /><br> <b>Other Date:</b><br><input type="text" name="oth_date" size="15" maxlength="30" value="'.$row[9].'" /> <br> <b>Assign Date: </b><br><input type="text" name="assgn_date" size="15" maxlength="30" value="'.$row[6].'" /> <br> <b>Interview Date: </b><br><input type="text" name="interv_date" size="15" maxlength="30" value="'.$row[7].'" /> <br> <b>Due to Reviewer:</b><br><input type="text" name="due_rev" size="15" maxlength="30" value="'.$row[10].'" /> <br> <b>Due to SUSPO:</b><br><input type="text" name="due_suspo" size="15" maxlength="30" value="'.$row[11].'" /> <br> <b>Due to Clerk:</b><br><input type="text" name="due_clerk" size="15" maxlength="30" value="'.$row[12].'" /> <br> <b>Due to Attorney:</b><br><input type="text" name="due_attny" size="15" maxlength="30" value="'.$row[13].'" /> <br> <b>Due to owner:</b><br><input type="text" name="due_owner" size="15" maxlength="30" value="'.$row[14].'" /> <br> <br> </fieldset> <div align="left"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="' . $id . '" /> </form>'; } else { // Not a valid user ID. echo '<h1 id="mainhead">Page Error</h1> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; } mysql_close(); // Close the database connection. ?> okay so i need this same logo to be on the other page..how do i do it.. this is code of the logo page.. Code: [Select] <? if(isset($_GET[ttid])) { $ttid = $_GET[ttid]; } $connection=mysql_connect("$server", "$username", "$password") or die("Could not establish connection"); mysql_select_db($database_name, $connection) or die ("Could not select database"); $query = "select master_event.* , (DATE_FORMAT(event_datefrom, '%d %M %Y')) as datefrom, (DATE_FORMAT(event_dateto, '%d %M %Y')) as dateto, ucase(event_name) as eventname from master_event where master_event.event_id = '$ttid '"; $result=mysql_query($query); while($row = mysql_fetch_array($result)){ $eventname = $row['eventname']; $eventdesc = $row['event_desc']; //$companydescription = $row['company_description']; $eventvenue = $row['event_venue']; $eventfee = $row['event_fee']; $datefrom = $row['datefrom']; $dateto = $row['dateto']; echo "<font color='#000000' face='arial' ><b> $eventname </b> </font> <br>"; echo "<font color='#000000' face='arial' ><i>Date</i> : $datefrom - $dateto <br>"; echo "<i>Venue</i> : $eventvenue <br>"; $querypstype = "SELECT DISTINCT master_pstype.pstype_id, pstype_desc FROM master_pstype INNER JOIN master_psevent ON master_psevent.pstype_id= master_pstype.pstype_id where master_psevent.event_id = '$ttid' ORDER BY pstype_order"; $resultpstype=mysql_query($querypstype); while($rowpstype = mysql_fetch_array($resultpstype)){ $pstypeid = $rowpstype['pstype_id']; $pstypedesc = $rowpstype['pstype_desc']; echo "<br><font color='#8B3A3A' size='1' face='georgia' ><b><i>$pstypedesc</i></b></font> <br>"; $queryps = "SELECT master_psevent.*, pstype_desc, company_name, company_link, company_description, logo_filename FROM master_psevent LEFT JOIN master_pstype ON master_psevent.pstype_id = master_pstype.pstype_id LEFT JOIN master_ps ON master_ps.ps_id = master_psevent.ps_id WHERE master_psevent.event_id = '$ttid' and master_pstype.pstype_id= '$pstypeid' ORDER BY pstype_desc,company_name "; echo $queryps; $resultps=mysql_query($queryps); while($rowps = mysql_fetch_array($resultps)){ $companyname = $rowps['company_name']; $companyid = $rowps['ps_id']; $companylinkori = $rowps['company_link']; $companydescription = $rowps['company_description']; $logopath = $rowps['logo_filename']; $describelink = "index.php?view=describe&ttid=$ttid&pstypeid=$pstypeid&psid=$companyid"; if(!empty($companydescription)){ echo "<a href=\"$describelink\" target=\"_blank\"><img src=".$logo_dir."/".$logopath." width=\"15%\" border=\"0\"></a>"; } else { echo "<a href=\"$describelink\" target=\"_blank\"><img src=".$logo_dir."/".$logopath." width=\"15%\" border=\"0\"></a>"; } } } } ?> i need to put the logo script on this page without removing other data..just wanna add the logo in it..where do i alter? Code: [Select] <? $monthname=$_POST['month']; if (isset($_GET['np'])){ $num_pages=$_GET['np']; } else { if($searchtype == 'yes') if ($monthname=="All" || $monthname=="") { $query = "SELECT count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 order by event_datefrom desc"; }else { $query = "SELECT count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 AND MONTHNAME(event_datefrom) = '$monthname' order by event_datefrom desc"; } else if ($monthname=="All" || $monthname=="") { $query = "Select count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 order by event_datefrom desc"; }else { $query = "Select count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 AND MONTHNAME(event_datefrom) = '$monthname' order by event_datefrom desc"; } $result=mysql_query($query); $row=mysql_fetch_array($result, MYSQL_NUM); $num_records=$row[0]; if ($num_records > $displayhome){ $num_pages=ceil($num_records/$displayhome); } else { $num_pages=1; } } if (isset($_GET['s'])){ $start=$_GET['s']; } else { $start=0; } if ($monthname=="All" || $monthname=="") { $query = "SELECT master_event.*,master_type.type_name, DATE_FORMAT(event_datefrom, '%d %b %y') as datefrom, DATE_FORMAT(event_dateto, '%d %b %y') as dateto, event_venue, (event_name) as eventname FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 order by event_datefrom asc LIMIT $start, $displayhome"; }else { $query = "SELECT master_event.*,master_type.type_name, DATE_FORMAT(event_datefrom, '%d %b %y') as datefrom, DATE_FORMAT(event_dateto, '%d %b %y') as dateto, event_venue, (event_name) as eventname FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 AND MONTHNAME(event_datefrom) = '$monthname' order by event_datefrom asc LIMIT $start, $displayhome"; } $result = mysql_query($query); $bg='#e5e5e5'; while($row = mysql_fetch_array($result)){ $eventid = $row['event_id']; $eventname = str_replace("", "", $row['eventname']); $eventdatefrom = $row['datefrom']; $eventdateto = $row['dateto']; $event_venue = $row['event_venue']; $event_desc = $row['event_desc']; $speakerlist = $row['speakerlist']; $showline1 = ""; $showpros =""; $showline2 = ""; $showreg =""; $showline3 = ""; $showps =""; $showline4 = ""; $showtestimonial =""; $showline5 = ""; $showsp =""; $showline6 = ""; $showsl =""; if ($eventdatefrom ==$eventdateto) { $eventdate = $eventdatefrom; } else { $eventdate = $eventdatefrom . " - " . $eventdateto; } $querypros="select count(*) as proscount from master_prospectus where event_id ='$eventid' "; $resultpros = mysql_query($querypros); while($rowpros = mysql_fetch_array($resultpros)){ $proscount = $rowpros['proscount']; if ($proscount > 0) { $showline1 = "|"; $showpros ="Request Brochure"; } } $queryreg="select (CASE WHEN event_dateto >= NOW() THEN 'valid' ELSE 'invalid' END) AS validreg from master_event where event_id ='$eventid' "; $resultreg = mysql_query($queryreg); while($rowreg = mysql_fetch_array($resultreg)){ $validreg = $rowreg['validreg']; if ($validreg == "valid") { $showline2 = "|"; $showreg ="Online Registration"; } } $queryps="select count(*) as pscount from master_psevent where event_id ='$eventid' "; $resultps = mysql_query($queryps); while($rowps = mysql_fetch_array($resultps)){ $pscount = $rowps['pscount']; if ($pscount > 0) { $showline3 = "|"; $showps ="Partner & Sponsor"; } } $querytesm="select count(*) as tesmcount from master_testimonial where event_id ='$eventid' "; $resulttesm = mysql_query($querytesm); while($rowtesm = mysql_fetch_array($resulttesm)){ $tesmcount = $rowtesm['tesmcount']; if ($tesmcount > 0) { $showline4 = "|"; $showtestimonial ="Testimonial"; } } $querysp="select count(*) as spcount from master_speakernote where event_id ='$eventid' "; $resultsp = mysql_query($querysp); while($rowsp = mysql_fetch_array($resultsp)){ $spcount = $rowsp['spcount']; if ($spcount > 0) { $showline5 = "|"; $showsp ="Speaker Notes"; } } if ($speakerlist <> '') { $showline6 = "|"; $showsl ="Speaker List"; } echo "<tr><p style=\"font-size:small;\"> <td width='' ><img src='images/search.png' alt='tooltips' ></img> <a href='index.php?view=event&content=tips&ttid=$eventid' title ='$eventname' class=\"fancybox fancybox.iframe\" style=\"color:#104E8B;text-decoration: none; \" ><strong><font size='2' face='Segoe UI' >$eventname</font></strong></a><br> <font color='#000000' size='2' face='arial' >Date : $eventdate <br> Venue : $event_venue<br></font> <table style=\"text-align: left; width: 400px; height: 92px;\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\"> <tbody> <tr> <td></td> <td style=\"text-align: justify; color: #000000;\"> <font color='#000000' size='2' face='arial' > $event_desc</font></td> <td></td> </tr> </tbody> </table> <font color='#919191' size='1' face='arial' ><b> <a href='index.php?view=prospectus®rq=$eventid' title ='Request Brochure...' >$showpros</a> <b>$showline1</b> <a href='index.php?view=registration®rq=$eventid' title ='Online Registration...' > $showreg </a> <b>$showline2</b> <a href='index.php?view=event&content=psevent&ttid=$eventid' title ='Sponsor & Partner...' class='fancybox fancybox.iframe' >$showps</a> <b>$showline3</b> <a href='index.php?view=event&content=tesm&ttid=$eventid' title ='Testimonial...' class='fancybox fancybox.iframe' >$showtestimonial</a> <b>$showline4</b> <a href='index.php?view=spl&splid=$eventid' > $showsp</a><b>$showline5</b> <a href='index.php?view=event&content=speaker&ttid=$eventid' title ='$eventname' class='fancybox fancybox.iframe' > $showsl</a></font><br><br></td> </p></tr></b></font> "; } if ($eventid=="") { echo "No Records Found."; } echo "<td><p style=\"font-size:1;\">"; echo "<br>"; if ($num_pages > 1) { $current_page = ($start/$displayhome) + 1; if ($current_page != 1) { echo '<a href="index.php?view=home&content=list&s=' . ($start - $displayhome) . '&np=' . $num_pages . '#a" class="style1" style="color:#4F94CD;text-decoration: none;">Previous</a> ';} for ($i = 1; $i <= $num_pages; $i++) { if ($i != $current_page) { echo '<a href="index.php?view=home&content=list&s=' . (($displayhome * ($i - 1))) . '&np=' . $num_pages . '#a" class="style1" style="color:#4F94CD;text-decoration: none;">' . $i . '</a> '; } else { echo '<font face="arial" size="2">'; echo $i . '</font> ';} } if ($current_page != $num_pages) { echo '<a href="index.php?view=home&content=list&s=' . ($start + $displayhome) . '&np=' . $num_pages . '#a" class="style1" style="color:#4F94CD;text-decoration: none;">Next</a>';} } echo "</p></td>"; ?> </tr> </div> </form> Hello: I have a small chunck of code that dosplays data depending on which PlayerID is selected. Like so: Code: [Select] <?php $myvar = $_REQUEST['PlayerID']; ?> ... <?php if ( $myvar == "1" ) { echo "Your name is Tina"; } elseif ( $myvar == "2" ) { echo "Your name is Sue"; } else { echo "Your name is Jill"; } ?> This works fine - no errors - but I am use to ASP and using an "End If" after "Else" ... Is this not needed in PHP? Thanks. I have a form with dynamic text boxes that have dynamic names (i.e., TextBox1, TextBox2, etc.). How do I get those variables passed into php? I have tried and tried...even googled it, with no solid luck. Any help, immediately, would be so much appreciated. Here's my code snippet. Code: [Select] if(preg_match("/^[ a-zA-Z1-42]+/", $_POST['name'])){ $name=$_POST['name']; $namer=$name; $result = mysql_query("select `resource` from resources where `resource_id` =" .$namer. "ORDER BY `resource_id` ASC "); echo "<br/>The following nations have " .$namer. " as a resource\n"; //-query the database table $sql="SELECT id, nation_id, ruler, resource1, resource2 FROM TS1 WHERE resource1 LIKE '%" . $name . "%' OR resource2 LIKE '%" . $name ."%'"; //-run the query against the mysql query function $result=mysql_query($sql); //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $ID=$row['id']; $Ruler=$row['ruler']; //-display the result of the array echo "<ul>\n"; echo "<li>" . "<a href=\"searcher.php?id=$ID\">" .$Ruler. "</a></li>\n"; echo "</ul>"; } } else{ echo "<p>Please enter a search query</p>"; } } } Basically I have a number that's posted from a form field from another page to this page. It displays correctly on the results page but what i'm trying to do now is get that number to change based on the query at the top '' $result = mysql_query("select `resource` from resources where `resource_id` =" .$namer. "ORDER BY `resource_id` ASC "); " So if the number 3 (which is in the `resource_id` column) was posted it will display a result (which is in the `resource` column). But it just seems that the query isn't going through and it continues to display the 3 which was originally posted instead of changing 3 to a number in the database. I was thinking of performing a while loop so it just just displays the result of the query.. something like this: Code: [Select] $name=$_POST['name']; $namer=$name; $result = mysql_query("select `resource` from resources where `resource_id` =" .$namer. "ORDER BY `resource_id` ASC "); while($row = mysql_fetch_array($result)) { echo "<br/>The following nations have " . $row['resource'] . " as a resource\n"; }But that seems to have more problems as it doesn't display anything at all, not even the original number I had. I don't think it's a big problem.. Maybe something i've just overlooked? Hello Forum, please can someone help me solve this error in the code below, thanks Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\XAMPP\xampp\htdocs\testingSite\addtobasket.php on line 10 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\XAMPP\xampp\htdocs\testingSite\addtobasket.php on line 11 <?php session_start(); require("db.php"); require("function.php"); $validid = pf_validate_number($_GET['id'], "redirect", $config_basedir); $prodsql = "SELECT * FROM products WHERE id =" .$_GET['id'] . "'"; $prodres = mysql_query($prodsql); $numrows = mysql_num_rows($prodres); $prodrow = mysql_fetch_assoc($prodres); if($numrows == 0) { header("Location: ". $config_basedir); } else { if($_POST['submit']) { if($_SESSION['SESS_ORDERNUM']) { $itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES (" . $_SESSION['SESS_ORDERNUM'] . "," . $_GET['id'] . "," . $_POST['amountBox'] .")"; mysql_query($itemsql); } else { if($_SESSION['SESSION_LOGGEDIN']) { $sql = "INSERT INTO orders(customer_id, registered, date) VALUES (" . $_SESSION['SESS_USERID'] . ", 1, NOW())"; mysql_query($sql); session_register("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); $itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES (" . $_SESSION['SESS_ORDERNUM'] .",". $_GET['id'] . "," . $_POST['amountBox'] . ")"; mysql_query($itemsql); } else { $sql = "INSERT INTO orders(registered, date, session) VALUES(" ."o, NOW(),'" . session_id() . "')"; mysql_query($sql); session_registered("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); $itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES(" . $_SESSION['SESS_ORDERNUM'] . "," .$_GET['id'] . "," . $_POST['amountBox'] . ")"; mysql_query($itemsql); } } $totalprice = $prodrow['price'] * $_POST['amountBox']; $updsql = "UPDATE orders SET total + ". $totalprice . " WHERE id = " . $_SESSION['SESS_ORDERNUM'] . ";"; mysql_query($updres); header("Location: " . $config_basedir . "showcart.php"); } else { require("header.php"); echo "<form action='addtobasket.php?id=" .$_GET['id'] . "' method='POST'>"; echo "<table cellpadding='10'>"; echo "<tr>"; if(empty($prodrow['image'])) { echo "<td><img src='./images.dummy.jpg' width='50' alt='" . $prodrow['name'] . "'></td>"; } else { echo "<td><img src=' ./images/" . $prodrow['image'] . "' width='50' alt='" . $prodrow['name'] . "'></td>"; } echo "<td>" . $prodrow['name'] ."</td>"; echo "<td>Select Quantity <select name='amountBox'>"; for($i=1;$i<=100;$i++) { echo "<option>" . $i . "</option>"; } echo "</select></td>"; echo "<td><strong>£" . sprintf('%.2f', $prodrow['price']) . "</strong></td>"; echo "<td><input type='submit' name='submit' value='Add to basket'></td>"; echo "</tr>"; echo "</table>"; echo "<form>"; } } require("footer.php"); ?> Hello i have coded a script that checks the post values then updates db recoreds thing is. i have this line of code if($name && $price && $ship && $paypal && $des && $cato_id !== ""){ do code }else{ do this } when the client enters 0 in the ship and price the do code does not get excuted how can i solve this problem thanks <?php # Script 10.3 - upload_image.php // This page is for editing a product. require_once(MYSQL);; // Check for a valid product ID, through GET or POST: if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { $id = $_GET['id']; // Make the query: $q = "SELECT name, price, ship, paypal, descr FROM products WHERE product_id='$id' LIMIT 1"; $r = mysqli_query ($dbc, $q); if(mysqli_affected_rows($dbc) == 1) {//Ran Ok ready to delete file $row = mysqli_fetch_array ($r, MYSQLI_ASSOC); } } else { die('<p class="error">Sorry this page is not available or has been accessed in error</p>'); } // Check if the form has been submitted: if (isset($_POST['submitted'])) { require_once(MYSQL); // Trim all the incoming data: $trimmed = array_map('trim', $_POST); // Assume invalid values: $name = $price = $ship = $paypal = $des = $cato_id = FALSE; // Check for a product name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['name'])) { $name = mysqli_real_escape_string ($dbc, $trimmed['name']); } else { echo '<p class="error">Please enter a product name</p>'; } // Check for a price if (is_numeric($trimmed['price'])) { $price = mysqli_real_escape_string ($dbc, $trimmed['price']); } else { echo '<p class="error">Please enter a price</p>'; } // Check for a price if (is_numeric($trimmed['shipping_cost'])) { $ship = mysqli_real_escape_string ($dbc, $trimmed['shipping_cost']); } else { echo '<p class="error">Please enter a shipping cost</p>'; } // Check for paypal code: if ($_POST['paypal']) { $paypal = mysqli_real_escape_string ($dbc, $trimmed['paypal']); } else { echo '<p class="error">Please enter the paypal code</p>'; } // Check for product description: if ($_POST['product_des']) { $des = mysqli_real_escape_string ($dbc, $trimmed['product_des']); } else { echo '<p class="error">Please enter a product description</p>'; } // Check for product description: if ($_POST['cato_id']) { $cato_id = mysqli_real_escape_string ($dbc, $trimmed['cato_id']); } else { echo '<p class="error">Please Select a category</p>'; } if ($name && $price && $ship && $paypal && $des && $cato_id !== "") { // If everything's OK... $q = "UPDATE products SET name='$name', price='$price', ship='$ship', paypal='$paypal', descr='$des', cato='$cato_id' WHERE product_id='$id'"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); echo '<p class="success"><em>The Product Information has Been Updated</em></p>'; } if($_POST['oldimage'] == 0){ // Check for an uploaded file: if (isset($_FILES['upload'])) { // Validate the type. Should be JPEG or PNG. $allowed = array ('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png'); if (in_array($_FILES['upload']['type'], $allowed)) { function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } //This applies the function to our file $ext = findexts ($_FILES['upload']['name']); //This line assigns a random number to a variable. You could also use a timestamp here if you prefer. $timestamp = time(); //This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended. $default_name = $timestamp."."; //This assigns the subdirectory you want to save into... make sure it exists! $target = TARGET; $image = "/photos/"; //This combines the directory, the random file name, and the extension $target = $target . $default_name.$ext; $image = $image . $default_name.$ext; // Move the file over. if (move_uploaded_file ($_FILES['upload']['tmp_name'], "$target")) { // Make the query: $q = "SELECT image FROM products WHERE product_id='$id' LIMIT 1"; $r = @mysqli_query ($dbc, $q); if(mysqli_affected_rows($dbc) == 1) {//Ran Ok ready to delete file $row = @mysqli_fetch_array ($r, MYSQLI_NUM); $q = "UPDATE products SET image='$image' WHERE product_id='$id'"; $r = @mysqli_query ($dbc, $q); //Delete from file $myFile = DELPATH . $row[0]; if (file_exists($myFile)) { //Delete from file if(unlink($myFile)){ echo "<p class=\"success\">File: $row[0] has been successfully deleted</p>"; } } echo '<p class="success"><em>The Product Image has Been Changed</em></p>'; } } // End of move... IF. } else { // Invalid type. echo '<p class="error">Please upload a JPEG or PNG image.</p>'; } // Check for an error: if ($_FILES['upload']['error'] > 0) { echo '<p class="error">The file could not be uploaded because: <strong>'; // Print a message based upon the error. switch ($_FILES['upload']['error']) { case 1: print 'The file exceeds the upload_max_filesize setting in php.ini.'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.'; break; case 3: print 'The file was only partially uploaded.'; break; case 4: print 'No file was uploaded.'; break; case 6: print 'No temporary folder was available.'; break; case 7: print 'Unable to write to the disk.'; break; case 8: print 'File upload stopped.'; break; default: print 'A system error occurred.'; break; } // End of switch. print '</strong></p>'; } // End of error IF. // Delete the file if it still exists: if (file_exists ($_FILES['upload']['tmp_name']) && is_file($_FILES['upload']['tmp_name']) ) { unlink ($_FILES['upload']['tmp_name']); } } // End of isset($_FILES['upload']) IF. } } Hello all,
Am trying to get the answers of a survey from my DB and display the percentage.. Everything am trying seems not to be working. please what am i doing wrong.
<? $question_query = "SELECT * FROM ".$tblprefix."question WHERE category = 'Service Availability' and section = 'Information Technology Services'"; $rs = $db->Execute($question_query); $all_the_time = array(); $most_of_the_time = array(); $sometimes = array(); $never = array(); while (!$rs->EOF) { $question_id = $rs->fields['question_id']; $question_query1 = "SELECT * FROM ".$tblprefix."user_answer, ".$tblprefix."question WHERE ".$tblprefix."user_answer.question_id = ".$tblprefix."question.question_id"; $rs1 = $db->Execute($question_query1); $answer_id = $rs1->fields['user_answer_id']; $question_query2 = "SELECT * FROM ".$tblprefix."answer WHERE answer_id = '$answer_id'"; $rs2 = $db->Execute($question_query2); $answer = $rs2->fields['answer']; if($answer == 'All the time') { array_push($all_the_time,'1'); } else if ($answer == 'Most of the time') { array_push($most_of_the_time,'1'); } else if ($answer == 'Sometimes') { array_push($sometimes,'1'); } else if($answer == 'Never') { array_push($never,'1'); } $rs->MoveNext(); } $count_all_of_time = count($all_the_time); $count_most_of_time= count($most_of_the_time); $count_sometimes = count($sometimes); $count_never = count($never); ?> <table border="0" class="question_answer_table"> <tr> <td><strong>Service Availability</strong></td> </tr> </table> <table border="0" class="question_answer_table"> <tr> <td style="width:120px;">All of Time</td> <td style="width:70px;"><?=round($count_all_of_time/$totaluser*100,2) .'%'?></td> </tr> <tr> <td>Most of Time</td> <td><?=round($count_most_of_time/$totaluser*100,2) .'%'?></td> </tr> <tr> <td>Sometimes</td> <td><?=round($count_sometimes/$totaluser*100,2) .'%'?></td> </tr> <tr> <td>Never</td> <td><?=round($count_never/$totaluser*100,2) .'%'?></td> </tr> </table>Only one of the field is displaying an output. the rest are not. thanks in advance Hello,
I'm looking to bring another php developer on board to help with php projects. You should be skilled in laravel, php, and mysql. The job starts at $15/hr for each project. Please pm me if you are intereasted.
Hello Form, This is my first post here so hello to all . Ok now for my question. i am making an CMS system for a school project. we have decided to work with smarty. Now this question is about 2 tables. table 1: attributes it contains the collums 'att_Id, att_Lable and att_Name' table 2: pg_Data(page data) this contains the collums 'dat_Id, att_Id, dat_Lable and dat_Name' This table contains the values for the attributes from table 1. in short: |table 1 |------------------------------------------------| | att_Id | att_Lable | att_Name | |------------------------------------------------| | 1 | head | Head | |table 2 |------------------------------------------------------------| | dat_Id | att_Id | dat_Value | |------------------------------------------------------------| | 1 | 1 | This is a text | now i need a query that need a query that get out de att_label from table 1 en the value from table 2. Code: [Select] SELECT dat.dat_Value, att.att_Lable FROM pg_Attributes AS att LEFT JOIN pg_Data AS dat ON att.att_Id = dat.att_Id then i get an output in php array( [dat_Value] => this is a text [att_Lable] => head ) now this is all good but i want to get the lable of the attribute in de key of the value. So it would look like this. array( [head] => this is a text ) is there anyone how understands this and can help me let me know. |