PHP - Problem With An If Statement?
Well I guess I'll jump right into the code..
The function: function isIpaddr ($ipaddr) { if (ereg("^([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})$", $ipaddr, $digit)) { if (($digit[1] <= 255) && ($digit[2] <= 255) && ($digit[3] <= 255) && ($digit[4] <= 255)) { return TRUE; } } return FALSE; } The loop and IF statement: if($_POST['submit_multiple']) { $SubmittedIPs = split("[\n|\r|,|-]", $_POST['IPAddresses']); foreach($SubmittedIPs as $IP) { trim($IP); if(isIpaddr($IP)) { echo $IP." = ".gethostbyaddr($IP)."<br />"; } else { echo "Invalid IP Address<br />"; } } } There's my relevant code.. Now the only problem so far is that I am getting this: Quote 12.34.56.78 = 12-34-56-78.test.hostname.com Invalid IP Address 12.34.56.78 = 12-34-56-78.test.hostname.com Invalid IP Address 12.34.56.78 = 12-34-56-78.test.hostname.com (The IPs and Hostnames are obviously fake..) The problem is that they are valid IP addresses and I've done a few checks to see what's wrong. I've checked the array and it is working fine by splitting up a textbox into an array of IPs and the IPs are fine inside the array. I then tested the script by echoing the output of just the function with each IP, I got all "1"s (TRUE). I just can't figure out why it's displaying both parts of the if statement.. Thanks for any help! Similar TutorialsHi im new to this site so i hope this is in the right place,my table goes green when i try to say less than 14 but when i use greater the code looks ok ,its works by itself but im using five similar else if statements for different ages(teacher doesnt want functions used yet) can anyone please help ??? Code: [Select] else if($myAge >9 || $myage <14) { echo"<table width='500' border='0' cellpadding='0' cellspacing='1' bgcolor='#CCCCCC'>"; echo"<tr>"; echo"<td>"; echo"<table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#FFFFFF'>"; echo"<tr>"; echo"<td colspan='3'><h3><strong>Sports Catagory</h3></strong></td>"; echo"</tr>"; echo"<tr>"; echo"<td><hr></td>"; echo"</tr>"; echo"<tr>"; echo"<td> ".$username." a-zA-z</td>"; echo"</tr>"; echo"<tr>"; echo"<td> ".$password." 0-9</td>"; echo"</tr>"; echo"<tr>"; echo"<td>Invalid data entered, please re-enter the data correctly</td>"; echo"</tr>"; echo"<tr>"; echo"</tr>"; echo "<tr>"; echo "<td><a href = '".$self."'> Back to Form </a></td>"; echo "</tr>"; echo "</table>"; echo"</td>"; echo"</tr>"; echo"</table>"; } So basically I've been experimenting with setting cookies and sessions. The code in my header file will display a login if there is no $_SESSION['username']. However, the else statement verifies that there is, and echo's "hello." My problem lies in the else statement, when the login form disappears, but nothing in the else statement appears. Here's the code, I feel like I am missing something obvious. Code: [Select] <?php if (!isset($_SESSION['username'])){ echo "<li><a href='register.php'>Register</a></li>"; echo "</ul>"; echo " <table> <tr> <form name='login' method='post' action='login.php'> <tr><td>Username</td> <td><input type='text' name='username'></td></tr> <tr><td>Password</td> <td><input type='password' name='password'></td></tr> <tr><td><input type='submit' name='submit' value='Login'></td></tr> <tr><td><input type='checkbox' name='rememberme' value='remember'> Remember</td></tr> </form> </table> "; }else{ echo "hello"; } ?> Thanks in advance My code is as follows <?php // Include the Sessions options require_once('inc/session_admin.inc.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Change Record form</title> <style type="text/css"> td {font-family: tahoma, arial, verdana; font-size: 10pt } </style> </head> <body bgcolor="#64b1ff"> <div align="center"> <?php echo '<p>Hello <b>' .($_SESSION['username']) .'</b> <a href="logging_out.php">Logout</a></p>'; $Username=$_POST['Username']; if ($Username = $Username) { // Include connecting to the database require_once('inc/connect_to_users_db.inc.php'); $query=" SELECT * FROM userinfo WHERE Username='$Username'"; $result=mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $FirstName=mysql_result($result,$i,"FirstName"); $LastName=mysql_result($result,$i,"LastName"); $Address1=mysql_result($result,$i,"Address1"); $Address2=mysql_result($result,$i,"Address2"); $Address2=mysql_result($result,$i,"Address2"); $Address3=mysql_result($result,$i,"Address3"); $Gender=mysql_result($result,$i,"Gender"); $Country=mysql_result($result,$i,"Country"); $MobileNumber=mysql_result($result,$i,"MobileNumber"); $EmailAddress=mysql_result($result,$i,"EmailAddress"); ?> <table width="300" cellpadding="5" cellspacing="0" border="1"> <tr align="center" valign="top"> <td align="center" colspan="1" rowspan="1" bgcolor="#64b1ff"> <h3>Edit and Submit</h3> <form method="post" action="update_a_user_script.php"> <input type="hidden" name="update_a_user_script" value="<?php echo "$Username" ?>" /> <table cellpadding="0" cellspacing="0" border="0"> <tr align="center" valign="top"> <td>Username:</td> <td><input type="text" name="Username" readonly="readonly" value="<?php echo "$Username" ?>" /></td> </tr> <tr align="center" valign="top"> <td>First Name:</td> <td><input type="text" name="FirstName" value="<?php echo "$FirstName" ?>" /></td> </tr> <tr align="center" valign="top"> <td>Last Name:</td> <td><input type="text" name="LastName" value="<?php echo "$LastName" ?>" /></td> </tr> <tr align="center" valign="top"> <td>Address:</td> <td><input type="text" name="Address1" value="<?php echo "$Address1" ?>" /></td> </tr> <tr align="center" valign="top"> <td> </td> <td><input type="text" name="Address2" value="<?php echo "$Address2" ?>" /></td> </tr> <tr align="center" valign="top"> <td> </td> <td><input type="text" name="Address3" value="<?php echo "$Address3" ?>" /></td> </tr> <tr align="center" valign="top"> <td>Gender:</td> <td><input type="text" name="Gender" value="<?php echo "$Gender" ?>" /></td> </tr> <tr align="center" valign="top"> <td>Country:</td> <td><input type="text" name="Country" value="<?php echo "$Country" ?>" /></td> </tr> <tr align="center" valign="top"> <td>MobileNumber:</td> <td><input type="text" name="MobileNumber" value="<?php echo "$MobileNumber" ?>" /></td> </tr> <tr align="center" valign="top"> <td>Email Address:</td> <td><input type="text" name="EmailAddress" value="<?php echo "$EmailAddress" ?>" /></td> </tr> </table> <input type="submit" value="Update" /> </form> <form method="post" action="update_a_user_form.php"> <input type="submit" value="Update a Different Record" /> </form> <form method="post" action="display_users.php"> <input type="submit" value="List all users" /> </form> <form method="post" action="index.php"> <input type="submit" value="Administrator Interface" /> </form> </td></tr></table> <?php ++$i; } ?> <?php } else { echo 'Username not found!. Please try again'; ?> <table width="300" cellpadding="5" cellspacing="0" border="2"> <tr align="center" valign="top"> <td align="left" colspan="1" rowspan="1" bgcolor="#64b1ff"> <h3>Insert Username</h3> <form method="post" action="update_a_user_form2.php"> Enter Username: <input type="text" name="Username" size="30" /><br /> <br /> <input type="submit" value="Submit" /><input type="reset" /> </form> <form method="post" action="index.php"> <input type="submit" value="Administrator Interface" /> </form> </td> </tr> </table> <?php } ?> </div> </body> </html> It will display what it's meant to display if I have a username that is in the database, however if the username doesn't exist in the database, it's meant to say "Username not found!. Please try again" and show the search box again. However if I put in a Username that doesn't exist. I get a blank page (well at the top of the page the page I do get Hello Howlin1 Logout) What am I doing wrong? I am creating a class alumni web and ask a question tha requires selecting one of 3 radio buttons. If the user selects the 3rd button, I want to display an additional field. Here is the lines of code: <label>Are you or your spouse a Taft Class of 1965 alumni?</label> <input type="radio" id="alumni" value=1 checked><label>yes</label> <input type="radio" id="alumni" value=2><label>no</label> <br> <label>Are you a graduate of Taft Union High School?</label> <input type="radio" id="alumni" value=3><label>yes</label> Error ---> <?php // If alumni is equal to 3 display the input field If ($ans == 3);{ Echo "<input type='int' id='gradClass' size='4' maxlenght='4' placeholder='1977'>" } ?> <br> <hr> <br> <span class="subheader">PRIVACY</span> <br> And I didn't forget a ' this time. Could someone please assist. Thanks in advance. I have a series of PHP files that are referenced in index.php like this: <?php include("credentials.inc"); $cxn = mysqli_connect($host, $user, $password, $dbname) or die ("Connection failed."); include('header.php'); include('menu.php'); include('contact.php'); include('home.php'); ?> One of my files, menu.php, brings up a JavaScript menu that was coded in Dreamweaver (yes, I cheated). However, it seems to get to the first "for" statement and stops. I can't work out what I've done wrong. <?php $h1 = mysqli_query($cxn, "SELECT areaID, area FROM area ORDER BY areaID"); echo("<ul id='MenuBar1' class='MenuBarHorizontal'>"); echo("<li><a href='index.php'>HOME</a></li>"); echo("<li><a href='#' class='MenuBarItemSubmenu'>PRODUCTS</a><ul>"); for ($a=0;$a<=count($h1);$a++) { echo("<li><a href='#' class='MenuBarItemSubmenu'>".$h1[$a]['area']."</a><ul>"); $h2 = mysqli_query($cxn, "SELECT catID, category, areaID, link FROM category WHERE areaID = '".$h1[$a]['areaID']."' ORDER BY catID"); for ($b=0;$b<count($h2);$b++) { echo("<li><a href='".$h2[$b]['link']."'>".$h2[$b]['category']."</a></li>"); } echo("</ul></li>"); } echo("</ul></li>"); echo("<li><a href='services.php'>SERVICES</a></li>"); echo("<li><a href='aboutus.php'>ABOUT US</a></li>"); echo("<li><a href='contact.php'>CONTACT</a></li></ul>"); ?> Hopefully someone has an idea of where the problem is. Thanks so much in advance! I have the following code which gets staff working on a selected day and their start and finish times. The code then lists out the day for every 15min of time for each staff member. During the loop of each staff member I then check an appointment table to see if a user has any appointments, and lists the booked time slots, if no appointments lists user as available for all the time slots. My problem is when a user has appointments it only shows the booked times and not the available times. I know the problem lies here else if ($inc<$resSTART && $inc>$resEND) { and the complete code that is from is here // convet to US format $input="$month/$day/$year"; // readable date $readDATE="$day/$month/$year"; // convert for mysql date $sqlDATE="$year-$month-$day"; // get day of the week $weekday=date(l, strtotime($input)); echo $weekday."<br/>"; // get working staff from staff table $staffSQL=mysql_query("SELECT * FROM staff WHERE ".$weekday." != 'off' AND onLEAVE='no' AND ACTIVE='yes' ORDER BY staffID ASC"); // return results putenv("TZ=Australia/Adelaide"); while ($staff=mysql_fetch_array($staffSQL)) { $name=$staff['staffNAME']; $avail=$staff[$weekday]; $staffID=$staff['staffID']; list($first, $last)=explode(" ", $name); list($in, $out)=explode("-", $avail); $firstTIME="$sqlDATE $in:00"; $lastTIME="$sqlDATE $out:00"; echo "$first is available between $avail on $weekday<br/>"; $in2=strtotime($firstTIME); $out2=strtotime($lastTIME); $stop=$out2-900; echo $in2." - time start - $firstTIME<br/>"; echo $out2." - time finish - $lastTIME<br/>"; for ($inc=$in2;$inc<=$stop;$inc+=900) { $existSQL=mysql_query("SELECT * FROM appointment WHERE date='$sqlDATE' AND staffID='$staffID'"); if (mysql_num_rows($existSQL)>=1) { while ($appointV=mysql_fetch_array($existSQL)) { $resSTART=$appointV['dateTIME']; $length=$appointV['totalTIME']; $resEND=$resSTART+($length*60); if ($inc>=$resSTART && $inc<=$resEND) { echo "Appointment time is ".date("g.i a", $inc)." <font color='red'><< $first BOOKED</font><br/>"; } else if ($inc<$resSTART && $inc>$resEND) { echo "Appointment time is ".date("g.i a", $inc)." <font color='green'><< $first AVAILABLE</font><br/>"; } } } if (mysql_num_rows($existSQL)==0) { echo "Appointment time is ".date("g.i a", $inc)." <font color='green'><< $first AVAILABLE</font><br/>"; } } } any ideas how to restructure that if statement to work properly would be very much appreciated Hi everybody i am beginnet with working with sql in php..so i confused.....i made one scripte and i am making the secound and now i am facing a problem....i hope u could help!! i have a dat=abse of my chatroom....this is the code i typed...please have a look at it! Code: [Select] $usern=$_SESSION['etchat_'.$this->_prefix.'username']; $con1 = mysql_connect("localhost","manosir_main","********"); if (!$con1) { die('Could not connect: ' . mysql_error()); } mysql_select_db("manosir_manoshos_main", $con1); $users= mysql_query(" select etchat_user_online_user_sex from db1_etchat_useronline where etchat_user_online_user_name = $usern "); in my database, i ahve a table called db1_etchat_useronline that keeps record of online users in chatroom. as u usee i qant to to get the user sex ( etchat_user_online_user_sex) of th current user!!! as u see i conected to database correctly but now i dont know how to echo the $users . before this i echo my sql results with mysql_fetch_array ..but now i cant.......i got nothing!!!! can someone help me!!!!! How do I fix this For Each statement when used with preg match? //Cat_ID & Category Name preg_match_all('%<a[^href=]*href=\"\/cats\.asp\?cat_id=(.*?)\" title="(.*?)">%',$data,$matches1,PREG_SET_ORDER); // works fine preg_match_all('%/60/(.*?).jpg"%s',$data,$matches2,PREG_SET_ORDER); // works fine preg_match_all('%h3><p>(.*?)<\/p>%s',$data,$matches3,PREG_SET_ORDER); // works fine foreach ($matches1 as $val) { //need help here $subcat_id=$val[0][1]; $subcat=$val[0][2]; $cat_image=$val[1][1]; $cat_desc=$val[2][1]; Thanks for your help!!! This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=350701.0 OK, I think I have confused this code and it is not calculating correctly. $ckifdue = mysql_query("SELECT * FROM accounting WHERE ClientID = '$clientid'") or die(mysql_error()); while($ckdue =mysql_fetch_array($ckifdue)){ if($ckdue['AmountDue'] == "0"){ $_SESSION['MONEYOWED'] = "0.00"; } else { $_SESSION['MONEYOWED'] = $_SESSION['MONEYOWED'] + $ckdue['AmountDue']; } if($ckdue['Amount1RS'] == "Balance Due"){ $totcol = $ckdue['TotalCollected']; echo " total collected:" . $totcol; $monpaid = $_SESSION['MONEYPAID']; echo "money paid in:" . $monpaid; $_SESSION['MONEYPAID'] = $totcol + $monpaid; echo "session money paid:" . $_SESSION['MONEYPAID']; } } $moneypaid = $_SESSION['MONEYPAID']; $moneyowed = $_SESSION['MONEYOWED']; echo "money paid:" . $moneypaid; echo " money owed:" . $moneyowed; $moneyowed = $moneyowed - $moneypaid; unset($_SESSION['MONEYOWED']); unset($_SESSION['MONEYPAID']); The echos look like: total collected:100.00money paid in:200session money paid:300 total collected:100.00money paid in:300session money paid:400money paid:400 money owed:0.00 There should be $100 due, $200 paid, so a balance of -100. There is 2 balance due reciepts, this is just not calclating right in the sessions. I have got a set of data for a country for each week of the year, but want to display the data a quarter at a time, using a form which posts a value into LIMIT, which was OK for the 1st quarter, but for subsequent quarters I needed to use LIMIT in the form LIMIT start, rows.
I found by experiment that this had to be the last statement in the query.
when I added the start I got an error:
Parse error: syntax error, unexpected ',' in /homepages/43/d344817611/htdocs/Admin/Visitdata.php on line 10
Here is the SQL part of my code:
$Visit_data="SELECT WeekNo.WNo, WeekNo.WCom, Countries.Country, ctryvisits.CVisits FROM ctryvisits LEFT JOIN Countries ON ctryvisits.country=Countries.CID LEFT JOIN WeekNo ON ctryvisits.WNo=WeekNo.WNo WHERE Countries.Country = '".$_POST["Country"]."' ORDER BY ctryvisits.WNo LIMIT '".$_POST["QUARTER"]."'" - 13, '".$_POST["QUARTER"]."'";Is this the best way of doing what I require or is there an easier way of achieving what I want? I am trying to check to see if a file size is acceptable before an upload but cant seem to get the right result no matter what i do. if i have my if statement below coded like this Code: [Select] if($_FILES["upload"]["size"] < 1024000){ echo'entered if statement<br />'; } else{ echo'entered else statement<br />'; } Then i always am entereing the if statememnt but if i have my if statement like this Code: [Select] if($_FILES["upload"]["size"] > 1024000){ echo'entered if statement<br />'; } else{ echo'entered else statement<br />'; } then i always seem to enter the else staement. I have tried with a VIREITY of differnt size files some from like 2kb to 10mb... i believe somewhere near the > or < is my problem but i dont seem to see it This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=332328.0 Hi... I have query in highlighting null data using this code: Code: [Select] <?php include 'config.php'; $currentEmpID = $_SESSION['empID']; if(!isset($_POST['Regsubmit_'])){ $DATE1 = $_GET['Regfirstinput']; $DATE2 = $_GET['Regsecondinput']; $sql = "SELECT DISTINCT IF(ISNULL(a.LOG_IN), 'rdc', '') AS LOGIN_CLASS, IF(ISNULL(a.LOG_OUT), 'rdc', '') AS LOGOUT_CLASS, a.EMP_ID, CONCAT(LASTNAME, ', ' , FIRSTNAME) AS FULLNAME, a.LOG_IN, a.LOG_OUT FROM $ATTENDANCE.attendance_build AS a JOIN $ADODB_DB.employment em ON (a.EMP_ID = em.EMP_NO AND em.STATUS IN ('Reg Operatives', 'Reg Staff')) WHERE LOG_IN BETWEEN '$DATE1' AND '$DATE2' OR ISNULL(LOG_IN) OR ISNULL(LOG_OUT)"; $DTR = $conn3->GetAll($sql); $smarty->assign('attendance', $DTR); } $smarty->display('header_att.tpl'); $smarty->display('RegAttendance.tpl'); $smarty->display('footer.tpl'); ?> and here is the tpl code: Code: [Select] {section name=att loop=$attendance} <tr> <td colspan="2">{$attendance[att].EMP_ID}</td> <td colspan="2">{$attendance[att].FULLNAME}</td> <td colspan="2" class="{$attendance[att].LOGIN_CLASS}">{$attendance[att].LOG_IN|date_format:"%d-%m-%Y %I:%M %p"}</td> <td colspan="2" class="{$attendance[att].LOGOUT_CLASS}">{$attendance[att].LOG_OUT|date_format:"%d-%m-%Y %I:%M %p"}</td> </tr> {sectionelse} <tr><td colspan="1">No DATA</td></tr> {/section} this code highlight the null value of login or logout or both. this is the css: Code: [Select] .rdc {background-color:#ff0000;} Now, I need to revised my query statement, because i have separate code for adding attendance if the employee has no attendance or no login or no logout. I just want to happen is if the employee is already add his attendance in NRS table or should I said if the LOG_IN in attendance table is equal to TIME_IN in NRS table the data will have a color yellow. For Example: I have this data in attendance table: EMP_ID = 012012 LOG_IN = NULL LOG_OUT = 2011-12-12 13:35:00 I will his attendance in NRS table to have his attendance: EMP_NO = 012012 TIME_IN = 2011-12-12 05:35:00 TIME_OUT = 2011-12-12 13:35:00 In my above query the LOG_IN has a background color of RED. I want to happen is if I add his attendance in NRS the EMP_NO, LOG_IN, LOGOUT will have a color to notice that it is already have in NRS. Because theirs a scenario that the employee has no login or no logout or both. Feel free to ask me if my explanation is not clear to you. Thank you in advance I'm having issues with the following: Code: [Select] <?php session_start(); $_SESSION['username']=$_POST['username']; $_SESSION['password']=$_POST['password']; if($_SESSION['username']=="username" && $_SESSION['password']=="password"){ if($_GET['product']=="add"){ $content.=' <p><label>Product Name:</label> <input type="text" name="product_name" size="30" /> <label>Product Price:</label> <input type="text" name="product_price" size="5" /> </p> <p><label>Product Category:</label> <input type="text" name="product_category" size="30" /></p> <p><label>Product Link:</label> <input type="text" name="product_link" size="30" /></p> <p><label>Product Image:</label> <input type="text" name="product_image" size="30" /></p> <p><label>Product Tag:</label> <input type="text" name="product_tag" size="30" /></p> <p><label>Product Keywords:</label> <input type="text" name="keyword" size="30" /></p> <p><label>Product Features:</label><br /> <textarea name="product_features" rows="10" cols="60"></textarea> </p> <p><label>Product Pros:</label><br /> <textarea name="product_pros" rows="5" cols="30"></textarea> </p> <p><label>Product Cons:</label><br /> <textarea name="product_cons" rows="5" cols="30"></textarea> </p> <p><label>Product Description:</label><br /> <textarea name="product_description" rows="10" cols="60"></textarea> </p> <p><label>Product Notes:</label><br /> <textarea name="product_notes" rows="5" cols="30"></textarea> </p> '; $logout='<div><a href="./acp_admincp.php?log-out">Log-Out</a></div>'; } elseif($_GET['product']=="view"){ } else{ $content.=' <a href="./admincp.php?product=add">Add New Product</a> <br /> <a href="./admincp.php?product=view">View Products</a> '; } } elseif(isset($_GET['log-out'])){ session_start(); session_unset(); session_destroy(); header("Location: ./admincp.php"); } else{ $content=' <form action="./admincp.php" method="post"> <p><label>Username:</label> <input type="text" name="username" size="30" />'; $content.='</p> <p><label>Password:</label> <input type="password" name="password" /></p>'; $content.='<p><input type="submit" value="Submit" name="Submit" /></p> </form>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <base href="http://ghosthuntersportal.com/" /> <title>Ghost Hunter's Portal - Admin Control Panel</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="verify-v1" content="" /> <meta name="keywords" content="ghost, hunters, hunter, ghosts, spirit, spirits, paranormal, investigation, investigator, investigators, k2, emf, meter, kii" /> <meta name="description" content="Ghost Hunters Potal. Parnormal research equipment store." /> <meta name="author" content="Andrew McCarrick" /> <meta name="robots" content="index, follow" <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <img src="./logo.png" alt="Ghost Hunter's Portal Admin Control Panel" /> <br /> <div style="color: #AA44AA; font-size: 26px; margin-top: -30px; margin-left: 125px;">Admin Control Panel</div> <?php echo $logout; echo $content; ?> </body> </html> I can log-in, and get to the page with the two links on it. However, once I click one of the links it falls back to the log-in page, and it ends up being a never ending loop. It's doing this: Log-In --> Page with links ---> Log-In page again Should be doing this: Log-In --> Page with links --> Add Product page or View Products page I can never get into the the actual sub page. Just to be clear, the address bar actually shows product=add or product=view, but it still shows the log-in page. Hello Everyone, I have to change the if statements to a switch statement, in this game. Can anyone help? Thanks. var checkKeyPressed = function (e) { // Press key A or key D to make dog run to the left or right // The running speed is specified by the step variable, 10 by default. // If you replace 10 with a larger integer, the dog will run faster. //press A, dog runs left if (e.keyCode == "65") { if (prex[0] > 5) { prex[0] = prex[0] - step; } } //press D, dog runs right if (e.keyCode == "68") { if (prex[0] < right) { prex[0] = prex[0] + step; } } }; So I am trying to tweak a few things on a page and I am stuck on this one. I want the ###### to also be the data in $row['id'] Code: [Select] <?php if (file_exists('/var/www/html/images/races/######/images/' . $row['id'] . $dthumb)): ?> so if $row['id'] = 124 it would be looking for /var/www/html/images/races/124/images/124.jpg')) I know it has to be that I am stumped on the correct question to ask or search for. Any help is appreciated. Thanks! I have a table on a page that displays info from a database and everything is working fine but I want it so if the user entered data from another page to a certain field then the row on my data display table will turn red. Right now I have a If statement in every row of my table. Is it possible to have two if statements in a row? Here is my page code with the table. <? include "include/session.php"; include "include/z_db.php"; ?> <? require "bottom.php"; ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> </head> <!-- <body bgcolor="#339999"> --> <body bgcolor="white"> <img src="logo.jpg" width="197" height="193" align="right"><br /><br /><br /><br /><br /> <br /><br /><br /><br /><br /> <FORM> <INPUT TYPE="BUTTON" VALUE="New Tour" ONCLICK="window.location.href='http://www.integranite.net/EAToursDemo/Input.php'"> </FORM> <?php $result = mysql_query("SELECT * FROM Project"); ?> <div style="overflow:auto; height:30px; width:1650px"> <?php echo "<table border='1'> <tr> <th width='200'>School</th> <th width='200'>Teacher</th> <th>First Contact start date</th> <th>Development Start</th> <th>Development End</th> <th>Pricing Start</th> <th>Pricing End</th> <th>Marketing Start date</th> <th>Price Based On</th> <th>Trip Assigned To</th> <th>Trip Made</th> <th width='104'>Notes</th> </tr>"; echo "</table>"; echo "</div>"; ?> <div style="overflow:auto; height:400px; width:1650px"> <?php while($row = mysql_fetch_array($result)) { $checkbox = ''; if ($row['TripMade'] == 1) $checkbox = ' checked'; ?> <!--<div style="overflow:auto; height:40px; width:155px">--!> <table cellpadding="0" cellspacing="0" style="width:50px;"> <?php echo "<table border='1'>"; echo "<tr>"; echo "<td width='200'>" .$row['School'] . "</td>"; echo "<td width='200'>" .$row['Teacher'] . "</td>"; if(!strcmp($row['dtFirstContactSt']&& $row['dtMarketingSt'] , '0000-00-00' && '0000-00-00')) { echo "<td width='156'>" . "  </td>"; } else { echo "<td bgcolor=FF0000 width='156'>" .$row['dtFirstContactSt']. "</td>"; } if(!strcmp($row['dtDevelopmentSt'], '0000-00-00')) { echo "<td width='126'>" . "  </td>"; } else { echo "<td width='126'>" .$row['dtDevelopmentSt']. "</td>"; } if(!strcmp($row['dtDevelopmentEnd'], '0000-00-00')) { echo "<td width='119'>" . "  </td>"; } else { echo "<td width='119'>" .$row['dtDevelopmentEnd']. "</td>"; }; if(!strcmp($row['dtPricingSt'], '0000-00-00')) { echo "<td width='83'>" . "  </td>"; } else { echo "<td width='83'>" .$row['dtPricingSt']. "</td>"; } if(!strcmp($row['dtPricingEnd'], '0000-00-00')) { echo "<td width='76'>" . "  </td>"; } else { echo "<td width='76'>" .$row['dtPricingEnd']. "</td>"; } if(!strcmp($row['dtMarketingSt'], '0000-00-00')) { echo "<td width='142'>" . "  </td>"; } else { echo "<td width='142'>" .$row['dtMarketingSt']. "</td>"; } echo "<td width='104'>" .$row['PriceBasedOn']. "</td>"; echo "<td width='115'>" .$row['TripAssignedTo']. "</td>"; ?> <td width="72"><input type="checkbox" name="TripMade" value="Yes" <?= $checkbox ?>></td> <td><textarea name="Notes" rows="1" cols="10"><?php echo $row["Notes"]?></textarea> </td> <?php echo "<td>" . "<a href=Edit_Form.php?UniqueIdentifier=$row[UniqueIdentifier]> Edit </a></td>"; echo "</tr>"; } echo "</table>"; echo "</div>"; mysql_close($con); ?> <br /> <meta name="GENERATOR" content="Arachnophilia 4.0"> <meta name="FORMATTER" content="Arachnophilia 4.0"> </head> <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"> <center> </body> </html> The first IF statement is what i am trying to do but just dont know how to code it. I know its kind hard to understand but any help is appreciated. I think I know the answer to this, but it would make things easier if I could do what I think I can't. Can I use LIKE and NOT LIKE in an if statement? Doesn't seem to be working for me. Code: [Select] <?php //$rightlic is a twelve character string ending either P00, P01, V00, or V01. I want to do different things based on V or P if ($rightlic not like '%V00' AND $rightlic not like '%V01'){ echo "<br>purchaser ran demo as public but is now trying to purchase a private account. Stop the process."; exit; } ?> Can I do something like this or do I have to separate the string and look for the last characters that way? Thanks in advance for any help. |