PHP - Echoing Search Criteria
Hey All.
Say someone was searching my photo database website from a drop down menu. They search for the aircraft: 'Boeing 747' and airline: 'British Airways', which is posted with the url 'result.php?aircraft=Boeing+747&airline=British+Airways'. How would i get my php to echo: Your search for 'Boeing 747 > British Airways' is displayed below: Or if the search was for just: Aspect: Flightdeck, echo: Your search for 'Flightdeck' is displayed below: I hope it's clear, Thanks, Jimmy Similar TutorialsHow to Store the search criteria like if user serach for a particular job and want to store that search ? Should i create anyother table to store critaria .... i have no idea what to do in this case/ thankx in advance So let's assume i'm making a script for searching cars by different criteria. Name of the car, color, and mileage. I used to do this by using LIKE and just adding AND for as many times as needed. But i've read that that is obsolete and is giving servers a hard time, so i went ahead and started making a new script that will use fulltext search. I've hit a dead end. Code: [Select] function search($table,$what,$string,$limit,$start,$country) { global $totrows; global $pages; $string = explode("*",$string); $what = explode("*",$what); $cname = trim($string[0]); $t = 0; $parameters = ""; while (isset($what[$t])){ if ($t>0) { $paramm .= ", "; } $paramm .= trim($what[$t]); if ($t>0) { $parama .= " "; } $parama .= trim($string[$t]); $t++; } $parameters .= " AND locationc = '".$country."'"; $sql = "SELECT *, MATCH(".$paramm.") AGAINST('".$parama."') AS score FROM main WHERE MATCH(".$paramm.") AGAINST('".$parama."') ORDER BY score DESC"; $result = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { var_dump($row); } } How does this work: The user selects and enters his parameters> The script then joins them all into a single variable which is then sent to the function(the reason i do this i because the user might input only the name, so that way i can add more criteria and not need to change the script)> The script explodes those into arrays and then it processes them into a form for use with sql> I run the sql query and then return the results. What's the problem? There's two of them actually> The first one is that mysql returns an error "Can't find FULLTEXT index matching the column list" even though i did setup fulltext indexes. (phpmyadmin c/p) Code: [Select] name FULLTEXT No No name 0 YES color FULLTEXT No No color 0 YES mileage FULLTEXT No No mileage 0 YES The second problem is that the script is not selective and will not work as intended. For example, a car's name is 300, the users input's 300, and the script will return those rows that had mileage 300 or 300000 or whatever. How do i fix this, and is FULLTEXT the right way to go with multi criteria search? Hey all, I'm using $_POST to post search variables from a search form i have made for my site. Below is the code for the search form: Code: [Select] <form method="post" action="results.php"> <p class="label">Airline </p><p class="right"> <select style="width: 200px;" name="airline" id="airline"> <option selected="selected" value=""> All Airlines</option> <?php $query=mysql_query("SELECT * FROM photos GROUP BY airline, aircraft ORDER BY airline"); while($row = mysql_fetch_assoc($query)){ echo '<option value="'.$row['airline'].'">'.$row['airline'].'</option>'; } ?> </select></p><br /><br /> <p class="label">Aircraft </p><p class="right"> <select style="width: 200px;" name="aircraft" id="aircraft"> <option selected="selected" value=""> All Aircraft</option> <?php $query=mysql_query("SELECT * FROM photos GROUP BY aircraft ORDER BY aircraft"); while($row = mysql_fetch_assoc($query)){ echo '<option value="'.$row['aircraft'].'">'.$row['aircraft'].'</option>'; } ?> </select></p><br /><br /> <p class="label">Registration </p><p class="right"><input type="text" style="width: 198px;" class="text" name="registration" id="registration" value="" /></p><br /><br /> <p class="label">Construction Number </p><p class="right"><input type="text" style="width: 198px;" class="text" name="cn" id="cn" value="" /></p><br /><br /> <p class="label">Location </p><p class="right"> <select class="select" style="width: 200px;" name="location" id="location"> <option selected="selected" value=""> All Locations</option> <?php $query=mysql_query("SELECT * FROM photos GROUP BY location ORDER BY location"); while($row = mysql_fetch_assoc($query)){ echo '<option value="'.$row['location'].'">'.$row['location'].'</option>'; } ?> </select></p><br /><br /><br /> <div class="options2"></div><br /><br /> <p class="label">Genre </p><p class="right"><select class="select" style="width: 200px;" name="class" id="class"> <option selected="selected" value=""> All Genres</option> <option> Airliner</option> <option> Cargo</option> <option> Executive/Private</option> <option> General Aviation</option> </select></p><br /><br /> <p class="label">Aspect/Subject </p><p class="right"><select class="select" style="width: 200px;" name="aspect" id="aspect"> <option selected="selected" value=""> All Aspects</option> <option> Cabin View</option> <option> Close Up</option> <option> Flight Deck</option> <option> Front View</option> <option> Rear View</option> <option> Side Profile</option> </select></p><br /><br /> <p class="label">Scheme </p><p class="right"> <select class="select" style="width: 200px;" name="scheme" id="scheme"> <option selected="selected" value=""> All Schemes</option> <option> Basic</option> <option> Extra Stickers</option> <option> Hybrid</option> <option> Special</option> <option> Standard</option> </select></p><br /><br /> <p class="label">Situation/Phase</p><p class="right"> <select class="select" style="width: 200px;" name="situation" id="situation"> <option selected="selected" value=""> All Situations</option> <option> Approach</option> <option> Departure</option> <option> Ground</option> </select></p><br /><br /> <p class="label">Time</p><p class="right"> <select class="select" style="width: 200px;" name="tod" id="tod"> <option selected="selected" value=""> All Times of Day</option> <option> Dawn and Dusk</option> <option> Day</option> <option> Night</option> </select></p><br /><br /><br /> <p class="label">Order By</p><p class="right"> <select class="select" style="width: 110px;" name="order" id="order"> <option selected="selected" value=""> Photo #</option> <option> Aircraft</option> <option> Airline</option> <option> Date of Photo</option> <option> Location</option> <option> Registration</option> </select> </p> <p class="right"> <br /><br /> <input type="submit" name="submit" id="submit" value=" Search " /> <input type="reset" name="reset" id="reset" value=" Reset " /> </form> On the results page i have this script: Code: [Select] if(!empty($_POST)) { $criteria= implode('</strong> > <strong>', array_map('htmlentities', $_POST)); } <p class="resulttext">Your search <?php if(!empty($_GET)) { echo 'for ';} ?> <strong><?php echo $criteria;?></strong> returned <strong><?php echo $num;?></strong> photo results, these are displayed below.</p> to echo the search variable. For example if someone used the form to search for 'British Airways' and 'London Heathrow', the results page would read: results.php?airline=British+Airways&location=London+Heathrow Your search for British Airways > London Heathrow has returned X photo results.... Although this is working; because there is often alot of form options not used, the url turn's out to be: results.php?airline=British+Airways&location=London+Heathrow&aircraft=®istration=&blah=&blah=&submit=search .....etc Which then reads as: Your search for British Airways > London Heathrow > > > > > SEARCH has returned X photo results.... as seen below in this pictu Is there anyway to stop this from happening and just echo the search field which !="" Thanks In Advanced! Hi, I have been trying for 2 days to get this to work. I am trying to put in a list of search keywords in the form, run a LIKE query on the database, and echo out all of the matching terms. Please if someone could please show me how to echo out this information I would be very grateful. Thank you. Code: [Select] <?php $host = ""; $database = ""; $username = ""; $password = ""; $tbl_name = "users"; $conn = mysql_connect($host, $username, $password) or die("Could not connect: " . mysql_error()); mysql_select_db($database); include('bouncer.php'); $currentUser = $_SESSION['myusername']; if(isset($_POST['submit'])) { $first = mysql_real_escape_string( $_POST['first']); $last = mysql_real_escape_string( $_POST['last']); $dob = mysql_real_escape_string( $_POST['dob']); $gender = mysql_real_escape_string( $_POST['gender']); $ethnic = mysql_real_escape_string( $_POST['ethnic']); $country = mysql_real_escape_string( $_POST['country']); $state = mysql_real_escape_string( $_POST['state']); $town = mysql_real_escape_string( $_POST['town']); $zip = mysql_real_escape_string( $_POST['zip']); $email = mysql_real_escape_string( $_POST['email']); $hobbies = mysql_real_escape_string( $_POST['hobbies']); $job = mysql_real_escape_string( $_POST['job']); $business = mysql_real_escape_string( $_POST['business']); $religion = mysql_real_escape_string( $_POST['religion']); $social = mysql_real_escape_string( $_POST['social']); $political = mysql_real_escape_string( $_POST['political']); $affiliations = mysql_real_escape_string( $_POST['affiliations']); $buying = mysql_real_escape_string( $_POST['buying']); $selling = mysql_real_escape_string( $_POST['selling']); $likes = mysql_real_escape_string( $_POST['likes']); $dislikes = mysql_real_escape_string( $_POST['dislikes']); $links = mysql_real_escape_string( $_POST['links']); //THE SEARCH FUNCTION $result = mysql_query ( "SELECT * FROM users WHERE dob LIKE '%$dob%' OR gender LIKE '%$gender%' OR race LIKE '%$ethnic%' OR job LIKE '%$job%' OR country LIKE '%$country%' OR state LIKE '%$state%' OR town LIKE '%$town%' OR zip LIKE'%$zip%' OR hobbies LIKE'%hobbies%' OR business LIKE '%$business%' OR religion LIKE'%$religion%' OR social_groups LIKE '%$social%' OR political_groups LIKE'%$political%' OR other_affiliations LIKE ' %$affiliations%' OR buying LIKE '%$buying%' OR selling LIKE '%$selling%' OR links LIKE '%$links%' OR likes LIKE '%$likes%' OR dislikes LIKE'%$dislikes%'"); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } $row = mysql_fetch_row($result); echo $row[0]; echo $row[1]; // I HAVE NO IDEA WHERE TO GO FROM HERE. } ?> <html> <body> <p>Login Successful</p> <p> </p> <form action="login_success6.php" method="post"> <p> <input type="text" name="first" size="20" /> First name<br /> <input type="text" name="last" size="20" /> Last name<br /> <input name="dob" type="text" size="20" id="dob" /> Date of Birth<br /> <input type="text" name="gender" size="20" id="gender" /> Gender <br /> <input type="text" name="ethnic" size="20" id="ethnic" /> Ethnicity <br /> <input type="text" name="country" size="20" id="country" /> Country<br /> <input type="text" name="state" size="20" id="state" /> State<br /> <input type="text" name="town" size="20" id="town" /> Town<br /> <input type="text" name="zip" size="20" id="zip" /> Zip Code<br /> <br /> <input type="text" name="email" size="40" id="email" /> Email<br /> <textarea name="job" cols="40" id="job"></textarea> Job<br /> <textarea name="business" cols="40" id="business"></textarea> Business<br /> <input type="text" name="religion" size="60" id="religion" /> Religion</p> <p><br /> <textarea name="social" cols="100" id="social"></textarea> Social Groups<br /> <textarea name="political" cols="100" id="political"></textarea> Political groups<br /> <textarea name="affiliations" cols="100" id="affiliations"></textarea> Other Affiliations<br /> <textarea name="buying" cols="100" id="buying"></textarea> Items I am buying<br /> <textarea name="selling" cols="100" id="selling"></textarea> Items I am selling<br /> <textarea name="likes" cols="100" id="likes"></textarea> My likes <br /> <textarea name="dislikes" cols="100" id="dislikes"></textarea> My dislikes <br /> <textarea name="links" cols="100" id="links"></textarea> My links <br /> <input type="submit" name="submit" value="Store in database and search" /> <input type="reset" value="Reset fields" /> </p> </p> </form> </body> </html> This is posting to any row in mssql that has a matching 'start_date'. I would like it to post rows where start_date = '$start_date' and it also matches the 'meter_id' . It should perform this check of both parameters before posting to mssql.
<?php $session_id = $_SESSION['id']; $comm_id = $_GET['meter_id']; $start_date = $_GET['start_date']; $payment_date = $_POST['payment_date']; $amount_paid = $_POST['amount_paid']; $check_number = $_POST['check_number']; $sql = "UPDATE [radiogates].[dbo].[ops_invoice_history] SET payment_date = '$payment_date', amount_paid = '$amount_paid', check_number = '$check_number' where start_date = '$start_date'"; $query = sqlsrv_query($conn, $sql);Thank you for any help. I need a php/mysql star rating which has 3 criteria to rate and at the bottom a link when clicked saves the ratings. Any idea of where to get that? Something like this Rate criteria 1 Rate criteria 2 Rate criteria 3 Save ratings I am working on a project that involves providing details for county government, and if applicable, cities independent of county oversight. Virginia is a state with a lot of independent cities, so I wanted to echo them in a separate list underneath the county governments.
This code works fine when displaying Virginia information. However, I would like to hide the Independent Cities heading in every other state. For some reason, this code still echoes the Independent Cities heading in states without independant cities in the database.
Any thoughts or wisdom?
(sorry for pasting the whole bulky code)
$query = "SELECT * FROM state WHERE st_id=$statecode"; $result = mysql_query($query) or die("Query $query failed : " . mysql_error()); $row = mysql_fetch_assoc($result); $state_name=$row["st_name"]; $state_note=$row["state_notes"]; echo "<h2>Counties of " . $state_name; "</h2>\n"; $query = "SELECT * FROM counties WHERE st_id=$statecode AND visible=1 ORDER BY county_name ASC"; $result = mysql_query($query) or die("Query $query failed : " . mysql_error()); echo "<table width=100%><tr><td valign=top width=33%>\n"; $count = 1; $col = 0; $rowcount = (int)(mysql_num_rows($result) / 3) + 1; $remainder = mysql_num_rows($result) - ($rowcount - 1) * 3; /* ********************************************************* */ while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<a href=\"services.php?county=".$row["county_id"]."\">".$row["county_name"] . "</style></a><br />\n"; $count = $count + 1; if ((($remainder > 0) && ($count == ($rowcount + 1))) || (($remainder <= 0) && ($count == $rowcount))) { $col = $col + 1; if ($col!=3) { echo "</td><td valign=top width=33%>\n"; $count = 1; if ($remainder > 0) $remainder = $remainder - 1; } } } /* ********************************************************* */ echo "</td></tr></table><br>\n"; mysql_free_result($result); /* ********************************************************* */ $query2 = "SELECT * FROM cities WHERE st_id=$statecode AND visible=1 ORDER BY city_name ASC"; $result2= mysql_query($query2) or die("Query $query failed : " . mysql_error()); $city_id = $row['city_id']; $city_name = $row['city_name']; if ($city_id!="") { echo "<h3>Independent cities of " . $state_name; "</h3>\n"; echo "<table width=100%><tr><td valign=top width=33%>\n"; $count2 = 1; $col2 = 0; $rowcount2 = (int)(mysql_num_rows($result2) / 3) + 1; $remainder2 = mysql_num_rows($result2) - ($rowcount2 - 1) * 3; /* ********************************************************* */ while ($row = mysql_fetch_array($result2, MYSQL_ASSOC)) { echo "<a href=\"services.php?county=".$row["city_id"]."\">".$row["city_name"] . "</style></a><br />\n"; $count2 = $count2 + 1; if ((($remainder2 > 0) && ($count2 == ($rowcount2 + 1))) || (($remainder2 <= 0) && ($count2 == $rowcount2))) { $col2 = $col2 + 1; if ($col2!=3) { echo "</td><td valign=top width=33%>\n"; $count2 = 1; if ($remainder2 > 0) $remainder2 = $remainder2 - 1; } } } /* ********************************************************* */ echo "</td></tr></table><br>\n"; mysql_free_result($result2); /* ********************************************************* */ } ?> Edited by myotch, 06 September 2014 - 09:19 PM. Hi,
I can I include a date range criteria to query with in the following code? The date field in the table (t_persons) is IncidentDate.
$criteria = array('FamilyName', 'FirstName', 'OtherNames', 'NRCNo', 'PassportNo', 'Gender', 'IncidenceCountryID', 'Status', 'OffenceKeyword', 'AgencyID', 'CountryID', 'IncidenceCountryID' ); $likes = ""; $url_criteria = ''; foreach ( $criteria AS $criterion ) { if ( ! empty($_POST[$criterion]) ) { $value = ($_POST[$criterion]); $likes .= " AND `$criterion` LIKE '%$value%'"; $url_criteria .= '&'.$criterion.'='.htmlentities($_POST[$criterion]); } elseif ( ! empty($_GET[$criterion]) ) { $value = mysql_real_escape_string($_GET[$criterion]); $likes .= " AND `$criterion` LIKE '%$value%'"; $url_criteria .= '&'.$criterion.'='.htmlentities($_GET[$criterion]); } //var_dump($likes); } $sql = "SELECT * FROM t_persons WHERE PersonID>0" . $likes . " ORDER BY PersonID DESC";Kind regards. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=308916.0 The result pages is supposed to have pagination like google help me please
Hello guys, I want to get the values of 3rd level of my referral but it did not echo any value but if i put the ref id directly on the code, it will echo the values. why is it so? or am i doing it the wrong way? in my database i have a table test_referral id acct_name ref_id refer_id 1 john J1234 0 2 bull B3456 J1234 3 doe D5567 J1234 4 frank F7788 J1234 5 jimmy J9990 J1234 6 tommy T6784 F7788 7 tom T9988 F7788 8 girly G8866 D5567 9 fred F0099 J9990 10 ronaldo R7722 B3456 thanks $stmt= $pdo->query("SELECT * FROM test_referral WHERE acct_name='Chidi Okafor'"); $parent = $stmt->fetch(PDO::FETCH_LAZY); echo "<ul><li>"; echo $parent['acct_name']; $ref_id = $parent['ref_id']; echo "</li><ul>"; $stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$ref_id'"); $child_count = $stmt->rowCount(); while($child = $stmt->fetch(PDO::FETCH_LAZY)){ echo "<li>"; echo $child['acct_name']; $ref_ids = $child['ref_id']; echo "</li>"; } //$reff = "F7788"; //$stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$F7788'"); $stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$ref_ids'"); $child_count2 = $stmt->rowCount(); while($children = $stmt->fetch(PDO::FETCH_LAZY)){ echo "<ul><li>"; echo $children['acct_name']; echo "</li></ul>"; } Edited by Mr-Chidi, 25 December 2014 - 05:34 AM. Hello, I have a PHP page (below) that is suppose to update a field in my database. For some reason it does not update. I am trying to echo that sql with this script. Any help would be greatly appreciated. Thanks JR Code: [Select] $p = (100-$_POST[$c])/100; $sql = "delete from products_groups where customers_group_id = ".$sppc['customers_group_id']; echo $sql; tep_db_query($sql); $sql = "insert into products_groups select '". $sppc['customers_group_id'] ."' as customers_group_id, ( " . $p . " * p.products_price) as customers_group_price, p.products_id from products p"; echo $sql; tep_db_query($sql); Below is the complete code, Code: [Select] <?php require('includes/application_top.php'); ?> <!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> <script language="javascript" src="includes/general.js"></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();"> <div id="popupcalendar" class="text"></div> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'template_top.php'); ?> <!-- header_eof //--> <?php if (isset($_POST['Update'])) { $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { if ($sppc["customers_group_name"] != "Retail"){ //$sppc['customers_group_id'] $c = "CG_".$sppc['customers_group_id']; $tmp = $_POST[$c]; if ($tmp != 0) { $p = (100-$_POST[$c])/100; tep_db_query("delete from products_groups where customers_group_id = ".$sppc['customers_group_id']); tep_db_query ("insert into products_groups select '". $sppc['customers_group_id'] ."' as customers_group_id, ( " . $p . " * p.products_price) as customers_group_price, p.products_id from products p"); } //if not 0 } //if not Retail } } ?> <!-- body //--> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo "Special Pricing Discount Setup"; ?></td> <td class="specialPrice" align="right"> </td> </tr> </table></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" align="left"> <?php if (isset($_POST['Update'])) { echo "<center>Updated!</center>"; } ?> </td> </tr> <?php $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { ?> <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)"> <td class="dataTableContent" align="left"> <?php if ($sppc["customers_group_name"] != "Retail"){ echo $sppc["customers_group_name"]; } if (isset($_POST['Update'])) { if ($sppc["customers_group_name"] != "Retail"){ $c = "CG_".$sppc['customers_group_id']; $tmp = $_POST[$c]; echo " Current Discount is $tmp%" ; } } ?> </td> </tr> <?php } ?> </table></td> </tr> <tr> <td valign="top"> <form action="" method="post"> <table border="0" width="40%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText" align="left"> </td> <td> </td> </tr> <?php $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { if ($sppc["customers_group_name"] != "Retail"){ ?> <tr> <td class="smallText" align="left">Set New Percentage (%) Discount for <?=$sppc["customers_group_name"]?> :</td> <td><input name="CG_<?=$sppc['customers_group_id']?>" type="text" size="5" value="0"></td> </tr> <?php } } ?> <tr> <td colspan="2" align="center"><input type="submit" name="Update" value="Update"></td> </tr> </table> </form> </td> </tr> </table></td> <!-- body_text_eof //--> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> This problem is existing on a few pages so I'll be in the clear if I can figure out to solve it on one page. Problem is on form submission its still echoing back that sortorder variable which makes it hard for it to compare on the success function to display the right message because the message should be good, bad1, bad2, ... . So is there anyway around that or do I need to do something on the client side of the form page. <?php // Include the database page require ('../inc/dbconfig.php'); if ( isset( $_POST['menuid'] ) ) { $menuid = (int)$_POST['menuid']; $query = "SELECT COUNT(sortorder) AS numOrder FROM `menuitems` WHERE `menu_id` = '".$menuid."'"; $result = mysqli_query ($dbc, $query); $row = mysqli_fetch_array( $result, MYSQL_ASSOC ); $sortorder = $row[ 'numOrder' ] + 1; echo $sortorder; } if (isset($_POST['submitmenuitem'])) { $menuid = mysqli_real_escape_string($dbc, $_POST['menuid']); $itemname = mysqli_real_escape_string($dbc, $_POST['itemname']); $itemurl = mysqli_real_escape_string($dbc, $_POST['itemurl']); $sortorder = mysqli_real_escape_string($dbc, $_POST['sortorder']); $contentpage = mysqli_real_escape_string($dbc, $_POST['contentpage']); $newscategory = mysqli_real_escape_string($dbc, $_POST['newscategory']); $application = mysqli_real_escape_string($dbc, $_POST['application']); $query = "SELECT * FROM `menuitems` WHERE (`itemname` = '".$itemname."') OR (`itemurl` = '".$itemurl."') OR (`contentpage_id` = '".$contentpage."') OR (`application_id` = '".$application."') OR (`newscategory_id` = '".$newscategory."') AND `menu_id` = '".$menuid."'"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); if ($rows == 0) { $query = "INSERT INTO `menuitems` (menu_id, itemname, itemurl, sortorder, contentpage_id, newscategory_id, application_id, creator_id, datecreated, enabled) VALUES ('".$menuid."','".$itemname."','".$itemurl."','".$sortorder."','".$contentpage."', '".$newscategory."', '".$application."', 1, NOW(), 0)"; mysqli_query($dbc, $query); echo "good"; } else { $row = mysqli_fetch_array($result); if (($row['itemname'] == $itemname) && ($row['newscategory_id'] == $newscategory)) echo 'bad9'; elseif (($row['itemname'] == $itemname) && ($row['application_id'] == $application)) echo 'bad8'; elseif (($row['itemname'] == $itemname) && ($row['contentpage_id'] == $contentpage)) echo 'bad7'; elseif (($row['itemname'] == $itemname) && ($row['itemurl'] == $itemurl)) echo 'bad6'; elseif ($row['newscategory_id'] == $newscategory) echo 'bad5'; elseif ($row['application_id'] == $application) echo 'bad4'; elseif ($row['contentpage_id'] == $contentpage) echo 'bad3'; elseif ($row['itemurl'] == $itemurl) echo 'bad2'; elseif ($row['itemname'] == $itemname) echo 'bad1'; } } if (isset($_POST['deletemenuitem'])){ $menuitemID = (int)$_POST['menuitemID']; $query = "UPDATE `menuitems` SET `enabled` = '1' WHERE `id` = '".$menuitemID."' LIMIT 1"; mysqli_query($dbc,$query); } ?> $lastfm = file_get_contents('http://www.last.fm/group/Rishloo/members'); $users = explode('" id="r4_', $lastfm); $users = explode('">', $users[1]); var_dump($users[0]); that is only echoing one ID http://www.last.fm/group/Rishloo/members 1 id for each member it should be echoing.. any idea why it isnt? $lastfm = file_get_contents('http://www.last.fm/group/Rishloo/members'); $grab_id=explode('" id="r4_', $lastfm); for($b=1; $b<count($grab_id); $b++){ $getid=explode('">', $grab_id[$b]); echo count($getid[0]); } that echos all 1's.. any help is appreciated.. thanks thanks Okay, I am having trouble. My script is not echoing the errors on the page/nor logging me in. If I check the browser source code it shows the error. here are my pages please help this is stupid ha index.php Code: [Select] <?php session_start(); include("includes/config.php"); if($_POST['submit']) { include("includes/action/".strtolower($_POST['submit']).".php"); } if (isset($_SESSION['SecureUid'])) { echo "Welcome Member!"; } else { echo $_SESSION['SecureUid']; $Larray = array ( "Username" => array("text","LoginUsername"), "Password" => array("password","LoginPassword"), "Hidden" => array("hidden","SecureHidden"), "Login" => array("submit","Login"), ); if ($LoginErrors) { foreach ($LoginErrors as $val) { echo "{$val}<br />"; } $Site->ClearErrors(); } $CreateForm = $Site->CreateForm("Login","{$_SERVER['PHP_SELF']}","post",$Larray); echo $CreateForm; } ?> includes/config.php Code: [Select] <?php ini_set( "display_errors", true ); date_default_timezone_set( "America/Phoenix" ); define( "CLASS_PATH", "includes/classes" ); //define( "TEMPLATE_PATH", "templates" ); define( "HOMEPAGE_NUM_ARTICLES", 5 ); function handleException( $exception ) { echo "Sorry, a problem occurred. Please try later."; error_log( $exception->getMessage() ); } set_exception_handler( 'handleException' ); include(CLASS_PATH."/class.database.php"); include(CLASS_PATH."/class.actions.php"); $Site = new Actions; $Site->connect(); $Site->setDatabase("ccloyd_rigid"); ?> includes/actions/login.php Code: [Select] <?php //log user in if ($_POST['SecureHidden']) { $Login = $Site->LoginUser(array("Username" => $_POST['LoginUsername'], "Password" => $_POST['LoginPassword'])); if ($Login) { $_SESSION['SecureUid'] = $Site->Uid; $_SESSION['SecureLevel'] = $Site->getLevel($Site->Uid); } else { $LoginErrors = $Site->ReturnErrors("Login"); } } ?> includes/classes/class.actions.php Code: [Select] <?php class Actions extends Database { public $Uid; //Login Vars private $Username; private $Password; //Errors Array private $Errors = array(); public function LoginUser($info, $admin = NULL) { //ugh //startover foreach ($info as $key => $val) { $this->{$key} = mysql_real_escape_string($val); } $this->Password = $this->EncryptPass($this->Password); if ($this->Username == '' || $this->Password == '') { $this->Errors["Login"] = array('Invalid Credentials!'); return false; } $Check = $this->select("users","`id`","username = '{$this->Username}' AND password = '{$this->Password}'"); if ($Check) { $Result = $this->getResult(); $id = $Result[id]; $this->Uid = $id; return true; } else { $this->Errors["Login"] = array('Invalid Credentials!'); return false; } } } ?> Hi all, I have this code which is suppose to display everymessage that the User has, but when im trying to display the messages its displaying them all in different tables.. Im trying to get it so it will be like: inbox ------------------ subject | From subject | username Read Messages ------------------ subject | From subject | username So two tables which one displays the messages which havent been read while the other does <?php session_start(); include "includes/config.php"; include "includes/functions.php"; logincheck(); ini_set ('display_errors', 1); error_reporting (E_ALL); $user=$_SESSION['username']; // Grab whats needed... $all_msgs = mysql_query("SELECT `id` FROM `inbox` WHERE `to`='$user' ORDER BY `id` DESC") or die("Error on line 9 - " . mysql_error()); $get_msg = mysql_query("SELECT * FROM `inbox` WHERE `to`='$user' ORDER BY `id` DESC") or die("Error on line 10 - " . mysql_error()); $msg_num = mysql_num_rows($all_msgs); // lets echo the subject + A linking to the message... echo '<table width="50%" cellpadding="0" align="center" cellspacing="0" border="1" class="table"> <tr> <td class="header" algin="center" colspan="2">Inbox</td> </tr> <tr> <td class="omg" align="center">Subject</td><td align="center" class="omg">From</td> </tr>'; for($number = 1; $number <= $msg_num; $number++) { $line = mysql_fetch_array($get_msg); //if the message is not read... if($line['read'] == 0){ echo '<tr> <td width="50%" align="center"><a href="rmessage.php?messageid=' . $line['id'] . '">' . $line['title'] . '</a>(New)</td><td width="50%" align="center"><a href="profile.php?viewuser=' . $line['from'] . '">' . $line['from'] . '</a></td> </tr></table> <br /> <br />'; }else{ // If message is read... echo '<br /><table width="50%" cellpadding="0" align="center" cellspacing="0" border="1" class="table"> <tr> <td class="header" algin="center" colspan="2">Messages Read</td> </tr> <tr> <td class="omg" align="center">Subject</td><td class="omg" align="center">From</td></td> </tr> <tr> <td width="50%" align="center"><a href="rmessage.php?messageid=' . $line['id'] . '">' . $line['title'] . '</a></td><td width="50%" align="center"><a href="profile.php?viewuser=' . $line['from'] . '">' . $line['from'] . '</td> </tr></table>'; }} ?> Anyone see a way I can sort it so it don't show a table for every message they have? Thanks for any help given I have a login form at http://cloydprojects.com you can login with username: test password test If you login the script works correctly, but if you type in the wrong info my session is not showing here is that I have. my login script Code: [Select] <?php session_start(); ?> <link href="signUp.css" rel="stylesheet" type="text/css" /> <?php include("db.php"); include("classes/class.account.php"); $Acc = new account; $u = $Acc->clean($_REQUEST['usernameLogin']); $password = $Acc->clean($_REQUEST['passwordLogin']); $p = md5($password); $get = mysql_query("SELECT * FROM users WHERE username = '".$u."' and password = '".$p."'"); $find = mysql_num_rows($get); if ($find == 1) { $info = mysql_fetch_assoc($get); $_SESSION['LoggedIn'] = $info['uID'].'.'.$info['username'].'.'.$info['email']; } else { $_SESSION['LoggedFailed'] = '<div id="ErrorBox">Incorrect username/password!</div>'; } //there is more just not showing it here is my index script where the error should be showing! Code: [Select] <div class="stylized"> <?php if(isset($_SESSION['LoggedIn'])) { echo '<h1> Welcome! </h1>'; echo '<a href="logout.php">logout!</a>'; } else { echo $_SESSION['LoggedFailed']; session_destroy(); ?> <form id="instantform" name="form" action="loginUser.php" method="post"> <h1>Login</h1> <label>Username <span class="small">The username you created!</span></label> <input type="text" name="usernameLogin" id="usernameLogin" /> <label>Password <span class="small">Case sensitive!</span></label> <input type="password" name="passwordLogin" id="passwordLogin" /> <button type="submit">Login</button></div> <div class="spacer"></div> </form> <?php } ?> </div> Folks, I want to echo an HTML tag in PHP. Code: [Select] <td width="300" bgcolor="#ffffff" align="center" onmouseout="style.backgroundColor='#ffffff'" onmouseover="style.backgroundColor='#e8e8e8';" style="word-wrap: break-word; border: 1px solid rgb(238, 238, 238); font-size: 12px; background-color: rgb(255, 255, 255);"> So what i am doing is; Code: [Select] echo '<td width="300" bgcolor="#ffffff" align="center" onmouseout="style.backgroundColor='#ffffff'" onmouseover="style.backgroundColor='#e8e8e8';" style="word-wrap: break-word; border: 1px solid rgb(238, 238, 238); font-size: 12px; background-color: rgb(255, 255, 255);">'; And its now working because this tag already has ' (Single Quotes) & ; (Semicolon) so its conflicting. Any work around for this friends? Cheers N Hi, I have this variable that checks which page we're on: Code: [Select] <?php $checkit = $_SERVER['PHP_SELF']; ?> and I need to echo some text depending which page we're on. I am using this code to do so: Code: [Select] <?php if ($checkit=="index.php") { echo "this is the home page"; } if ($checkit=="index2.php") { echo "this is the other page"; }?>...but nothing is printed. what am i doing wrong? Thanks |