Search the Community
Showing results for tags 'sql'.
-
I am trying to calculate the difference in the previous row using the following query. $query2 = "select * from " . $wsym .",CleanedCalendar where '" . $wsym ."' = CleanedCalendar.Symbol AND " . $wsym .".Close - LAG(" . $wsym .".Close) OVER (ORDER BY " . $wsym .".Date) AS difference FROM " . $wsym .""; I am trying to open two tables and populate a new field called difference. The query works until I add the AND portion of the statement. Is my formatting wrong or am I not allowed to do this? Print: select * from AMDA,CleanedCalendar where 'AMDA' = CleanedCalendar.Symbol AND AMDA.Close - LAG(AMDA.Close) OVER (ORDER BY AMDA.Date) AS difference FROM AMDA You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OVER (ORDER BY AMDA.Date) AS difference FROM AMDA' at line 1
-
Hi Guys, I have a system to keep track the scoring from different form. So, Initially when come to the reporting, i just accumulative different scoring from different form to get Grand Total. The Output that i have: The query that i use is : SELECT EmpID,EmpName,sum(Scoring) AS GrandTotal FROM [SubmittedForm] WHERE submissionStatus <> 'Draft' AND fiscalYear='2015' group by EmpID,EmpName ORDER BY GrandTotal DESC But, the feedback that i received, user request to have details, where this Grand Total come from which form? So I am thinking to allow user mouse over the Grand Total to show in details. Of course Only show individual details. For example, if i mouse over grand total for James, only James details will show up. Example: Query: SELECT EmpID,EmpName,[FormName],sum(Scoring) AS GrandTotal FROM [SubmittedForm] WHERE submissionStatus <> 'Draft' AND fiscalYear='2015' group by EmpID,EmpName,[FormName] ORDER BY GrandTotal DESC So, I am quite confusing is there any query can get what i need. I can know the accumulative of all forms and also individual forms. Or i only can do some if else matching on my programming sides?
-
i have a table with these fields: table:_projecttbl fields(P_id,PrT_id,Other_id) I have a string like so: 'HG||Fxg|||ergx||xx' at every '|||' marks the begining of PrT_id and Other_id respectively. and it can have more than 64 records. I would like to write a query to delete from table where not exists in the string and P_id="known value" DELETE FROM _projecttbl WHERE NOT EXISTS (SELECT * FROM _projecttbl AS T1 WHERE T1.Project_id='1'); that is what i have tried but removes all.
-
Hi all, I was hoping you could point me in the right direction, I have 2 questions. 1. I want to have an option drop down which uses the array of a returned sql query. I have the following code which uses onchange to submit the selection, how do I use the mysql_fetch_array($result1) to give a list of the two selected columns in the $Site=array() bit. 2. The selected result will be used in more SQL select statements, so once a site from the list is selected the relevant data from other tables will be displayed using e.g. select person from people [some inner join statement] where site="site 1"; Therefore the $_POST value must be available to be passed to other queries once selected. Thanks for any help, I still feel like a noob, but I'm getting there. Gary <?php include 'header.php'; ?> <div class='container'> <?php include 'menu.php'; ?> <?php include 'connect.php'; ?> <?php $sql1="SELECT Sites.Site_ID, Sites.Site_name_1 FROM `Sites`"; $result1=mysql_query($sql1); ?> <?php function get_options() { $site=array('Site 1'=>'Site 1', 'Site 2'=>'Site 2', 'Site 3'=>'Site 3'); $options=''; while(list($k,$v)=each($site)) { $options.='<option value="'.$v.'">'.$k.'</option>'; } return $options; } if(isset($_POST['site'])) { echo $_POST['site']; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <select name="site" onchange="this.form.submit();"> <?php echo get_options(); ?> </select>
-
Hi, how to generate auto increment ID with combination of characters and number. For example, i would like to have product ID start from PROD00001. When i add second product, the ID will check on the existing database to check PROD00001 is the latest ID. So, the second product ID will +1, become PROD00002.
-
Hi all. How can i send mail to multiple users at the same time with each user getting their own related data. I'm using php mailer as an engine to send the mail. Based on this, i'd have loved to setup a cron for it but i do not know how, so i figure i'd just do it manually before i get to know how to setup a cron job. It's just to send a reminder to users and each user has a different subscription expiry time. I want each user to get their respective expiration date, expiry day etc. Thanks if(isset($_POST['send_reminder'])){ $sql = "SELECT * FROM users WHERE status = '$status'"; $stmt = $pdo->query($sql); $stmt->execute(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ $name = $row['name']; $acct_no = $row['acct_no']; $email_addresses = $row['email']; $expiry_date = $row['expiry_date']; $expiry_day = $row['expiry_day']; } $message="Hello $name,<br> <p> This is to remind you that your subscription will expire in $expiry_day. </p> <p> Details as follows: Name: $name<br> Account Number: $acct_no<br> Email: $email_addresses<br> Expire in days: $expiry_day<br> Expiry Date: $expiry_date </p> <p> Thank you </p> $mail = new PHPMailer; //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'mail.server.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'mails@services.cap'; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 465; // TCP port to connect to $mail->From = mails@services.cap'; $mail->FromName = 'Club 404'; $mail->addAddress($email_addresses); // Add a recipient $mail->WordWrap = 587; // Set word wrap to 50 characters $mail->AddEmbeddedImage("../img/logo.png", "my_logo"); $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'REMINDER ON CLUB EXPIRY DATE'; $mail->Body = $mess; $mail->send(); }
-
i have this array: test={'dog','cow','shee'}; how can I pass it to a stored procedure: call sp_array(in i_arr1 text); what data type should I use? Iam currently looping through and multi executing the procedure in php to pass the values one by one .But is there a way to pass it to the procedure and then assign it to a cursor in sql.
-
I have this query : select GROUP_CONCAT(Other_type)as projtype2,PrT_id from _Otherproject_typetbl,_project_typetbl where _Otherproject_typetbl.Other_id=_project_typetbl.Other_id and Project_id=in_projid; and it gives this result: +-----------+--------+ | projtype2 | PrT_id | +-----------+--------+ | All_other | HR_3 | +-----------+--------+ 1 row in set (0.04 sec) I would to set the value incase it is "Allother" to be set to empty or null in any of the columns +-----------+--------+ | projtype2 | PrT_id | +-----------+--------+ | null | HR_3 | +-----------+--------+ 1 row in set (0.04 sec)
-
I have 3 variables coming from 3 columns from a table. I want to insert these variables into 3 columns in a different table. Variables are name, cover, and pageno. The issue is I can see the values in the hidden inputs this is when the page loads when nothing is selected in the combobox??? If I select book number two the same values are in the hidden inputs. If I select book one this is what I see because when the page loads it populates the values as book 1. <input type="hidden" name="cover" value="cover 1"> <input type="hidden" name="pageno" value="pageno 1"> If I select book two this is what I see. <input type="hidden" name="cover" value="cover 1"> <input type="hidden" name="pageno" value="pageno 1"> Make sense? If not, no matter which book I select I see the same values. Here's the code. <select name="name"> <option value="<?php echo "{$_POST['name']}"; ?>"> </option> <?php include('theconnection.php'); $con = mysqli_connect($host,$user,$pass,$dbName); if (!$con) { die('cannot connect: ' . mysqli_error($con)); } mysqli_select_db($con,"thebooks"); $result = mysqli_query($con,"SELECT * FROM books"); $result = mysqli_query($con,"SELECT b.id, b.name, b.cover, b.pageno FROM books"); $cover = ''; $pageno = ''; while($row = mysqli_fetch_array($result)) { echo ("<option value='$row[name]'>$row[name] $row[cover], $row[pageno] </option>"); $cover = "$row[cover]"; $pageno = "$row[pageno]"; } ?> </select> <input type="hidden" name="cover" value="<?php echo $cover; ?>"> <input type="hidden" name="pageno" value="<?php echo $pageno; ?>"> Maybe Javascript will work? I can't figure out how to do this with Javascript either.
-
Hello I have a php script I actually got from Stackoverflow, on one of the questions asked. I'm not really sure where to apply it, I put it in some code that I had already that submits the data to be put in the text file. It downloads the file, but inside it has php errors. The errors are: Undefined variable: month in xxx.xxx.xxx on line 12 Undefined variable: res xxx.xxx.xxx on line 14 mysql_fetch_array() expects parameter 1 to be resource, null given in xxx.xxx.xxx on line 14 The script I have is: //Below is where you create particular month's text file $file = $month . '.txt'; $handle = fopen($file, "w"); while ($row=mysql_fetch_array($res)){ $writestring = $row['data_I_want'] . "\r\n"; fwrite($handle, $writestring); } fclose($handle); $data = file_get_contents($file); echo $data; //Now the file is ready with data from database //Add below to download the text file created $filename = $file; //name of the file $filepath = $file; //location of the file. I have put $file since your file is create on the same folder where this script is header("Cache-control: private"); header("Content-type: application/force-download"); header("Content-transfer-encoding: binary\n"); header("Content-disposition: attachment; filename=\"$filename\""); header("Content-Length: ".filesize($filepath)); readfile($filepath); exit;
-
Having problems viewing pages of my codeigniter based hospital management system. Can only view the homepage, other pages missing, really dont know how to fix it. Uploaded it with the sql on google drive. https://drive.google.com/file/d/0B2NbxciE_vU6S29hZGl5OW1QbzQ/view?usp=sharing Only page uploaded is tthe homepage as see below, rest are missing -- -- Dumping data for table `pages` -- INSERT INTO `pages` (`id`, `title`, `slug`, `parent_id`, `order`, `template`, `body`) VALUES (1, 'Home', '', 0, 1, 'homepage', '');
-
Best, I am currently working on a mafia crime game. But there is something wrong with my script. I have 1 error on my news. php, and will you even error + the script here. I know that my script is messy but am still but a novice It would be great if this solved hit! And sorry for my bad English. (IM a Belgian) Here the error + script: error: Parse error: syntax error, unexpected $end in C:\xampp\htdocs\_menu_l.php on line 881 and here the script: <?php $__admin = 16; $__gmod = 8; $__fmod = 4; $__help = 2; include("./includes/_mysql_connection.php"); include("./includes/_functions.php"); include("_functies.php"); if(!isset($_SESSION['__id'])){ header("location: index.php"); } define("ID", $_SESSION['__id']); $select = mysql_query("SELECT `username`, `ip`, `lastclick`, `id` FROM `users` WHERE `id` = ".ID." LIMIT 1") or die(mysql_error()); if(mysql_num_rows($select) == 0){ header("location: index.php"); } $res = mysql_fetch_assoc($select); $naam = $res['username']; $SESSID = $_COOKIE['PHPSESSID']; $s = mysql_query("SELECT `id` FROM `sessions` WHERE `id`=".ID." AND `SESSID`='".mr($SESSID)."' LIMIT 1") or die(mysql_error()); if(mysql_num_rows($s) == 0){ $sql = mysql_query("SELECT `id` FROM `sessions` WHERE `id`=".ID." LIMIT 1") or die(mysql_error()); if(mysql_num_rows($sql) == 0){ mysql_query("INSERT INTO `sessions`(`id`, `SESSID`) VALUES (".ID.", '".mr($_COOKIE['PHPSESSID'])."')") or die(mysql_error()); } /* else { unset($_SESSION); header("location: index.php"); }*/ if(mysql_num_rows($s) > 0 AND !isset($_SESSION['logged'])) { unset($_SESSION); header("location: index.php"); } } mysql_query("UPDATE `sessions` SET `SESSID`='".$SESSID."' WHERE `id`=".ID." LIMIT 1") or die(mysql_error()); // Selecteer wat data $sql = mysql_query("SELECT `speldata`. * , `landen`.`land` , `familie`.`naam` FROM `speldata` LEFT JOIN `landen` ON ( `speldata`.`land_id` = `landen`.`id` ) LEFT JOIN `familie` ON ( `speldata`.`familie_id` = `familie`.`id` ) WHERE `speldata`.`id` =".ID." LIMIT 1 ") or die(mysql_error()); $res = mysql_fetch_assoc($sql); /* Data invullen */ if(!is_null($res['naam'])){ $hasfam = true; } else { $hasfam = false; } $sql = mysql_query("SELECT COUNT(`id`) FROM `familie` WHERE `baas_id`=".ID." LIMIT 1") or die(mysql_error()); if(mysql_result($sql, 0) == 1){ $famboss = true; } else { $famboss = false; } $sql = mysql_query("SELECT COUNT(`id`) FROM `familie` WHERE `onderbaas_id`=".ID." LIMIT 1") or die(mysql_error()); if(mysql_result($sql, 0) == 1){ $famunderboss = true; } else { $famunderboss = false; } $sql = mysql_query("SELECT COUNT(`id`) FROM `familie` WHERE `shoutboxmod`=".ID." LIMIT 1") or die(mysql_error()); if(mysql_result($sql, 0) == 1){ $shoutmod = true; } else { $shoutmod = false; } $sql = mysql_query("SELECT COUNT(`id`) FROM `familie` WHERE `onderbaas_id2`=".ID." LIMIT 1") or die(mysql_error()); if(mysql_result($sql, 0) == 1){ $famunderboss2 = true; } else { $famunderboss2 = false; } $s = mysql_query("SELECT `misdaden_s`, `misdaden_g`, `auto_s`, `auto_g`, `wapenervaring`, `hoerenpimpen`, `kracht`, `fam_overvallen`, `bombaderen`, `stem`, `route66`, `computer` FROM `usertimes` WHERE `id`=".ID) or die(mysql_error()); $r = mysql_fetch_assoc($s); $sql_sd = mysql_query("SELECT `donateur`, `status` FROM `status` WHERE `id`=".ID) or die(mysql_error()); $rs = mysql_fetch_assoc($sql_sd); $__status = $rs['status']; $__dona = $rs['donateur']; $__rank = $rs['status']; if(isset($_COOKIE['banned']) && $__status > 0){ setcookie("banned", "true", time()); mysql_query("UPDATE `status` SET `status`=1 WHERE `id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `ip_banned` WHERE `ip`='".mr($_SERVER['REMOTE_ADDR'])."'") or die(mysql_error()); mysql_query("DELETE FROM `bans` WHERE `id`=".ID) or die(mysql_error()); } $v_id = array(); $v_ip = array(); $v_reden = "Hacken"; $v_names = array(""); if(in_array(ID, $v_id) || in_array($_SERVER['REMOTE_ADDR'], $v_ip) || in_array($naam, $v_names)){ die("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html> <head> <meta http-equiv='content-type' content='text/html; charset=iso-8859-1' /> <meta name='author' content='$naam' /> <link rel='shortcut icon' href='favicon.ico'> <link rel='icon' href='favicon.ico'> <link href='styles.css' rel='stylesheet' type='text/css' /> <title>Verbannen!</title> </head> <body style='background-color: #464646; text-align: center; margin-top: 7%'> <img src='IMG/ban.jpg' alt=''> <br><br> <font size='2'> <b> Je bent verbannen! <br><br> </font> Reden:</b> ".$v_reden."<br><br> </body> </html>"); } $_s = mysql_query("SELECT COUNT(`ip`) FROM `ip_banned` WHERE `ip`='".mr($_SERVER['REMOTE_ADDR'])."'") or die(mysql_error()); if($__status == 0 || isset($_COOKIE['banned']) || mysql_result($_s, 0) >= 1){ $sql = mysql_query("SELECT `reden` FROM `bans` WHERE `id`=".ID) or die(mysql_error()); $res = mysql_fetch_assoc($sql); if(!isset($_COOKIE['banned'])){ setcookie("banned", "true", (time() + (60*60*24*200))); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv='content-type' content='text/html; charset=iso-8859-1' /> <meta name='author' content='$naam' /> <link rel='shortcut icon' href='favicon.ico'> <link rel='icon' href='favicon.ico'> <link href='styles.css' rel='stylesheet' type='text/css' /> <title>Verbannen!</title> </head> <body style='background-color: #464646; text-align: center; margin-top: 7%'> <img src="IMG/ban.jpg" alt=""> <br><br> <font size='2'> <b> Je bent verbannen! <br><br> </font> Reden:</b> <?=$res['reden'];?><br><br> </body> </html> <? die(); } /* Zet er een nieuwe tijd in, om te zien dat ie online is */ if(!isset($_COOKIE['offline']) || $__status <= 1){ mysql_query("UPDATE `users` SET `lastclick`=".time()." WHERE `id`=".ID) or die(mysql_error()); } /*$poll = mysql_query("SELECT `user_id` FROM `poll_answers` WHERE `user_id`=".ID) or die(mysql_error()); if(mysql_num_rows($poll) == 0 AND $_SERVER['REQUEST_URI'] != "/poll.php"){ header("location: poll.php"); } */ $adminpagina = array("/famshoutbox.php", "/nieuws.php"); if($_SERVER['REQUEST_URI'] == $adminpagina){ header("location: nieuws.php"); } $st = cname(ID, $naam, true); $status = $st['status']; $familie = $res['naam']; $famID = $res['familie_id']; $staatID = $res['land_id']; $staat = $res['land']; if($staatID < 1 || $staatID > 11){ mysql_query("UPDATE `speldata` SET `land_id`=1 WHERE `id`=".ID) or die(mysql_error()); } $contant = $res['cashmoney']; $bank = $res['bankmoney']; /* Aantal hoeren, eerpunten, kills */ $hoeren = $res['hoeren_straat']; $hoeren_count = $res['count_hoeren']; $eerpunten = $res['eerpunten']; $killed = $res['kills']; mysql_query("UPDATE speldata SET cashmoney='0' WHERE cashmoney<'0'"); mysql_query("UPDATE speldata SET bankmoney='0' WHERE bankmoney<'0'"); /* Rank */ $leven = $res['leven']; if($leven == 0){ if(isset($_POST['reset'])){ $newname = trim($_POST['name']); $id = getid($newname); if(!is_name($newname)){ $msg = "Je hebt ongeldige tekens in je nieuwe naam gedaan!"; } elseif($id != false && $id != ID){ $msg = "Deze naam is al bezet!"; } else { cname(ID, $newname, false, true); mysql_query("UPDATE `speldata` SET `leven`=100, `hoeren_straat`=0, `rank`=0.5, `cashmoney`=2500, `bankmoney`=10000 WHERE `id`=".ID) or die(mysql_error()); mysql_query("UPDATE `status` SET `bescherming`=0 WHERE `id`=".ID) or die(mysql_error()); mysql_query("UPDATE `users` SET registerDate=NOW(),`username`='".$newname."' WHERE `id`=".ID) or die(mysql_error()); mysql_query("UPDATE `vrienden_blokkeren` SET `who`='".$newname."' WHERE `who`=".ID) or die(mysql_error()); mysql_query("UPDATE `uitrust` SET `kogels`=10, `huizen_gehad`='', `woning`=0, `wapen`=0, `verd`=0, `vliegtuig`=0 WHERE `id`=".ID) or die(mysql_error()); mysql_query("UPDATE `userstats` SET `misdaden_s`=0, `misdaden_g`=0, `auto_s`=0, `auto_g`=0, `kracht`=0, `winst`=0, `verlies`=0, `wapenervaring`=0, `wapentraining`=0, `hacken`=0, `hack_s`=0, `program`=0, `program_s`=0, `beheer`=0, `beheer_s`=0 WHERE `id`=".ID); mysql_query("UPDATE `usertimes` SET `misdaden_s`=0, `misdaden_g`=0, `auto_s`=0, `auto_g`=0, `wapenervaring`=0, `hoerenpimpen`=0, `reizen`=0, `kracht`=0 WHERE `id`=".ID); mysql_query("DELETE FROM `hoeren_rld` WHERE `id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `hoeren_voorbereiding` WHERE `id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `gevangenis` WHERE `user_id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `garage` WHERE `user_id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `crusher_converter` WHERE `user_id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `drugs_drank` WHERE `user_id`=".ID) or die(mysql_error()); // mysql_query("UPDATE plattegrond SET owner='0',Gevangenis='0',Red_Light_District='0',Ziekenhuis='0',Casino='0' WHERE owner='".ID."'"); mysql_query("UPDATE speldata SET platte='0' WHERE id='".ID."'"); header("location: nieuws.php"); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv='content-type' content='text/html; charset=iso-8859-1' /> <meta name='author' content='$naam' /> <link rel='shortcut icon' href='favicon.ico'> <link rel='icon' href='favicon.ico'> <link href='styles.css' rel='stylesheet' type='text/css' /> </head> <body style='background-color: #303030; text-align: center; margin-top: 7%'> <form method='post' action='nieuws.php'> <img src="IMG/grave_rip.jpg" alt=""> <br><br> <font size='2'> <b> Je bent vermoord! <br><br> <?php if(isset($msg)){ echo $msg; } ?> Naam: <input type='text' name='name' value='<?=$naam;?>' maxlength='12' /><br><br> <input type='submit' name='reset' value='Opnieuw Beginnen!' /> </b> </font> </form> </body> </html> <? die(); } $rank = getRank($res['rank']); $rankID = $rank['rankID']; $gSql = mysql_query("SELECT `tijd` FROM `gevangenis` WHERE `user_id`=".ID." AND `tijd`>".time()." LIMIT 1") or die(mysql_error()); if(mysql_num_rows($gSql) == 1){ $gevangen = true; $gRes = mysql_fetch_assoc($gSql); $seconden = $gRes['tijd'] - time(); } else { $gevangen = false; } $rSql = mysql_query("SELECT `reizen` FROM `usertimes` WHERE `id`=".ID) or die(mysql_error()); $rRes = mysql_fetch_assoc($rSql); if($rRes['reizen'] > time()) { $reizen = true; $reistijd = $rRes['reizen'] - time(); } else { $reizen = false; } include("_mainMenus.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv='content-type' content='text/html; charset=iso-8859-1' /> <meta name='author' content='$naam' /> <link href='styles.css' rel='stylesheet' type='text/css' /> <link rel='shortcut icon' href='favicon.ico'> <link rel='icon' href='favicon.ico'> <title>MyWay</title> </head> <body> <table width='100%' cellspacing='0' style='margin: 0px;'> <tr> <td width='14%' style='vertical-align: top;'> <table border='0' cellspacing='1' width='100%' bgcolor='#000'> <?php foreach($menuleft AS $cat => $subCats){ echo " <tr><td class='menutop'>".$cat."</td></tr>"; if(is_array($subCats)){ foreach($subCats AS $url => $name){ if($url == "donatieshop.php"){ echo " <tr><td class='menu'><img src='IMG/star.jpg' alt=''><a href='".$url."'>".$name."</a></td></tr>"; } else { echo " <tr><td class='menu'><a href='".$url."'> - ".$name."</a></td></tr>"; } } } } ?> </table> </td> <td width='72%' style='vertical-align: top; height: 0px; text-align:center;' align='center'> <table border='0' cellspacing='0' width='100%' align='center'> <tr> <td> <table border='0' cellspacing='1' width='96%' bgcolor='#000' align='center'> <tr> <td class='header' style='padding: 0px;'> <table style="margin:0px; padding:0px;vertical-align: bottom;" cellpadding="0" cellspacing="0" width="100%"> <tr> <td style="padding:0px; margin:0px;"> <img src="/IMG/header_image.jpg" alt="" /> </td> <td> <div class="counter_view"> <table cellpadding="0" cellspacing="0" style="margin: 0px; padding: 0px;"> <tr> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/gun.png' alt='' title='Misdaden/Familie misdaad' border='0'> </td> <td><?php if($r['misdaden_s'] < time()){ echo "<a href='misdaad.php'>Nu</a>"; } else { echo "<span id='cdmisdaad_s'>".($r['misdaden_s'] - time())."</span>".countDown("misdaad_s", ($r['misdaden_s'] - time())); } ?></td> </tr> </table> </td> <td style="width: 50px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/gun_anchor.png' alt='' title='Wapen Training' border='0'> </td> <td> <?php if($r['wapenervaring'] < time()){ echo "<a href='wapenervaring.php'>Nu</a>"; } else { echo "<span id='cdwapenervaring'>".($r['wapenervaring'] - time())."</span>".countDown("wapenervaring", ($r['wapenervaring'] - time())); } ?> </td> </tr> </table> </td> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/anchor.png' alt='' title='Sportschool Training' border='0'> </td> <td> <?php if($r['kracht'] < time()){ echo "<a href='sportschool.php'>Nu</a>"; } else { echo "<span id='cdkracht'>".($r['kracht'] - time())."</span>".countDown("kracht", ($r['kracht'] - time())); } ?> </td> </tr> </table> </td> </tr> <tr> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/car.png' alt='' title='Voertuigen Beginners' border='0'> </td> <td> <?php if($r['auto_s'] < time()){ echo "<a href='stealcar.php'>Nu</a>"; } else { echo "<span id='cdauto_s'>".($r['auto_s'] - time())."</span>".countDown("auto_s", ($r['auto_s'] - time())); } ?> </td> </tr> </table> </td> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/car_add.png' alt='' title='Voertuigen Gevorderden' border='0'> </td> <td> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <?php if($rank['rankID']< 5){ ?> <img src='/images/icons/cross_small.png' alt='' border='0'> <?php } else { if($r['auto_g'] < time()){ echo "<a href='stealcar.php'>Nu</a>"; } else { echo "<span id='cdauto_g'>".($r['auto_g'] - time())."</span>".countDown("auto_g", ($r['auto_g'] - time())); } } ?> </td> <td> </td> </tr> </table> </td> </tr> </table> </td> <td style="width: 50px;" colspan="2"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/user_female.png' alt='' title='Hoeren Pimpen' border='0'> </td> <td> <?php if($r['hoerenpimpen'] < time()){ echo "<a href='rld.php'>Nu</a>"; } else { echo "<span id='cdhoerenpimpen'>".($r['hoerenpimpen'] - time())."</span>".countDown("hoerenpimpen", ($r['hoerenpimpen'] - time())); } ?> </td> </tr> </table> </td> </tr> <tr> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/group.png' alt='' title='Familie Overval' border='0'> </td> <td> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <?php if($famID == 0){ ?> <img src='/images/icons/cross_small.png' alt='' border='0'> <?php } else { if($r['fam_overvallen'] < time()){ echo "<a href='famoverval.php'>Nu</a>"; } else { echo "<span id='cdfam_overvallen'>".($r['fam_overvallen'] - time())."</span>".countDown("fam_overvallen", ($r['fam_overvallen'] - time())); } } ?> </td> <td> </td> </tr> </table> </td> </tr> </table> </td> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/group_gun.png' alt='' title='Route 66' border='0'> </td> <td> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <?php if($r['route66'] < time()){ echo "<a href='route66.php'>Nu</a>"; } else { echo "<span id='cdroute66'>".($r['route66'] - time())."</span>".countDown("route66", ($r['route66'] - time())); } ?> </td> <td> </td> </tr> </table> </td> </tr> </table> </td> <td style="width: 50px;" colspan="2"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/bomb.png' alt='' title='Aanslag Plegen' border='0'> </td> <td> <?php if($r['bombaderen'] < time()){ echo "<a href='plattegrond.php'>Nu</a>"; } else { echo "<span id='cdbombaderen'>".($r['bombaderen'] - time())."</span>".countDown("bombaderen", ($r['bombaderen'] - time())); } ?> </td> </tr> </table> </td> </tr> </table> </div> </td> </tr> </table> </td> </tr> <td class='subheader'> <table width='100%' border='0' cellspacing='0' style='margin: 0px;' cellpadding='0'> <tr> <td style='text-align: left;'> <a href='fambericht.php'><img src='IMG/tab/fambericht.jpg' alt='' border='0' /></a><? if($__status >= 16){echo "<a href='hqadminbasis.php'><img src='IMG/tab/admin.jpg' alt='' border='0' /></a>"; } ?> <? if($__status == { echo "<a href='gmod.php'><img src='IMG/tab/gamemod.jpg' alt='' border='0' /></a>"; } ?> <? if($__status == 4){ echo "<a href='forummod.php'><img src='IMG/tab/forummod.jpg' alt='' border='0' /></a>"; } ?> <? if($__status == 2){ echo "<a href='hdbasis.php'><img src='IMG/tab/helpdesk.jpg' alt='' border='0' /></a>"; } ?> <?php $sql = mysql_query("SELECT `id` FROM `berichten` WHERE `gelezen`=0 AND `ontvanger_id`=".ID." AND `in_inbox`=0 LIMIT 1") or die(mysql_error()); if(mysql_num_rows($sql) == 1){ echo "<a href='berichten.php?x=inbox'><img src='IMG/tab/inbox_n.jpg' alt='' border='0' /></a>"; } else { echo "<a href='berichten.php?x=inbox'><img src='IMG/tab/inbox.jpg' alt='' border='0' /></a>"; } ?><a href='berichten.php?x=outbox'><img src='IMG/tab/outbox.jpg' alt='' border='0' /></a><a href='berichten.php?x=new'><img src='IMG/tab/new.jpg' alt='' border='0' /></a> </td> <td style='text-align: right;'> <?php if($gevangen){ echo " <table border='0' cellspacing='0' cellpadding='0' align='right'> <tr> <td> <img src='IMG/gevang.jpg' alt='' style='margin: 0px;'> </td> <td> <b><span id='cdgevang'>".$seconden."</span></b> </td> </tr> </table> ".countDown("gevang", $seconden); } if($reizen){ echo " <table border='0' cellspacing='0' cellpadding='0' align='right'> <tr> <td> <img src='IMG/reizen.jpg' alt='' style='margin: 0px;'> </td> <td> <b><span id='cdreis'>".$reistijd."</span></b> </td> </tr> </table> ".countDown("reis", $reistijd); } ?> </td> </tr> </table> </td> </tr> </table> </td> </tr> <?php $SSQl = mysql_query("SELECT status FROM speldata WHERE id=".ID) or die(mysql_error()); $QREs = mysql_fetch_assoc($SSQl); $statu = $QREs['status']; $MSQL = mysql_query("SELECT m_12 FROM count_missions WHERE id=".ID) or die(mysql_error()); $QrSl = mysql_fetch_assoc($MSQL); $m12 = $QrSl['m_12']; if($statu == 0){ $plrstatus = Online; } elseif($statu == 1){ $plrstatus = Online; } elseif($statu == 2){ $plrstatus = Bezet; } elseif($statu == 3){ $plrstatus = Afwezig; } elseif($statu == 4){ $plrstatus = Smokkelen; } elseif($statu == 5){ $plrstatus = Designen; } elseif($statu == 6){ $plrstatus = Druk; } elseif($statu == 7){ $plrstatus = Eten; } elseif($statu == 99){ $plrstatus = Scripten; } elseif($statu == 100){ $plrstatus = Legend; } if(isset($_POST['go'])){ $actie = $_POST['actie']; if($actie == 1){ mysql_query("UPDATE speldata SET status = 1 WHERE id=".ID); } elseif($actie == 2){ mysql_query("UPDATE speldata SET status = 2 WHERE id=".ID); } elseif($actie == 3){ mysql_query("UPDATE speldata SET status = 3 WHERE id=".ID); } elseif($actie == 4){ mysql_query("UPDATE speldata SET status = 4 WHERE id=".ID); } elseif($actie == 5){ mysql_query("UPDATE speldata SET status = 5 WHERE id=".ID); } elseif($actie == 6){ mysql_query("UPDATE speldata SET status = 6 WHERE id=".ID); } elseif($actie == 7){ mysql_query("UPDATE speldata SET status = 7 WHERE id=".ID); } elseif($actie == 99){ mysql_query("UPDATE speldata SET status = 99 WHERE id=".ID); } elseif($actie == 100){ mysql_query("UPDATE speldata SET status = 100 WHERE id=".ID); } } ?> <tr> <form method='post' actie='".$_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING']."'> <td style='text-align: right; padding-right: 27px; padding-top: 5px; padding-bottom: 5px;'> <select name='actie'> <option value='0'>-- <?=$plrstatus;?> --</option> <option value='1'>Online</option> <option value='2'>Bezet</option> <option value='3'>Afwezig</option> <option value='4'>Smokkelen</option> <option value='5'>Designen</option> <option value='6'>Druk</option> <option value='7'>Eten</option> <?php if($__status == 16){ ?> <option value='99'>Scripten</option> <? } ?> <?php if($m_12 == 1){ ?> <option value='100'>Legend</option> <? } ?> </select> <input type='submit' name='go' value='Update!' /> </td> </tr> </form> </html> <tr> <td style='text-align: center;'> <?php $sql = mysql_query("SELECT `bankmoney`, `cashmoney` FROM `speldata` WHERE `id`=".ID) or die(mysql_error()); $res = mysql_fetch_assoc($sql); if(ID == ''){ //Logboek script als je iemand niet vertrouwd! $logQuery = "INSERT INTO `logboek`(`id_user`, `ip`,`date`, `page`, `money`) VALUES (".ID.", '".$_SERVER['REMOTE_ADDR']."', NOW(), '".mr($_SERVER['REQUEST_URI'])."', ".($res['bankmoney'] + $res['cashmoney']).")"; mysql_query($logQuery) or die(mysql_error()); } if($res['cashmoney'] < 0){ mysql_query("UPDATE `speldata` SET `cashmoney`=0, `bankmoney`=`bankmoney`+".$res['cashmoney']." WHERE `id`=".ID) or die(mysql_error()); $menu_rechts_top['Contant'] = "\$0"; $menu_rechts_top['Bank'] = "\$".number_format($bank + $res['cashmoney']); } if($res['bankmoney'] < 0){ if($_GET['p'] == "famdonate"){ mysql_query("UPDATE `familie` SET `geld`=`geld`+".$res['bankmoney']." WHERE `id`=".$famID) or die(mysql_error()); mysql_query("UPDATE `speldata` SET `bankmoney`=0 WHERE `id`=".ID) or die(mysql_error()); mysql_query("UPDATE `famdonaties` SET `total`=`total`+".$res['bankmoney']." WHERE `user_id`=".ID." AND `fam_id`=".$famID) or die(mysql_error()); $menu_rechts_top['Bank'] = "\$0"; } elseif($url == "markt.php"){ $min = (int) str_replace("-", "", $res['bankmoney']); $s = mysql_query("UPDATE `markt_alg` SET `bieder`=0, `high_bod`=`bied_bod` WHERE `bieder`=".ID." AND `high_bod`>=".$min." LIMIT 1") or die(mysql_error()); if(mysql_affected_rows($s) == 0){ $s = mysql_query("SELECT `id` FROM `markt_alg` WHERE `bieder` =".ID." AND `high_bod` <".$min." ORDER BY `high_bod` DESC LIMIT 1 ") or die(mysql_error()); $r = mysql_fetch_assoc($s); mysql_query("UPDATE `markt_alg` SET `bieder`=0, `high_bod`=`bied_bod` WHERE `id`=".$r['id']) or die(mysql_error()); mysql_query("UPDATE `speldata` SET `bankmoney`=0 WHERE `id`=".ID) or die(mysql_error()); } else { mysql_query("UPDATE `speldata` SET `bankmoney`=0 WHERE `id`=".ID) or die(mysql_error()); } } else { mysql_query("UPDATE `speldata` SET `bankmoney`=0, `cashmoney`=`cashmoney`+".$res['bankmoney']." WHERE `id`=".ID) or die(mysql_error()); $menu_rechts_top['Bank'] = "\$0"; $menu_rechts_top['Contant'] = "\$".number_format($contant + $res['bankmoney']); } } ?> Thanks in advance for the help! _menu_l.php
-
Hi All, I am having trouble getting my script to work. I have two tables. Stocks Calendar The stocks table only has two fields, Company and Symbol The Calendar table has a field with the same title SName. I would like to return the matching rows in the calendar that contain the company name from the Stocks Table along with a date field. I think utilizing the LIKE command is best. $query = "SELECT * FROM Stocks"; $query2 = "SELECT * FROM Calendar"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo $row['SName'] ," ", $row['Symbol'] ; echo "<br />"; } $result2 = mysql_query($query2) or die(mysql_error()); while($row2 = mysql_fetch_assoc($result2)){ echo $row2['SName'] ," ", $row2[''] ; echo "<br />"; } ?> <tr> <td><p><?php echo $row['Symbol']; ?></p></td> <td><p><?php echo $row['SName']; ?></p></td> <td><p><?php echo $row['Primary Completion Date']; ?></p></td> </tr> </table> </body> </html>
-
Good evening, I am working on a query at my office that is joining multiple tables in order to display a User notification (similar to facebook). The notifications are based on user department, access level, and position. I want to display all of the announcements filtered for the user that is in the CWAnnouncement table and the NotificationArchive Table where the NotificationArchive.Active is equal to 1 or if they have not made an entry in the NotificationArchive table. If NotificationArchive.Active is equal to 0 then I do not want it to show up in the query results. So far the user filter works but I am having trouble display the results based on who the user is and whether or not they have an announcement in the NotificationArchive table. I hope this make sense. Help would be greatly appreciated this will be my first major project for this company and I want to do a good job for them. Thanks, SELECT ROW_NUMBER() OVER(ORDER BY StartDate DESC) AS 'Rownumber', dbo."User".USERID, CWNotifications.* FROM dbo."User" LEFT JOIN ( SELECT dbo.CWAnnouncements.AnnouncementID, dbo.CWAnnouncements.Title, dbo.CWAnnouncements.Message, dbo.CWAnnouncements.StartDate, dbo.CWAnnouncements.EndDate, dbo.CWAnnouncements.AllStaff, dbo.CWAnnouncements.MGR, dbo.CWAnnouncements.L504, dbo.CWAnnouncements.AdminSupport, dbo.CWAnnouncements.EXP, dbo.CWAnnouncements.IT, dbo.CWAnnouncements.Legal, dbo.CWAnnouncements.PSA, dbo.CWAnnouncements.SRV, dbo.CWAnnouncements.QC, dbo.CWAnnouncements.Active, dbo.CWAnnouncements.UserID, dbo.CWAnnouncements.LS, dbo.CWAnnouncements.LSA, dbo.CWAnnouncements.FileRoom, dbo.CWAnnouncements.Collateral, NotificationArchive.NotificationID, NotificationArchive.Active AS ActiveNote FROM dbo.CWAnnouncements Left JOIN dbo.NotificationArchive ON dbo.CWAnnouncements.AnnouncementID=dbo.NotificationArchive.AnnouncementID WHERE (dbo.NotificationArchive.UserID='#GetAuthUser()#' AND dbo.CWAnnouncements.Active=1 AND dbo.NotificationArchive.UserID IS NULL) OR dbo.CWAnnouncements.UserID='#GetAuthUser()#' AND dbo.NotificationArchive.UserID='#GetAuthUser()#' AND dbo.CWAnnouncements.Active=1 AND dbo.NotificationArchive.Active = 1 ) CWNotifications ON (dbo."User".MGR>=CWNotifications.MGR AND CWNotifications.MGR >=1 OR dbo."User".QC>=CWNotifications.QC AND CWNotifications.QC >=1 OR dbo."User".IT>=CWNotifications.IT AND CWNotifications.IT >=1 OR Dbo."User".LEG>=CWNotifications.Legal AND CWNotifications.Legal >1 OR (dbo."User".AdminSupport=CWNotifications.AdminSupport AND CWNotifications.AdminSupport = 1 OR dbo."User".Fileroom=CWNotifications.Fileroom AND CWNotifications.Fileroom = 1 OR dbo."User".Collateral=CWNotifications.Collateral AND CWNotifications.Collateral = 1) OR (dbo."User".L504>=CWNotifications.L504 AND CWNotifications.L504 >= 1 or dbo."User".EXP>=CWNotifications.EXP AND CWNotifications.EXP >= 1 or dbo."User".SRV>=CWNotifications.SRV AND CWNotifications.SRV >= 1 or dbo."User".PSA>=CWNotifications.PSA AND CWNotifications.PSA >= 1) AND (dbo."User".LS=CWNotifications.LS AND CWNotifications.LS = 1 OR dbo."User".LSA=CWNotifications.LSA AND CWNotifications.LSA = 1) OR CWNotifications.AllStaff=1) AND CWNotifications.Active=1 WHERE (dbo."user".USERID='#GetAuthUser()#') ORDER BY StartDate DESC
-
Hi look for some help with querying based on todays date. I'm trying to count all the entries in the database based on username, status, date. The date bit is where I' stuck (see screen shot of database) Based on data in database I should get a count of 3 but get nothing?? The result I get is 0 and should be 3 based on date Any help would be a great help Cheers Chris //date bit $d=strtotime("today"); $wholedate2 = date("Y-m-d", $d); //query $query_rsUser = "SELECT COUNT(*) FROM quotes WHERE quotes.quote_user = 'username' AND quotes.quote_complete = '$date2' AND quotes.quote_status = 'Complete'";
-
Hey Guys. Long time no speak to you all. I hope everyone is well. OK so I have a search page which searches through a list of members. Works great and here is the code for that..... mysql_select_db($database_dbcon, $dbcon);$query_allClients = "SELECT userid, fname, sname, uad1, upost, utoken FROM `user` WHERE (branchid=".$_SESSION['cBranch']." AND permid!=".intval(99)." AND permid!=".intval(4).") AND statusid!='".intval(7)."' AND ( lfname LIKE '%$searchfld%' ORlsname LIKE '%$searchfld%' OR fname LIKE '%$searchfld%' OR sname LIKE '%$searchfld%' OR uad1 LIKE '%$searchfld%' OR uad2 LIKE '%$searchfld%' ORuarea LIKE '%$searchfld%' ORupost LIKE '%$searchfld%') ";$query_limit_allClients = sprintf("%s LIMIT %d, %d", $query_allClients, $startRow_allClients, $maxRows_allClients);$allClients = mysql_query($query_limit_allClients, $dbcon) or die(mysql_error());$row_allClients = mysql_fetch_assoc($allClients); do{echo $row_allClients['fname'].' '.$row_allClients['sname'].' '.$row_allClients['upost'] .' '.$row_allClients['uad1']; } while($row_allClients = mysql_fetch_assoc($allClients)); I have now added the ability to have multiple addresses assigned to one member. To do this I have move the forename and the surname of the (landlord) over to a landlord table. When I add a landlord I add the forename and surname to that table and I then add their home address to the users table with a extra field call ishome = '1' else ishome ='0' I have also added the landlordid field to the user table so I can find any address a particular landlord owns. Tables landlord user landlordid userid lfname ishome lsname landlordid fname sname Now when I search for a postcode the original search query still works great. The only thing I want to change is formatting of how it looks. So currently it brings back user 1 pr7ygf 64 some street name user 2 pr75tf 3 some other street name user 3 pr74rt 5 awesome street etc what I want is for it to effectively group the search results under the landlord each address belongs to, so for example....... landlord 1 user1 pr7ygf 64 some street name landlord 2 user 2 pr75tf 3 some other street name user 3 pr74rt 5 awesome street Ive tried to change the query to whats below however i'm sure sure of how to displace the formatted data SELECT user.userid, user.fname, user.sname, user.uad1, user.upost, user.utoken, landlord.lfname, landlord.lsname FROM `user` INNER JOIN landlord ON user.landlordid = landlord.landlordid WHERE (user.branchid=".$_SESSION['cBranch']." AND user.permid!=".intval(99)." AND user.permid!=".intval(4).") AND user.statusid!='".intval(7)."' AND (user.fname LIKE '%$searchfld%' OR user.sname LIKE '%$searchfld%' OR user.uad1 LIKE '%$searchfld%' OR user.uad2 LIKE '%$searchfld%' ORuser.uarea LIKE '%$searchfld%' ORuser.upost LIKE '%$searchfld%')
-
<?php $con=mysqli_connect("localhost","my_user","","shazz"); $query = mysqli_query($con,"SELECT * from posts2 order by rand() LIMIT 0,4"); $post_title ="shazz"; while ($row=mysqli_fetch_array($query)) { $post_id=$row['post_id']; $post_title=$row['post_title']; $post_date=$row['post_date']; $post_author=$row['post_author']; $post_image=$row['post_image']; $post_keywords=$row['post_keywords']; $post_content=substr($row['post_content'],0,200); } ?> the following are the errors im facing: Warning: mysqli_connect(): (HY000/1044): Access denied for user ''@'localhost' to database 'shazz' inC:\xampp\htdocs\shazz\include\main_content.php on line 3 Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given inC:\xampp\htdocs\shazz\include\main_content.php on line 4 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given inC:\xampp\htdocs\shazz\include\main_content.php on line 6
-
I cannot view data based upon my "wid" in the following code. Basically I have a page that you click on a link, and it passes a number to the "wid" as an integer. I want to call on that corresponding table that has a "like" wid. Here is what I have so far... <?php require 'database.php'; if(!empty($_GET['wid'])) { $wid = $_GET['wid']; } else { $wid = null; } if ( null==$wid ) { header("Location: workorders.php"); } else { $pdo = Database::connect(); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = 'SELECT * FROM items where wid = ?'; $rows = $pdo->query($sql); foreach ($pdo->query($sql) as $row) { echo '<tr>'; echo '<td>'. $row['id'] . '</td>'; echo '<td>'. $row['wid'] . '</td>'; echo '<td>'. $row['model'] . '</td>'; echo '<td>'. $row['description'] . '</td>'; echo '<td>'. $row['cost'] . '</td>'; echo '<td>'. $row['retail'] . '</td>'; echo '<td>'. $row['tax'] . '</td>'; echo '<td width=250>'; } Database::disconnect(); } ?>
-
Hey guys I am struggling here. I am making an recipe website and right now attempting to create an search engine, to search the database for recipes. BUT the search form has form filters the user can edit such as one dropdown menu with preptime, another with what type of meal type, another like what type of cooking method etc etc. So how would the php if statements, query look like, I am not very experienced in sql so that is an main reason I am having such an struggle. Thanks
-
Hello guys, am new to this forum. I have a question that i'd like some help with, this is part of my dissertation project. So i'm creating a system that will gather hardware parts from the database manually (I have 7 hardware parts for each component which is cpu,gpu,psu,motherboard,ram and case) for each and the user will input the price tag in the listbox ($300-$450) for example and the system will display hardware parts from the database within that price range. How can I link the listbox with the database? And how can I make the total price from hardware parts display depending on what the user pressed? Thanks
-
Hi all. I have two tables where the username is what they have in common. i want to perform a join for both tables but i'm having problems with mysql joins. //to get the desire result individually i did //table one $stmt = $pdo->query("SELECT * FROM tableone WHERE username = '$_GET[id]'"); $row = $stmt->fetch(PDO::FETCH_ASSOC); $credit_score = $row['credit_score']; $acct_num = $row['acct_num']; $acct_name = ucwords($row['surname']) ." ". ucwords($row['firstname']); $username = $row['username']; if($credit_score ==3){ $bill_limits = 2000; }elseif($credit_score ==2){ $bill_limits = 1000; }elseif($credit_score ==1){ $bill_limits = 500; } //table two $stmt=$pdo->query("SELECT SUM(amt) as bill FROM tabletwo WHERE username = '$_GET[id]' AND relationship = 'PARENT'"); $row = $stmt->fetch(PDO::FETCH_ASSOC); $bill = $row['bill']; $service_charge_for_limits = '0.05' * $bill; $tax_rate_for_limits = '0.13' * $service_charge_for_limits; $bill_sum = $tax_rate_for_limits + $service_charge_for_limits + $bill; Approved Bill Limits = $<?php echo number_format($bill_limits,2); ?> <br> Bill Limits Used = $<?php echo number_format($bill_sum,2); ?> <br> <?php $available_limits = $bill_limits - $bill_sum; ?> Bill Limits Available = $<?php echo number_format($available_limits,2); ?> The above gives me the correct result, but now i have another page where i want to all the clients and their corresponding available limits, used limits and approve limits form table two and other information from table one On the page i have $stmt = $pdo->prepare("SELECT * FROM tableone WHERE status = 'COMPLETED' ORDER BY id DESC LIMIT $start, $limit"); $stmt->execute(); $num_rows = $stmt->rowCount(); echo "<table width='100%' class='table-responsive table-hover table-condensed table-striped'>"; echo "<tr> <th bgcolor='#444444' align='center'><font color='#fff'>Account Number</th> <th bgcolor='#444444' align='center'><font color='#fff'>Subscriber's Name</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Username</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Limits ($)</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>View Profile</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Delete Account</font></th> </tr>"; // keeps getting the next row until there are no more to get while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['acct_num']; echo "</td><td>"; echo ucwords($row['surname']." ". $row['firstname']); echo "</td><td>"; echo $row['username']; echo "</td><td>"; $credit_score = $row['credit_score']; if($credit_score ==3){ $bill_limits = 2000; }elseif($credit_score ==2){ $bill_limits = 1000; }elseif($credit_score ==1){ $bill_limits = 500; } echo number_format($bill_limits, 2); echo "</td><td>"; echo "<a href='view-client-profile.php?id={$row['username']}'>view more</a>"; echo "</td><td>"; echo "<a href='delete-account.php?id={$row['username']}'>Delete Account</a>"; echo "</td></tr>"; //echo "</td><td>"; //echo "<a href='settle.php?id={$row['acct_num']}'>Points</a>"; } echo "</table>"; How ca i join tableone and tabletwo (plus sum)
-
Hey guys, I am not sure how to phrase this WHERE statement. I currently have this: WHERE approved = "1" AND item_gender="1" OR item_gender="3" It seems to be omitting the 'approved' part. What I require is that approved=1 must be adhered to regardless, but item_gender can be equal to 1 or 3. Any ideas what I am doing wrong? Thanks!
-
Hi I'm currently having a problem with concatenation. My fields is as follow Leerder ID - Van - Eerste Voornaam - Datum 120 - Botha - Peter - 15/02/2015 120 - Botha - Peter - 16/02/2015 121 - Jacobs - John - 17/02/2015 I want it to show as Leerder ID - Van - Eerste Voornaam - Datum 120 - Botha - Peter - 15/02/2015 & 16/02/2015 121 - Jacobs - John - 17/02/2015 My current SQL code is as follow SELECT [Leerder Afwesigheid].[Leerder ID], Students.Van, Students.[Eerste Voornaam], Count([Leerder Afwesigheid].Datum) AS CountOfDatum FROM Students RIGHT JOIN [Leerder Afwesigheid] ON Students.ID = [Leerder Afwesigheid].[Leerder ID] GROUP BY [Leerder Afwesigheid].[Leerder ID], Students.Van, Students.[Eerste Voornaam] HAVING (((Count([Leerder Afwesigheid].Datum))>=5)); How can I change it to add another field Datums Afwesig with the concatenated info?
-
I am trying to create a "login" webpage. The PHP codes for the login (login100.php) are called by another file (index100.php). Whenever I run index100.php on XAMPP, I get two errors: Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\login100.php on line 24 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\login100.php on line 26 My codes for index.php are: <?php include('login100.php'); // Includes Login Script if(isset($_SESSION['login_user'])){ header("location: profile100.php"); } ?> <!DOCTYPE html> <html> <head> <title>Login Form in PHP with Session</title> <link href="style100.css" rel="stylesheet" type="text/css"> </head> <body> <div id="main"> <h1>PHP Login Session Example</h1> <div id="login"> <h2>Login Form</h2> <form action="" method="post"> <label>UserName :</label> <input id="name" name="username" placeholder="username" type="text"> <label>Password :</label> <input id="password" name="password" placeholder="**********" type="password"> <input name="submit" type="submit" value=" Login "> <span><?php echo $error; ?></span> </form> </div> </div> </body> </html> My codes for login.php are: <?php session_start(); // Starting Session $error=''; // Variable To Store Error Message if (isset($_POST['submit'])) { if (empty($_POST['username']) || empty($_POST['password'])) { $error = "Username or Password is invalid"; } else { // Define $username and $password $username=$_POST['username']; $password=$_POST['password']; // Establishing Connection with Server by passing server_name, user_id and password as a parameter $connection = mysqli_connect("localhost", "root", "", "Company"); // To protect MySQL injection for Security purpose $username = stripslashes($username); $password = stripslashes($password); $username = mysqli_real_escape_string($connection, $username); $password = mysqli_real_escape_string($connection, $password); // SQL query to fetch information of registerd users and finds user match. $sql = "SELECT * FROM login where password='$password' AND username='$username'"; $query = mysqli_query($connection, $sql); if (false === $query) { echo mysqli_error(); } $rows = mysqli_num_rows($query); if ($rows == 1) { $_SESSION['login_user']=$username; // Initializing Session header("location: profile100.php"); // Redirecting To Other Page } else { $error = "Username or Password is invalid"; } mysqli_close($connection); // Closing Connection } } ?> I have worked on this for the past FIVE days and I cannot resolve this issue. All I want is a code which fetches a user's username and password from the database, and no such username or password exist, a message saying "invalid password" is generated. For some reason, I'm getting the two error messages above. Can someone help?