Jump to content

Search the Community

Showing results for tags 'sql'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hello, This is my first attempt at sql sub queries, so please excuse me if it's something very silly. Below is my sql: SELECT td.*, CONCAT(me.First_Name,' ', me.Surname) AS managers_full_name, me.Telephone AS managers_telephone, td.status AS status FROM `team_details` td JOIN `members` me ON me.id = td.managers_user_id JOIN (SELECT COUNT(*) AS nap FROM `team_players`) AS tp ON td.team_id = tp.team_id WHERE tp.status = '1' WHERE td.entry_year = '2016' The SQL executed fine before I added the second join with a sub query, now I'm getting the following error: #1064 - 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 'WHERE td.entry_year = '2016' LIMIT 0, 25' at line 5 Is this not the correct way of sub querying, or have I missed something? Any help would be greatly appreciated.
  2. Hi everyone, I don't understand why MySQL won't do execute query to delete record in phpmyadmin. I made a script in PHP, what did I do wrong? First page: <?php session_start(); if ($_SESSION['user']) { echo "<p>You are logging in as ".$_SESSION['user']." <a href='logout.php'>Log out</a></p>"; } else { header('location:denied.php'); } require('require.php'); ?> <!doctype html> <html> <head> <title>Delete your member's information</title> <link href="rcd.css" rel="stylesheet" type="text/css"> <link href="submit.css" rel="stylesheet" type="text/css"> </head> <body> <center> <p>Are you sure you want to delete this member's information?</p> <form action="delete2.php"> <table> <?php $del = $_GET['delete']; $show = "SELECT * FROM Members WHERE ID = '".$del."'"; $result = mysqli_query($Garydb, $show); if (mysqli_num_rows($result)) { while ($rows = mysqli_fetch_assoc($result)) { echo "<tr><td>First Name: </td><td><input type='text' value='".$rows['FirstName']."'></td></tr>"; echo "<tr><td>Last Name: </td><td><input type='text' value='".$rows['LastName']."'></td></tr>"; echo "<tr><td>Birth Month: </td><td><input type='text' value='".$rows['Month']."'></td></tr>"; echo "<tr><td>Email: </td><td><input type='text' value='".$rows['Email']."'></td></tr>"; echo "<tr><td>Local: </td><td><input type='text' value='".$rows['Local']."'></td></tr>"; echo "<tr><td colspan='2'><a href='delete2.php?delete2=".$rows['ID']."' style='font-size:20px;'>Delete Member's Information</a></td></tr>"; } } ?> </table> </form> <p><a href="register.php">Return to register page</a></p> </center> </body> </html> Second Page <?php session_start(); if ($_SESSION['user']) { echo $_SESSION['user']; }else { header('denied.php'); } require("require.php"); if ($_GET['delete2']) { $delete = $_GET['delete2']; } if ($delete) { $del = "DELETE * FROM Members WHERE ID = '".$delete."'"; mysqli_query($Garydb, $del); } ?> <!doctype html> <html> <head> <title>Deleted</title> </head> </html>
  3. Is there an easy way to change dates in a column so that if the date falls on a Saturday or Sunday it changes to the closest business day?
  4. I have a table of prices by date and I am trying to select two rows, the 2nd row and a fixed row. It the below statement I am trying to get the date less than the current date but it is returning mixed results. How can I get just the row for .$Hist['BuyDateSubmit']. and the row with the date which is on the 2nd row from the top? $HistQ = "select * from TABLE where Date = '".$Hist['BuyDateSubmit']. "' AND (Date <'". $XXX . "' OR Date = '" . $Hist['BuyDateSubmit'] ."')";
  5. I have the following query used for a google line chart. The query works and does four different monthly counts for the past 12 months to current date. I need to modify it so it does the same exact thing but weekly for the past 6 month to current date. Week starts Sunday, ends Saturday. No brain food left after this one. Getting weak... * Any improvements to current query are also encouraged. Output Image attached. <?php if (isset($_REQUEST['floor']) || !isset($_REQUEST['specialty'])) { $contract_type_id = 3; $active_column = 'active'; } if (isset($_REQUEST['specialty'])) { $contract_type_id = 2; $active_column = 'active_specialty'; } $sql="SELECT C.month, sum(slab) as slab, sum(dried_in) as dried_in, sum(drywall) as drywall, sum(frame) as frame, C.year_month_number FROM ( (SELECT CASE MONTH (l.frame_date) WHEN 1 THEN CONCAT('Jan','-',Year (l.frame_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.frame_date)) WHEN 3 THEN CONCAT('Mar','-',Year (l.frame_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.frame_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.frame_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.frame_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.frame_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.frame_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.frame_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.frame_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.frame_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.frame_date)) ELSE 'Unknown' END as 'month', null as slab, null as drywall, COUNT(IF(l.frame_date is not null, 1, 0)) AS frame, null AS dried_in, CONCAT(Year (l.frame_date),LPAD(MONTH (l.frame_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and l.frame_date is not null and (frame_date <= CURDATE() and frame_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.frame_date) ORDER BY MONTH (l.frame_date) ASC) UNION ALL (SELECT CASE MONTH (l.drywall_date) WHEN 1 THEN CONCAT('Jan','-',Year (l.drywall_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.drywall_date)) WHEN 3 THEN CONCAT('Mar','-',Year (l.drywall_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.drywall_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.drywall_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.drywall_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.drywall_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.drywall_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.drywall_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.drywall_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.drywall_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.drywall_date)) ELSE 'Unknown' END as 'month', null as slab, COUNT(IF(l.drywall_date is not null, 1, 0)) AS drywall, null as frame, null AS dried_in, CONCAT(Year (l.drywall_date),LPAD(MONTH (l.drywall_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and l.drywall_date is not null and (drywall_date <= CURDATE() and drywall_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.drywall_date) ORDER BY MONTH (l.drywall_date) ASC) UNION ALL (SELECT CASE MONTH (l.slab_date) WHEN 1 THEN CONCAT('Jan','-',Year (l.slab_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.slab_date)) WHEN 3 THEN CONCAT('Mar','-',Year (l.slab_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.slab_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.slab_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.slab_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.slab_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.slab_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.slab_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.slab_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.slab_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.slab_date)) ELSE 'Unknown' END as 'month', COUNT(IF(l.slab_date is not null, 1, 0)) AS slab, null as drywall, null as frame, null AS dried_in, CONCAT(Year (l.slab_date),LPAD(MONTH (l.slab_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and l.slab_date is not null and (slab_date <= CURDATE() and slab_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.slab_date) ORDER BY MONTH (l.slab_date) ASC) UNION ALL (SELECT CASE MONTH (l.dried_in_date) WHEN 1 THEN CONCAT('Jan', '-', Year (l.dried_in_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.dried_in_date)) WHEN 3 THEN CONCAT('Mar', '-', Year (l.dried_in_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.dried_in_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.dried_in_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.dried_in_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.dried_in_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.dried_in_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.dried_in_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.dried_in_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.dried_in_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.dried_in_date)) ELSE 'Unknown' END as 'month', null AS slab, null as drywall, null as frame, Count(IF(l.dried_in_date is not null, 1 , 0)) AS dried_in, CONCAT(Year (l.dried_in_date), LPAD(MONTH (l.dried_in_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and dried_in_date is not null and (dried_in_date <= CURDATE() and dried_in_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.dried_in_date) ORDER BY MONTH (l.dried_in_date) asc) ) as C GROUP BY C.month ORDER BY C.year_month_number asc"; echo $sql; $stmt = $pdo->prepare($sql); $stmt->execute(); $result = $stmt->fetchAll(); $data[] = array( 'month', 'slab', 'dried_in', 'frame', 'drywall' ); foreach ($result as $row) { $data[] = array( $row['month'], (int) $row['slab'], (int) $row['dried_in'], (int) $row['frame'], (int) $row['drywall'] ); } $encoded_data= json_encode($data); ?> <!-- Load Google JSAPI --> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", { packages: ["corechart"] }); google.setOnLoadCallback(drawChart); // draw chart fucntion function drawChart() { /* var jsonData = $.ajax({ url: "./includes/chart_12month_comparison_data.php", dataType: "json", async: false }).responseText; var obj = jQuery.parseJSON(jsonData); */ var data = google.visualization.arrayToDataTable(<?php echo $encoded_data;?>); var currentYear = new Date(); var options = { //title: 'Demo Google LineChart : ' + (new Date(currentYear.setDate(currentYear.getDate() - 365))).yyyymmdd() + ' - ' + (new Date()).yyyymmdd() title: '12 Month Comparison ' + (new Date(currentYear.getFullYear()-1,currentYear.getMonth()+1)).yyyymmdd() + ' - ' + (new Date()).yyyymmdd(), //legend: 'none', hAxis: { minValue: 0, maxValue: 9 }, pointSize: 10, pointShape: 'square' }; var chart = new google.visualization.LineChart( document.getElementById('chart_div')); chart.draw(data, options); } // format date function Date.prototype.yyyymmdd = function() { var yyyy = this.getFullYear().toString(); var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based var dd = this.getDate().toString(); return yyyy + "/" + (mm[1]?mm:"0"+mm[0]) + "/" + (dd[1]?dd:"0"+dd[0]); // padding }; </script> <?php $floor = isset($_GET['floor']) || !isset($_GET['specialty']) ? "style=\"color:#FF0000\"" : ''; $specialty = isset($_GET['specialty']) ? "style=\"color:#FF0000\"" : ''; ?> FILTER: <a href="<?php echo $_SERVER['SCRIPT_NAME'];?>?p=<?php echo $_GET['p'];?>&floor" title="Flooring" <?php echo $floor;?>>Flooring</a> | <a href="<?php echo $_SERVER['SCRIPT_NAME'];?>?p=<?php echo $_GET['p'];?>&specialty" title="Specialty" <?php echo $specialty;?>>Specialty</a><br><br> <div id="chart_div" style="width: 900px; height: 500px;"> </div>
  6. Hello, I have a question regarding SQL. Please refer my attachment below: This view of table give me correct of the output. Which give me 36 of results. Please refer attachment below: But, when i try to put additional table which i need to indicated whether the form is completed or draft, it's because i do not want to show "draft" form in the table. Have a look on the table below: After i added this table into my view, the output is repeated 2 times and give me 72 of results.
  7. 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
  8. 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?
  9. 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.
  10. 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>
  11. 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.
  12. 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(); }
  13. 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.
  14. 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)
  15. 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.
  16. 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;
  17. 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', '');
  18. 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
  19. 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>
  20. 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
  21. 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'";
  22. 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%')
  23. <?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
  24. 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(); } ?>
×
×
  • Create New...

Important Information

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