Jump to content

Eiolon

Members
  • Posts

    358
  • Joined

  • Last visited

Everything posted by Eiolon

  1. I am working on a calendar but am having difficulty finding a way to loop the events through the concatenation. Having it loop on the outside of the string brings only the first event for the day, not all of them. If I loop outside of the string of $week outputs all the events but it creates a new "day" square for each event. Thanks for your advice. for ($day = 1; $day <= $count_days; $day++, $str++) { $date = $year_month . '-' . $day; $sth_events = $dbh_mysql->prepare(" SELECT id, name, date_time FROM events WHERE date_time LIKE '$date%' "); $sth_events->execute(); while ($row_events = $sth_events->fetch(PDO::FETCH_ASSOC)) { $name = $row_events['name']; } if ($today == $date) { $week .= '<td>' . '<div class="today">' . $day . '</div>' . $name; } else { $week .= '<td>' . '<div class="day">' . $day . '</div>' . $name; } $week .= '</td>';
  2. Thanks for all your advice. I have done all you have suggested. The only error that returns is the Notice: Undefined variable: $LastActivityDate No connection errors reported and the company's database I am connecting to does see the server connect without a problem.
  3. I've been connecting to a database for a number of years now. The MSSQL server was updated the other day and it can no longer pull the data down. I connect with PHP PDO ODBC driver. The connection to the server is good, but nothing is returned. I can throw the query into my SQL client and bring up the data without a problem. Any ideas on what I can try? Here is a sample: <?php $HOSTNAME = '1.1.1.1'; $DATABASE = 'db'; $USERNAME = 'user'; $PASSWORD = 'pass'; try { $dbh = new PDO("odbc:Driver={SQL Server};Server=$HOSTNAME;dbname=$DATABASE", "$USERNAME", "$PASSWORD"); array (PDO::ATTR_PERSISTENT => true); } catch (PDOException $e) { echo $e->getMessage(); } $Barcode = '37782555863'; $sth = $dbh->prepare(" SELECT LastActivityDate FROM Customers WHERE Barcode = :Barcode "); $sth->bindParam(':Barcode', $Barcode); $sth->execute(); while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { $LastActivityDate = $row['LastActivityDate']; } ?> <?php echo $LastActivityDate; ?>
  4. In your SQL, you are asking it to select data based on the criteria of a username, password AND the userlevel. Your fields being submitted are for username and password only. You are not submitting a userlevel field (nor should you be). Secondly, you are saying that $count is your $userlevel is. Basically, you are saying if 1 row is returned, then userlevel is equal to 1. It will never be 2 because you should never have two of the same username/password combinations in your database. So what you really need to do is modify your SQL to select the userlevel based on the submitted fields of the username and password. $sql="SELECT userlevel FROM daftarPenyelia WHERE user='$username' AND pass='$password'"; Then you need to do your error checking. If $count is = to 1, then there was a match for the username and password. Once that has been done, determine if it was a 1 or 2 for the admin or staff to direct to the appropriate page.
  5. The table is not inside the div. The div is above it. They are completely separate elements. Also, it is the table that is showing the correct 900px whereas the div is showing 924px.
  6. Here is my CSS: div.header { width:900px; background-color:#363E44; padding:12px; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#FFFFFF; font-weight:bold; } table.data { width:900px; padding:12px; border-collapse:collapse; } table.data th { background-color:#EEEEEE; padding:12px; font-family:Arial, Helvetica, sans-serif; font-size:11px; font-weight:bold; color:#000000; } table.data td { background-color:#FFFFFF; padding:12px; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#000000 }
  7. I have a DIV that is 900px wide and padding at 12px. I have a table that goes below it (for data) that is set for 900px wide and padding at 12px. However, the DIV is actually 24 pixels wider than the table. Shouldn't they be the same width?
  8. Nevermind, I got it working. Stupid \'s
  9. I am not sure if it is my PHP or Javascript that is causing this to not work. The first select gets populated successfully but the second doesn't get populated when something is selected from the first: <?php require_once('../includes/support.php'); require_once('../includes/functions.php'); @$cat=$_GET['cat']; if(strlen($cat) > 0 and !is_numeric($cat)) { echo "Error"; exit; } $query_categories = mysql_query("SELECT DISTINCT id, category FROM categories ORDER BY category ASC"); if(isset($cat) and strlen($cat) > 0){ $query_equipment = mysql_query("SELECT DISTINCT name, description FROM equipment WHERE category_id=$cat"); } else { $query_equipment = mysql_query("SELECT DISTINCT name, description FROM equipment WHERE category_id=0"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Support</title> <link href="../includes/style.css" rel="stylesheet" type="text/css"> <SCRIPT language=JavaScript> function reload(form) { var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='index2.php?cat=' + val ; } </script> </head> <body> <?php include_once('../includes/menu.php'); ?> <div id="headers"> <img src="../images/support.png" class="icon" alt="Support" /><h1>Support</h1> </div> <div id="content"> <form method="post" name="add" action=""> <label>Category:</label> <select name="cat" id="cat" onchange=\"reload(this.form)\"> <option value=''>SELECT</option> <?php while($category = mysql_fetch_array($query_categories)) { if($category['id']==@$cat) { echo "<option selected value='$category[id]'>$category[category]</option>"."<br>"; } else { echo "<option value='$category[id]'>$category[category]</option>"; } } ?> </select> <label>Equipment:</label> <select name="equipment_id" id="equipment_id"> <option value=''>SELECT</option> <?php while($equipment = mysql_fetch_array($query_equipment)) { print '<option value="' . $equipment['name'] . '</option>';}?> </select> <input type="submit" value="Submit"> </form> </div> </body> </html> Thanks for your assistance!
  10. I want to make it show that a card has expired if it's after the expiration date. Dates are stored in DATETIME format in the database so this is what I have done: <?php $today = date("Y-m-d"); ?> Status: <?php if ($ExpirationDate < $Today) { echo 'The card has expired.'; } else { echo 'Active.'; } ?> It seems that my card is never expired even though I set the date in the database to be: 2010-02-26 00:00:00 Thanks!
×
×
  • 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.