PHP - Dropdown Has Value Prior To If Statement, Another Value Within If
I have 2 dropdowns, both default to 'select'. The query seemed to work ok before I added validation that both dropdowns need to have a value other than 'select' before the query will be run (i.e., "please select a value for both dropdowns").
For one of the dropdowns, the value just prior to that evaluation has a value/year selected, but within that IF evaluation it echos as 'select'. --right before IF--year:2010 post year:2010 year end:2011 owner:C WAGNER ------while in IF--year:select post year:2010 year end:2011 owner:C WAGNER the code is up at brewhas.org/team_history.php any ideas as to why that value seems to change within the IF? Code: [Select] <?php $url_owner = $_GET['owner']; $url_year = $_GET['year']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Brewhas Keeper League Fantasy Baseball - Team Transaction History</title> <link rel="stylesheet" type="text/css" href="style/bklstyle.css" /> <link rel="stylesheet" type="text/css" href="style/mm_travel2.css" /> <link rel="shortcut icon" href="http://www.brewhas.org/images/favicon.ico"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr bgcolor="#003300"> <td rowspan="2" nowrap="nowrap" bgcolor="#003300"> </td> <td width="59" rowspan="2" nowrap="nowrap" bgcolor="#003300"><img src="http://www.brewhas.org/images/BKL.jpg" alt="BKLLogo" width="59" height="66"/></td> <td width="608" height="49" align="center" valign="bottom" nowrap="nowrap" bgcolor="#003300" id="logo"><span class="style1">BREWHAS KEEPER LEAGUE </span></td> <td width="415" align="center" valign="bottom" nowrap="nowrap" bgcolor="#003300" id="logo"> </td> <td width="5" rowspan="2" bgcolor="#003300"> </td> </tr> <tr bgcolor="#003300"> <td height="24" align="center" valign="top" bgcolor="#003300" id="tagline"><span class="style2">fantasy baseball</span></td> <td height="24" align="center" valign="top" bgcolor="#003300" id="tagline"> </td> </tr> <tr> <td colspan="6" bgcolor="#003300"><img src="images/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td> </tr> <tr bgcolor="#CCC999"> <td height="15" colspan="5" bgcolor="#CCC999"> <div class="container"> <div style="clear: both; display: block; padding-bottom: 2px;"></div> <ul id="topnav"> <li><a href="http://www.brewhas.org/index.html">Home</a></li> <li><a href="#">Team Pages</a> <span> <a href="http://www.brewhas.org/team_pages/boothby.html">Boothby</a> | <a href="http://www.brewhas.org/team_pages/bradt.html">Bradt</a> | <a href="http://www.brewhas.org/team_pages/jcurry.html">J Curry</a> | <a href="http://www.brewhas.org/team_pages/pcurry.html">P Curry</a> | <a href="http://www.brewhas.org/team_pages/hurlebaus.html">Hurlebaus</a> | <a href="http://www.brewhas.org/team_pages/jankowski.html">Jankowski</a> | <a href="http://www.brewhas.org/team_pages/oneil.html">O'Neil</a> | <a href="http://www.brewhas.org/team_pages/shimizu.html">Shimizu</a> | <a href="http://www.brewhas.org/team_pages/cwagner.html">C Wagner</a> | <a href="http://www.brewhas.org/team_pages/jwagner.html">J Wagner</a> </span> </li> <li><a href="http://www.brewhas.org/rules.html">League Rules</a></li> <li><a href="http://www.brewhas.org/payout_picks.html">Payouts & Draft Order</a></li> <li><a href="http://www.brewhas.org/standings/2010_standings.html">Standings</a> <span> <a href="http://www.brewhas.org/standings/2010_standings.html">2010</a> | <a href="http://www.brewhas.org/standings/2009_standings.html">2009</a> | <a href="http://www.brewhas.org/standings/2008_standings.html">2008</a> | <a href="http://www.brewhas.org/standings/2007_standings.html">2007</a> | <a href="http://www.brewhas.org/standings/2006_standings.html">2006</a> | <a href="http://www.brewhas.org/standings/2005_standings.html">2005</a> | <a href="http://www.brewhas.org/standings/2004_standings.html">2004</a> | <a href="http://www.brewhas.org/standings/2003_standings.html">2003</a> | <a href="http://www.brewhas.org/standings/2002_standings.html">2002</a> | <a href="http://www.brewhas.org/standings/2001_standings.html">2001</a> </span> </li> <li><a href="http://www.brewhas.org/drafts/2011_draft.html">Drafts</a> <span> <a href="http://www.brewhas.org/drafts/2011_draft.html">2011</a> | <a href="http://www.brewhas.org/drafts/2010_draft.html">2010</a> | <a href="http://www.brewhas.org/drafts/2009_draft.html">2009</a> | <a href="http://www.brewhas.org/drafts/2008_draft.html">2008</a> | <a href="http://www.brewhas.org/drafts/2007_draft.html">2007</a> | <a href="http://www.brewhas.org/drafts/2006_draft.html">2006</a> | <a href="http://www.brewhas.org/drafts/2005_draft.html">2005</a> | <a href="http://www.brewhas.org/drafts/2004_draft.html">2004</a> | <a href="http://www.brewhas.org/drafts/2003_draft.html">2003</a> | <a href="http://www.brewhas.org/drafts/2002_draft.html">2002</a> | <a href="http://www.brewhas.org/drafts/2001_draft.html">2001</a> </span> </li> <li><a href="http://www.brewhas.org/excelfiles/alltimeaverages.xls">Records</a></li> <li><a href="http://www.brewhas.org/excelfiles/transactions.xls">Transactions</a></li> </ul> </div> </td> </tr> <tr> <td width="164" bgcolor="#FFFFFF"> </td> <td width="59" bgcolor="#FFFFFF"> </td> <td colspan="4" valign="top" bgcolor="#FFFFFF"> <table border="0" cellspacing="0" cellpadding="2" width="835"> <div align="center"> <tr> <td width="831" height="31" class="pageName"> <div align="left"></div> </td> </tr> </div> </table> </td> </tr> </table> <div id="header"></div> <div id="leftcol_long"></div> <div id="content_long"> <h2>Transaction Search - Team History</h2> <table border="0" cellspacing="0" cellpadding="1" width="95%" align=center> <tr> <td bgcolor="#ffffff" height="35" valign="top" rowspan="2"> <form name="form1" method="post" action="http://brewhas.org/team_history.php"> <table border="0" align=left> <tr> <td>Year: <select name='year'> <option value='select'>SELECT</option> <option value='2011' <?php if($_POST['year'] == '2011') echo "selected"?>>2011</option> <option value='2010' <?php if($_POST['year'] == '2010') echo "selected"?>>2010</option> <option value='2009' <?php if($_POST['year'] == '2009') echo "selected"?>>2009</option> <option value='2008' <?php if($_POST['year'] == '2008') echo "selected"?>>2008</option> <option value='2007' <?php if($_POST['year'] == '2007') echo "selected"?>>2007</option> <option value='2006' <?php if($_POST['year'] == '2006') echo "selected"?>>2006</option> <option value='2005' <?php if($_POST['year'] == '2005') echo "selected"?>>2005</option> <option value='2004' <?php if($_POST['year'] == '2004') echo "selected"?>>2004</option> <option value='2003' <?php if($_POST['year'] == '2003') echo "selected"?>>2003</option> <option value='2002' <?php if($_POST['year'] == '2002') echo "selected"?>>2002</option> <option value='2001' <?php if($_POST['year'] == '2001') echo "selected"?>>2001</option> </select> Owner: <select name='owner'> <option value='select'>SELECT</option> <option value='J BOOTHBY'<?php if($_POST['owner'] == 'J BOOTHBY') echo "selected"?>>J BOOTHBY</option> <option value='K BRADT' <?php if($_POST['owner'] == 'K BRADT') echo "selected"?>>K BRADT</option> <option value='J CURRY' <?php if($_POST['owner'] == 'J CURRY') echo "selected"?>>J CURRY</option> <option value='P CURRY' <?php if($_POST['owner'] == 'P CURRY') echo "selected"?>>P CURRY</option> <option value='R HURLEBAUS' <?php if($_POST['owner'] == 'R HURLEBAUS') echo "selected"?>>R HURLEBAUS</option> <option value='M JANKOWSKI' <?php if($_POST['owner'] == 'M JANKOWSKI') echo "selected"?>>M JANKOWSKI</option> <option value='T ONEIL' <?php if($_POST['owner'] == 'T ONEIL') echo "selected"?>>T ONEIL</option> <option value='C WAGNER' <?php if($_POST['owner'] == 'C WAGNER') echo "selected"?>>C WAGNER</option> <option value='J WAGNER' <?php if($_POST['owner'] == 'J WAGNER') echo "selected"?>>J WAGNER</option> <option value='J BADER' <?php if($_POST['owner'] == 'J BADER') echo "selected"?>>J BADER</option> <option value='M SUH' <?php if($_POST['owner'] == 'M SUH') echo "selected"?>>M SUH</option> </select> </td> <td nowrap class="row1" width="40"><input type="submit" value="Submit" name="submit"></td> <td nowrap class="row1" width="60"></td> <td><p><img src="images/baseball.jpg" alt="baseball" width="8""height=8"" /><span class="style7"> Note: For the 2001 season, only the draft transactions are available.</span></p></td> </tr> </table> </form> </td> </tr> </table> <?php include 'config.php'; include 'opendb.php'; //Include the PS_Pagination class include('ps_pagination.php'); if((isset($url_year))&&(isset($url_owner))) { //If a year and owner appear in the URL, meaning we're past page 1 --> get the year and owner from the URL parms $year_search = $url_year; $owner_search = $url_owner; } else //If a year and owner have not been entered and do not appear in the URL (first time thru) --> get them from the form { $year_search = $_POST['year']; $owner_search = $_POST['owner']; } switch ($year_search) { case "2011": $year_end="2012"; break; case "2010": $year_end="2011"; break; case "2009": $year_end="2010"; break; case "2008": $year_end="2009"; break; case "2007": $year_end="2008"; break; case "2006": $year_end="2007"; break; case "2005": $year_end="2006"; break; case "2004": $year_end="2005"; break; case "2003": $year_end="2004"; break; case "2002": $year_end="2003"; break; case "2001": $year_end="2002"; break; } echo "--right before IF--"; echo "year:".$year_search." "; echo "post year:".$_POST['year']." "; echo "year end:".$year_end." "; echo "owner:".$owner_search." "; //This checks to see if both the year and the owner have been selected. if(($year_search="select")||($owner_search="select")) { echo "<BR>"."------while in IF--"; echo "year:".$year_search." "; echo "post year:".$_POST['year']." "; echo "year end:".$year_end." "; echo "owner:".$owner_search; echo "<p class='style7'>Please select both a year and a team owner.</p>"; exit; } else //sets the query to get the number of rows { $sql = "SELECT * FROM `BKL_TRANSACTIONS` WHERE (((TO_OWNER='$owner_search')OR(FROM_OWNER='$owner_search')) and (TRANS_DT >='$year_search') AND (TRANS_DT <='$year_end'))"; } $count = mysql_query($sql) or die ("Could not execute the query"); //executes the query to count the number of matching rows //Count the number of results $numrows=mysql_num_rows($count); echo "<p class='style7'>Your search: "".$year_search." ".$owner_search."" returned <b>".$numrows."</b> results.</p>"; //Count the number of results /* * Create a PS_Pagination object * * $conn = MySQL connection object (defined in opendb.php) * $sql = SQl Query to paginate * 50 = Number of rows per page * 5 = Number of links * "year=valu1&owner=value2" = Append name parameters ($year_search and $owner_search) to paginations links */ $pager = new PS_Pagination($conn, $sql, 50, 5, "year=$year_search&owner=$owner_search"); /* * The paginate() function returns a mysql result set * or false if no rows are returned by the query */ $rs = $pager->paginate(); //executes the query if(!$rs) die(mysql_error()); if ($numrows == 0) //if no matches, don't display the table exit; else //build the table and insert rows { echo "<table border=1 cellspacing=0 cellpadding=1 width='77%' align=left bordercolor=#666666>"; echo "<tr bgcolor=#cccc99 class='style5'><th width='10%' class='style5'>Date</th>"; echo "<th width='10%' class='style5'>Action</th>"; echo "<th width='12%' class='style5'>From</th>"; echo "<th width='12%' class='style5'>To</th>"; echo "<th width='5%' class='style5'>Pos</th>"; echo "<th width='18%' class='style5'>Name</th>"; echo "<th width='5%' class='style5'>Round</th></tr>"; while ($row = mysql_fetch_array($rs)) { echo "<tr><td width='10%' class='style6'>".$row['TRANS_DT']."</td>"; echo "<td width='10%' class='style6'>".$row['TRANS_ACTION']."</td>"; echo "<td width='12%' class='style6'>".$row['FROM_OWNER']."</td>"; echo "<td width='12%' class='style6'>".$row['TO_OWNER']."</td>"; echo "<td width='5%' class='style6'>".$row['POSITION']."</td>"; echo "<td width='18%' class='style6'>".$row['PLAYER_FNAME']." ".$row['PLAYER_LNAME']."</td>"; echo "<td width='5%' class='style6'>".$row['DRAFT_RND']."</td></tr>"; } //Display the navigation if ($numrows > 50) { echo "<p class='style7'>".$pager->renderFullNav()."</p>"; } echo "</table>"; } ?> </div> <div id="rightcol_long"></div> <div id="footer"><p align="center" class="style8">Brewhas Keeper League - <img src="images/icon_mlb.gif" alt="mlb" width=36 height=18> - Established 2001</p></div> <p></p> </body> </html> Similar TutorialsOK, since today is the 31st, I guess I figured out that strtotime("-1 Month') really only goes back 30 days, so where I think it should be September, its registering October 1st. Is there a fix for this? Code: [Select] $month = date('F Y', strtotime("-1 month")); $month1 = date('F Y', strtotime("-2 month")); $month2 = date('F Y', strtotime("-3 month")); $month3 = date('F Y', strtotime("-4 month")); $month4 = date('F Y', strtotime("-5 month")); $month5 = date('F Y', strtotime("-6 month")); Hi
I'm have a PHP form that submits to a MYSQL database and I'm trying to make it so when any form input field is empty the user gets a message below that field and the data isn't submitted. I can't seem to get it work though?
<?php // submit data to database if (isset($_POST['submit'])) { // assign variable names to name attributes from the form $firstname = $_POST['first-name']; $email = $_POST['email']; // This is the attempted validation code if(empty($firstname)) { $error= "<br>- Please enter your firstname"; } if(empty($email)) { $error="<br>- Please enter your email"; } if ($error) { $result="<p class='alert error'>There is an error. Please correct the following: {$error}</p>"; } else { // This is when the data is submitted $query = "INSERT INTO users(firstname, email) VALUES(?,?)"; $stmt = $connection->prepare($query); $stmt->bind_param("ss", $f, $e); $f = $firstname; $e = $email; $stmt->execute(); $stmt->close(); $connection->close(); header("Location: index.php"); // makes page refresh after query so new records show in HTML table } } ?>
I want to remove the HTTP:// or HTTPS:// from the insert into the DB. The Viewer may put just www, or copy the entire URL with the HTTP:// or HTTPS://
I tried using the preg-replace but couldn't seem to get it to work.
Any other recommendation?
Thanks in advance,
Mike
Hi all, I am trying to figure out how to calculate 5 working days prior to a given date. I have done some googling but can only see examples of how to add 5 working days onto a date, such as this: Code: [Select] $holidayList = array(); $j = $i = 1; while($i <= 5) { $day = strftime("%A",strtotime("+$j day")); $tmp = strftime("%d-%m-%Y",strtotime("+$j day")); if($day != "Sunday" and $day != "Saturday" and !in_array($tmp, $holidayList)) { $i = $i + 1; $j = $j + 1; } else $j = $j + 1; } $j = $j -1; echo strftime("%A, %d-%m-%Y",strtotime("+$j day")); Does anyone know how to calculate 5 working days prior to a date? Many thanks, Greens85 Hey everyone, so im trying to utilize a systems OPTION command send prior to the POST command, the OPTION command will for example state that it would like to request specific headers. im trying to perform this to get the headers needed before the POST command im trying to execute, the values are required for the POST command i need to perform to get a response. The URL in question would be: https://media-entitlement.mlb.com/api/v3/jwt?os=windows&did=ffeae86c-9447-4bac-a021-caad0c02c605&appname=mlbtv_web Request method: OPTIONS (to get required headers):
Host: media-entitlement.mlb.com then a post command is performed just after which retrieves the values originally requested by the OPTIONS command prior to the POST:
Host: media-entitlement.mlb.com
Now Generally speaking, i fully understand their authorization etc. but this specific set of values seem only used in this one situation, they use bam-sdk which i understand pretty well. but needless to say this authorization bearer, and api-key value only seem generated via the initial OPTIONS grab in browser. so in summary i need to understand how these OPTIONS commands can be utilized to store the required headers as a variable which can be used in the POST command. Thanks in advance for your time and energy responding. mosb3rgler Edited June 14, 2019 by mosb3rglertypo I have a form with dropdown list that is populated with values from Sql Server table. Now i would like to use this selected item in SQL query. The results of this query should be shown in label or text field. So when a user selects item from dropdown menu, results from SQL query are shown at the same time. I have two dropdown list at the moment in my form. First one gets all values from a column in table in SQL Server. And the second one should get a value from the same table based on a selection in first dropdown list.
When i load ajax.php i get 2 error mesages: This is my code so far. I have tried to do it with this Ajax script. But i can only get first dropdown to work. The second dropdown(sub_machinery) does not show values, when first dropdown item is selected. The second dropdown should show values from databse table with this query( *$machineryID* is first dropdown selected item): SELECT MachineID FROM T013 WHERE Machinery=".$machineryID. Index.php <!doctype html> <?PHP $server = "server"; $options = array( "UID" => "user", "PWD" => "pass", "Database" => "database"); $conn2 = sqlsrv_connect($server, $options); if ($conn2 === false) die("<pre>".print_r(sqlsrv_errors(), true)); echo " "; ?> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <section id="formaT2" class="formaT2 formContent"> <div class="row"> <div class="col-md-2 col-3 row-color remove-mob"></div> <div class="col-md-5 col-9 bg-img" style="padding-left: 0; padding-right: 0;"> <h1>Form</h1> <div class="rest-text"> <div class="contactFrm"> <p class="statusMsg <?php echo !empty($msgClass)?$msgClass:''; ?>"><?php echo $statusMsg; ?></p> <form action="connection.php" method="post"> <div>machinery</div> <select id="machinery"> <option value="0">--Please Select Machinery--</option> <?php // Fetch Department $sql = "SELECT Machinery FROM T013"; $machanery_data = sqlsrv_query($conn2,$sql); while($row = sqlsrv_fetch_array($machanery_data) ){ $id = $row['Id']; $machinery = $row['Machinery']; // Option echo "<option value='".$id."' >".$machinery."</option>"; } ?> </select> <div class="clear"></div> <div>Sub Machinery</div> <select id="sub_machinery"> <option value="0">- Select -</option> </select> <input type="submit" name="submit" id="submit" class="strelka-send" value="Insert"> <div class="clear"> </div> </form> </div> </div> </div> </div> </section> </script> <script type="text/javascript"> $(document).ready(function(){ $("#machinery").change(function(){ var machinery_id = $(this).val(); $.ajax({ url:'ajaxfile.php', type: 'post', data: {machinery:machinery_id}, dataType: 'json', success:function(response){ var len = response.length; $("#sub_machinery").empty(); for( var i = 0; i<len; i++){ var machinery_id = response[i]['machinery_id']; var machinery = response[i]['machinery']; $("#sub_machinery").append("<option value='"+machinery_id+"'>"+machinery+"</option>"); } } }); }); }); </script> </body> </html> Ajaxfile.php <?php $server = "server"; $options = array( "UID" => "user", "PWD" => "pass", "Database" => "database"); $conn2 = sqlsrv_connect($server, $options); if ($conn2 === false) die("<pre>".print_r(sqlsrv_errors(), true)); echo " "; $machineryID = $_POST['machinery']; // department id $sql = "SELECT MachineID FROM T013 WHERE Machinery=".$machineryID; $result = sqlsrv_query($conn2,$sql); $machinery_arr = array(); while( $row = sqlsrv_fetch_array($result) ){ $machinery_id = $row['ID']; $machinery = $row['MachineID']; $machinery_arr[] = array("ID" => $machinery_id, "MachineID" => $machinery); } // encoding array to json format echo json_encode($machinery_arr); ?>Edited May 6, 2019 by davidd Hi freaks, I'm new to php first of all. I'm dynamically binding a dropdownlist with mysql database . After the user selects an item from it , I want to match that item with another table so as to populate another database. The code I'm using to populate dropdown: Code: [Select] <?php $con = mysql_connect("localhost","root",""); if(!$con) { die ('Can not connect to : '.mysql_error()); } mysql_select_db("ims",$con); $result=mysql_query("select cat_id,cat_name from category"); echo "<select name=cat>"; while($nt=mysql_fetch_array($result)) { echo "<option value=$nt[cat_id]> $nt[cat_name] </option>"; } echo "</select>"; mysql_close($con); ?> Now after the user selects any one of the item , I want to bind another dropdown on the same page using such query like $result=mysql_query("select subcategory.sc_id,subactegory.sc_name from subcategory,category where subcategory.sc_id=$nt[cat_id]"); Please anyone tell me the logic and code to do it. Also tell me do I need an intermediate page to post the 1st dropdown value and then continue with 2nd dropdown. I couldn't figure out the concept anyhow. Help on this will be highly appreiable . (Tell me if I'm not clear with my question) 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; } } }; I am not a developer but I can modify code to work for me. The following code works on my test machine (Windows 10, IIS, PHP 7.4) but doesn't work on my website (cPanel, Some version of Linux, PHP 7.4). The two dropdowns are for State and City. You are supposed to be able to select the state and then select a city from that state then bring up a report for craft breweries in the city. When selecting State from the first dropdown, the page refreshes, the URL is correct with the reports.php?cat=<STATE> so $cat is being set, but the first dropdown no longer has the state selected and the second dropdown is populated with All cities and not just one ones from the selected state. Any ides why this is working fine on one machine and not the other? Selected code from reports.php
<?php
?>
/////// for second drop down list we will check if State is selected else we will display all the cities/////
echo "<form method=post action='brewerylistbycity.php'>";
}
////////// Starting of second drop downlist /////////
//// End Form /////
Trying to code a first fit algorithm (explanation here). It doesn't output everything correctly at the end. There probably is an easier way to achieve this, but I need to do it using do and while statements. From the output I only get the first array, none of the others display. function first_fit(&$arr, &$max) { $bin = array(array(), array(), array(), array(), array(), array(), array(), array(), array() ,array() ); $i=0; $j=0; do { do { if (array_sum($bin[$j])+$arr[$i] <= $max) {$bin[$j][] = $arr[$i]; $k=1; } $j++; } while($k = 0); $i++; $j=0; } while($i<=9); outputarray($bin[0]); outputarray($bin[1]); outputarray($bin[2]); outputarray($bin[3]); outputarray($bin[4]); outputarray($bin[5]); outputarray($bin[6]); outputarray($bin[7]); outputarray($bin[8]); outputarray($bin[9]); } The function outputarray() just prints the array in a nicely formatted way. Any help would be much appreciated. i want do do something like this Hi there can anybody help me please? my if statement isnt working?? All i am trying to do is display an image if the session variable is == entered varialble "Empire" I get the error message "Parse error: syntax error, unexpected T_VARIABLE, expecting " Code: [Select] if $_SESSION['MM_Username'] == 'Empire'{ echo'<img src="Images/empicon.jpg" width="20" height="20" class="moncalimari"/>' ; } ?> I have checked and the session does == Empire Please help Thank you. Can someone write me some simple code to check to see if the url has the word "soundcloud" in them. This is what I want to do.... This is my code now... Code: [Select] echo " <h3> $title - $author</h3> </br> <iframe width='640' height='360' src='$link' frameborder='0' allowfullscreen></iframe> </br> </br> $message </br> <font color='#8b8d9b' size='1'>Posted By: $username $date</font> </br></br></br></br></br> "; However I want to pull the link value out of the database and see if it contains the word "soundcloud" and if it does do this...(note the height is changed) Code: [Select] echo " <h3> $title - $author</h3> </br> <iframe width='640' height='100' src='$link' frameborder='0' allowfullscreen></iframe> </br> </br> $message </br> <font color='#8b8d9b' size='1'>Posted By: $username $date</font> </br></br></br></br></br> "; Any help would be greatly appreciated. I need help with my if/else statement. Code: [Select] function show_list() { $query = "SELECT show_id,show_name,host,description_short,show_graphic1 FROM shows"; $result = mysql_query($query) or die(mysql_error()); echo "<table>"; while($row = mysql_fetch_array($result)) { echo "<tr> <td rowspan='3' width='155' class='show_image'> <a href='". $site ."show_page.php?show_id=". $row['show_id'] ."'> <img src='". $site ."images/". $row['show_graphic1'] ."' height='150' width='150'></img></a> </td> <td class='show_name'> <h1>"; if ($row['host'] == "") { echo $row['show_name']" with " $row['host']; } else { echo $row['show_name']; } echo " </h1> </td> </tr> <tr> <td height='100'>" . $row['description_short'] . "</td> </tr> <tr> <td align='right'> <a href='". $site ."show_page.php?show_id=". $row['show_id'] ."'>More Info</a> </td> </tr>"; } echo "</table>"; } This function is for a page showing a list of shows from a database. Not all shows have a host. So it does not need to show "with host name" for those shows. I tried if / else statement stating that if there "is" data in the row to display one thing and if there "is not" data in the row to display another. Here is that piece of code. Code: [Select] if ($row['host'] == "") { echo $row['show_name']" with " $row['host']; } else { echo $row['show_name']; } I keep getting this error "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/ansonb/lwr_config.php on line 46" What am I doing wrong ? I'm sure it is something simple, I just can't figure it out. Hi All, I have an SQL query that returns a date (31/01/2011 - for example) and this get's placed into a variable - $req_date. I want to be able to display an image when the required date is within 5 days of the current date. Normally in an if statement I would use: <?php if ($ticket_no == 100) { echo "This is ticket 100" } else { echo "This is not ticket 100" ?> However I am struggling to work out the difference between the 2 dates. Any ideas? Cheers Matt 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! Hi I am trying to perform an echo yes if field from query is equal to one or no if anything else. See the code below, Now its erroring saying unexpected t variable in string and its also saying expecting ' It seems to be erroring at the start of my IF statement. So can anyone please help with what I have done wrong. This will be my first personal written IF statement so if it is miles off i apologise. <?php $qGetCat = ("SELECT * FROM category ORDER BY `id`"); $rGetCat = mysql_query($qGetCat) or die(mysql_error()); while($Cat = mysql_fetch_assoc($rGetCat)) { ?> <td height="31" align="left" nowrap="nowrap"><?= $Cat['id'] ?></td> <td align="left" nowrap="nowrap"><?= $Cat['cat1'] ?></td> <td align="left" nowrap="nowrap"> <?php if $Cat['top']='1' { echo "Yes";} else { echo "No";} ?> </td> <td><a href="updatetopcategory.php?=<?= $Cat['id'] ?>"><img src="../images/Edit.png" width="29" height="29" /></a></td> <td><img src="../images/delete.jpg" width="29" height="29" /></td> <? } ?> |