PHP - For Loop Giving To Much Out Put
Hello Everyone,
I am working on a project where I have to go in and grab the names of the fields in a table. I got it to work and for it to show me the field names but it also displays a lot more than what I would like for it to do. I keep getting the following error. It is repeated over my screen like 15 times. Quote Warning: mysql_field_name() [function.mysql-field-name]: Field 5 is invalid for MySQL result index 7 in C:\xampp\htdocs\CMS\admin\includes\get_table.php on line 44 This is the section of code that it is referring to. Line 44 is Quote $tablecolumn .= "<p>" . mysql_field_name($fieldnamesquery_result, $table_field) . "<input type='text' name='" . mysql_field_name($fieldnamesquery_result, $table_field) . "' id='" . mysql_field_name($fieldnamesquery_result, $table_field) . "'/>"; Code: [Select] $tablecolumn = "<form name='insert_table' id='insert_table' action='get_database.php' method='post' > <fieldset> <legend>table information</legend>"; for ($table_field = 2; $table_field < $fieldnamesquery_result; $table_field++) { $tablecolumn .= "<p>" . mysql_field_name($fieldnamesquery_result, $table_field) . "<input type='text' name='" . mysql_field_name($fieldnamesquery_result, $table_field) . "' id='" . mysql_field_name($fieldnamesquery_result, $table_field) . "'/>"; <-----This is line 44 } $tablecolumn .= " <p> <input type='submit' name='submit_info' id='submit_info' /> </p> </fieldset> </form> "; echo $tablecolumn; Similar TutorialsHello everyone. I am wondering how can i give different id's to a html form? Code: [Select] <?php ... if ($numrows!=0) { // fetching data from the database to variable while ($row = mysql_fetch_assoc($query)) { $view_jam = $row['jamname']; $view_recipe = $row['jamrecipe']; $view_rating = $row['jamrate']; $view_owner = $row['owner']; $view_comments = $row['comments']; $view_count = $row['count']; $view_id = $row['id']; $view_count2 = $row['count2']; echo "Jam name: <b>" . $view_jam . "</b><br />"; echo "Jam recipe: " . $view_recipe . "<br />"; echo "Owner: " . $view_owner . "<br />"; echo "Comments: " . $view_comments . "<br />"; echo "Jam Rating: " . $view_rating . "<br />"; [b]echo '<form action="main.php?id=jams" method="POST">[/b] Choose rating <input type="text" name="jamrate" /> <input type="submit" name="submit1" value="Rate"> </form><br /><br />'; ... ?>As you can see, the form is inside a loop. I am trying to build a rating system. When there is only one row in a database then everything goes smoothly, but if there are more, then the rating applies to all rows. I suppose i need to give different id's to the form. How? Thank you All, I'm getting the following error when I work with a class: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /webspace/httpdocs/offers/form_key.php on line 5 The complete code for this is class is: <?php class Form_Key { protected $oldKey; public function __construct() { // Ensure we have an available session if ( NULL == session_id() ) { session_start(); } // Grab our former key for validation if ( isset( $_SESSION['form_key'] ) ) { $this->oldKey = $_SESSION['form_key']; } // Assign the new key $_SESSION['form_key'] = md5( uniqid( mt_rand(), TRUE ) ); } public function isValid() { return 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['form_key'] ) && '' != trim( $_POST['form_key'] ) && '' != trim( $this->oldKey ) && $_POST['form_key'] === $this->oldKey; } public function getKey() { return $_SESSION['form_key']; } public function getOldKey() { return $this->oldKey; } public function render() { return '<input type="hidden" name="form_key" value="' . $_SESSION['form_key'] . '" />'; } public function __toString() { return $this->render(); } } ?> The line that is giving the issue is this line: protected $oldKey; Is it ok just to remove this line?? If I comment it out it gives me the same message but for line 7, which is this one: public function __construct() Anyone have any ideas? Thanks in advance. Hi all, Here's the code I'm using, after opening an IMAP stream to an inbox. The code previous to this opens the inbox, grabs the emails and iterates through them. This bit is checking an individual mail for attachments. Code: [Select] <?php $structure = imap_fetchstructure($mbox, $email_number); $parts = $structure->parts; $fpos=2; for($i = 1; $i < count($parts); $i++) { $message["pid"][$i] = ($i); $part = $parts[$i]; if($part->disposition == 'ATTACHMENT') { // Save the attachment locally to the server // Find the file extension // Save the attachment to DB code here $fpos+=1; } } ?> When I run the script, I get a load of the following reply: Notice: Undefined property: stdClass::$parts in /var/www/html/site/public_html/cron/cron_email_import.php on line XXX Would this mean that there are no actual attachments in the email being processed? Has anyone ever dealt with this function before? All input appreciated. WoolyG What I can Do: Code: [Select] function createDir($path = '/path/to/root/') What I Need To Do: Something like this Code: [Select] $server_root = $_SERVER['DOCUMENT_ROOT']; function createDir($path = $server_root) Or This Code: [Select] function createDir($path = $_SERVER['DOCUMENT_ROOT']) Code: [Select] $Rep = htmlspecialchars($_GET["Rep"]); echo $Rep; The above will print "John Doe & Assoc." (without the quotes) Code: [Select] $result = mysql_query("SELECT RepName FROM Reps WHERE Repname = '".$Rep."'"); $repcount = mysql_num_rows($result); echo $repcount; The above code prints "0" If I delete the first block of code and replace it with Code: [Select] $Rep = "John Doe & Assoc." The second block of code will then return a "1" as it should. Why is one returning a 0 and one returning a 1 when the text in $Rep appears to be identical in both cases? This problem only appears to be occurring when the $Rep value contains an &. My code looks as follows: include('connectvars.php'); /* REGISTER FORM */ // check if submit button has been clicked if (isset($_POST['submit_signup'])) { // process and assign variables after post submit button has been clicked $user_email = strip_tags(trim($_POST['email'])); $firstname = strip_tags(trim($_POST['firstname'])); $lastname = strip_tags(trim($_POST['lastname'])); $nickname = strip_tags(trim($_POST['nickname'])); $password = $_POST['password']; $repassword = $_POST['repassword']; $dob = $_POST['dob']; $find_us_question = strip_tags(trim($_POST['find_us_question'])); // connect to database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $check_query = "SELECT * FROM users WHERE nickname = '$nickname'"; $check_connect = mysqli_query($dbc, $check_query); $check_count = mysqli_num_rows($check_connect); echo $check_count; die(); It's a register (sign up) page, and it's the beginning of the script, the rest of the script is just checking if all fields are a empty and if the input is in the allowed character length etc. I could it off at die(); because the rest doesn't matter. I want the script to check if the username already exists in the database, so I want mysqli_num_rows to tell me how many rows are already there with the same username, and then I want to continue doing an if statement saying if ($check_count != 0) { echo "Username already exists!" } But the mysqli_num_rows doesn't even print out how many rows there are availible, it gives me an error saying: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in... The num_rows function worked in the login script the same way, but for some reason it's not working in the register script. Any ideas, what I'm doing wrong? For testing purposes I just want it to print me "1" when I'm entering a username that's already in the database. Hey.
So the issue I'm having is consecutive loops on semi-large arrays, over and over. Consider this array:
$firstArray = array( 'row1' => array( 'dates' => array( '2014-01-01' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-02' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-03' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-04' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-05' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-06' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-07' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), ) ), 'row2' => array( 'dates' => array( '2014-02-01' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-02' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-03' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-04' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-05' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-06' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-07' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-08' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-09' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), ) ) );Originally the data comes from ~2-3 database tables, of course. But to ilustrate the point, this is how the main array looks like. This array usually contains anywhere between 10-50 rows, each row containing at least 10 dates, with 10 key/values each. And after setting up all the data, it needs to be processed. Currently this is how a friend of mine did it.. $placeDataHere = array(); foreach($firstArray as $key => $dates) { foreach($dates as $date => $values) { foreach($values as $key => $value) { $placeDataHere['DV_' . $date]['SM_' . $key] = 'KS_' . $value; //Followed by another ~50-70 lines of processing the 3 loop's data.. ... ... .... .... .... .... .... .... } } }Obviously this isn't good practise, but we can't seem to figure out a better way of doing it, since both the data and the loops are horribly nested. This loop and setup of $firstArray is run anywhere between 10-20 times/request, due to amount of users we wish to process. So, the result is that this code can take up to over 2-3 minutes to complete, which isn't really optimal performance. In short my question is, are there any better methods of handling this with the data setup we currently have? Hello, this is my first post in this forum, in fact my first post about php. I am developing a crud application, but when i am trying to list a set of results it gives me more that the expected Let me explain. if i print_r my array (which i get it from a sql result) it gives me this Array ( => SHR1 [codprod] => SHR1 [1] => REGULAR SERVICE HOUR [proddescription] => REGULAR SERVICE HOUR [2] => 3.00 [qty] => 3.00 [3] => HR Code: [Select] => HR [4] => 45.0000 [price] => 45.0000 [5] => 0.00 [discount] => 0.00 [6] => 135.00 [amount] => 135.00 ) [/li][/list] if I foreach($detailrow as $value){ echo $detailrow['codprod'] . ", " . $detailrow['proddescription'] . ", " . $detailrow['qty'] . ", " . $detailrow['code'] . ", " . $detailrow['price'] . ", " . $detailrow['discount'] . ", " . $detailrow['amount'] . "<br/>"; } It gives me 14 rows with the same info. I run the query in mysql and it gives me only 1 result as expected. I noticed that the 14 rows are the same quantity of items in the array not results but let say columns, i dont know if it has something to do with the results. My questions: Why it is giving me 14 rows instead just one? What is the $value in the foreach function? why can't i just say foreach($myarray)? why the print_r shows me the items array duplicated using the array position and the item name? Thank you for your help!! So I wrote this piece of code that for the most part works. The problem is two things. One if I print out say $dir[$i] I get 7 directories back. if I try and store that in an array to later be access by some other function I get up to 24+ C's instead of C:/Path... Code: [Select] public function aisis_get_dir_array($dir){ if(!is_array($dir)){ aisis_get_dir($dir); return; } $count = count($dir); for($i = 0; $i<$count; $i++){ if(!is_dir($dir[$i])){ _e('Specified dir' . $dir[$i] . 'is not a directory.'); } $this->directory_list = $dir[$i]; //store these $handler = opendir($dir[$i]); while($file = readdir($handler)){ if($file != "." && $file != ".."){ $this->files[] = $file; } } } return $this->files; } right under the line: $this->directory_list = $dir[$i]; //store these if You put in echo $dir[$i] you get back directories. How ever down in this function: Code: [Select] public function load_if_extentsion_is_php($dir, $array = false){ $list = array(); $list_dir = array(); if($array == true){ $list = $this->aisis_get_dir_array($dir); $list_dir = $this->directory_list; } else{ $list = $this->aisis_get_dir($dir); } $count = count($list); for($i = 0; $i<$count; $i++){ if($array == true){ $countdir = count($this->directory_list); for($j = 0; $j<$countdir; $j++){ echo $list_dir[$j]; //echo $list_dir[$j]; //echo $list[$i]; } } //if(substr(strrchr($list[$i],'.'),1)=="php"){ //echo $list[$i]; //require_once($dir . $list[$i]); //} } } echoing out: echo $list_dir[$j]; gets you up to 24+ C's instead of the directories that are stored. You can view the whole class at Paste bin - there is an expiry: 12 hours. Essentially you call load_if_extentsion_is_php($dir, $array = false) pass it an array of directories and set the array part to true. To Summarize: If you pass in an array of directories you should get back: a echoed list of directories a echoed list of php files belonging in those directories. Currently you get the later and a series of C's for the first. Why? I am trying to split a simple string from my db it is in the format #/# 1/5 2/5 3/3 4/2 etc... I have the following: Code: [Select] echo $value.'<BR>'; $temp=explode('/',$value['field']); print_r($temp); echo '<br>'; when I execute the above (it's in a for loop) I get the following output 1/5 Array ( => 1 ) 2/5 Array ( => 2 ) 3/3 Array ( => 3 ) 4/2 Array ( => 4 ) I am expecting 1/5 Array ( => 1 [1] => 5) for the first entry and so on down the line showing both values after the explode. I have a php page where I have posts about different topic. I have a menu listing all this categories of topics . Some topics may belong to more than one category. So when i click on a particular menu item, the topic belonging to that category will be displayed. While displaying it is in this format---Topic Heading,Belongs to which all categories,date posted and the description. All this are taken from database. Now my actual issue is I am not able to give links to the categories dispalyed ,if the category exceeds more than 1. For eg: Global Warming Posted on March 11,2011 in News, Issue -----------description of global warming goes here. In the above eg: News and issue are the two categories,when i click on News it should display all the items in news category,and when i click on issue it should display all items of issue category. But I am not able to give this link to the categories. Code: [Select] while($row = mysql_fetch_array($q)) { if($row[6]=='News'){ $c='<a href="category_disp.php?category=news">News</a>'; } if($row[6]=='Issues'){ $c='<a href="category_disp.php?category=issues">Issues</a>'; } echo "<tr><td><p >$row[1]</p><br></td></tr>"; echo "<tr><td> <div >". "<p><span>$row[4]</span> <span>". "<a href='$row[6]' >$row[6]|<a href='$row[5]'> Post Comments</a></span></p>". "<p> </p></div><br></td></tr>"; echo "<tr><td><p >$row[2]</p><br></td></tr>"; echo "<tr><td><p ><a href='$row[3]' >Click Here to read more...</a></p></td></tr>"; echo "</div></td></tr>"; } echo" </table> i'm using a dropdown menu to add data to URL in order to run a separate query command depending on result.
url comes in as: index.php?role=ceo
i have the following form:
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="GET" > <select name="role"> <option value="all">ALL</option> <option value="ceo">CEO</option> <option value="coceo">Co-Ceo</option> <option value="director">Director</option> <option value="pos">POS Manager</option> <option value="member">Member</option> </select> <input type="submit" value="Filter Results" /> </form>and the following set of if commands; <?php //Check if it echo role (IT DOES!!) echo $role; // Perform the SQL query //if role is set then add WHERE clause to filter to specific role if (isset($_GET['role'])) { $results = mysql_query('SELECT * FROM `ecmt_memberlist` WHERE role = '. $_GET['role'].' ORDER BY CONCAT(MainToon, Name)'); } //if no role set in url return ALL results! else { $results = mysql_query('SELECT * FROM `ecmt_memberlist` ORDER BY CONCAT(MainToon, Name)'); } $results_array = array(); while ($row = mysql_fetch_array($results)) { $results_array[$row['characterID']] = $row; } ?> Hi,
I have a text area field on one of my forms in order for people to post articles, however, it doesn't work when I try and post HTML through it. It works if I post normal text. Also, PHP won't give me an error, it just doesn't insert it?
<?php if ($_POST['add']) { $title = addslashes($_POST['title']); $image = htmlspecialchars($_POST['image']); $source = mysql_real_escape_string($_POST['source']); $active = $_POST['active']; $feature = $_POST['feature']; $cat_id = $_POST['cat_id']; $content = htmlspecialchars($_POST['content']); $months = array( "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); $date = date('d', time()) . ' ' . $months[date('n', time())] . ' ' . date('Y', time()); if ($title == NULL || $image == NULL || $content == NULL) { echo '<br /><br /><center>Please, fill all inputs</center><br /><br />'; } else { $add = "INSERT INTO `news` cat_id='$cat_id', title='$title', image='$image', content='$content', date='$date', author='".$user['admin']."', authorid='".$user['id']."', source='$source', active='$active', twitter='".$user['twitter']."', featured='$feature'" or die(mysql_error()); $sql = mysql_query($add); $addgrowl = "INSERT INTO `growl` (toid, message) VALUES ('$id', 'Your article is now online!')"; $sql = mysql_query($addgrowl); echo '<script type="text/javascript"> window.location = "articles.php" </script> '; } } ?>Help :-( I can't figure out how I'm messing up so badly. Anyway, I have:
$con=mysqli_connect("removedforsecurity"); $finderCleanup = mysqli_query($con, "SELECT * FROM Entries ORDER BY PID DESC LIMIT 1"); $finderCleanupArray = mysqli_fetch_array($finderCleanup); $integerCleanup = $finderCleanupArray['PID'] - 40; $lastPID = $finderCleanupArray['PID']; $lastPIDreduced = $finderCleanupArray['PID'] - 8;When I var_dump $lastPID, it returns INT with a number (it works correctly.) Then, I have this: function getResults($con,$lastPIDreduced)$con works correctly in the function, but $lastPIDreduced is "undefined." What is my sin? Thanks. I have been using some CSS written by Matthew Taylor (www.http://matthewjamestaylor.com), for displaying my web page on iPad orsimilar device. It works in most cases but for some reason it gives strange results when I try to output a table in the main screen area.
It puts the title heading in the right place, but the table for some reason underneath the footer and the page menu disappears completely.
It is usually caused by unclosed div tags, but I have checked them and they appear to be correct.
There is a good explaination of how the CSS works on his web site.
Here is the code for the PHP/HTML:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)"> <meta name="dcterms.created" content="Sat, 02 Mar 2013 20:21:23 GMT"> <meta name="description" content=""> <meta name="keywords" content=""> <meta name="viewport" content="width=768px, minium-scale=1.0, maximum-scale=1.0" /> <title></title> <link rel="stylesheet" href="stylesheets/ipad.css" /> <!--[if IE]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div id="fb-root"> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script></div><!--end fb-root--> <div id="wrap"> <!--Start wrap--> <div id="header"> <!--Start header--> <img src="images/Head!.png" width="100%" height="150px" alt="" title="" border="0" /> <h1>1066 cards4U</h1> </div><!-- end header --> <div id="content"> <!--Start content--> <div id="main"> <!--Start main--> <h3>Statistics for <? echo $Country; ?> in 2014</h3> <h4>If only the header is shown, there is no data for this country</h4> <?php include('connect_visits.php'); doDB7(); $limitStart = $_POST['QUARTER'] - 13; $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.CID = '{$_POST['country']}' ORDER BY ctryvisits.WNo LIMIT {$limitStart}, 13"; $Visit_data_res = mysqli_query($mysqli, $Visit_data) or die(mysqli_error($mysqli)); $display_block = " <table width=\"20%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"white\" > <tr> <th>Week No</th> <th>Week Commencing</th> <th>Visits</th> </tr>"; while ($C_info = mysqli_fetch_array($Visit_data_res)) { $Cid = $C_info['WNo']; $Visits = ($C_info['CVisits']); $WeekNo = ($C_info['WCom']); //add to display $display_block .= " <tr> <td width=\"1%\" valign=\"top\">".$Cid."<br/></td> <td width=\"8%\" valign=\"top\">".$WeekNo."<br/></td> <td width=\"5%\" valign=\"top\">".$Visits."<br/></td> </td></tr>"; } mysqli_free_result($Visit_data_res); $CNo2Cty ="SELECT CID, Country FROM Countries WHERE CID='{$_POST['country']}'"; $CNo2Cty_res =mysqli_query($mysqli, $CNo2Cty) or die(mysqli_error($mysqli)); if (mysqli_num_rows($CNo2Cty_res)<1){ $display_block="<p><em>Invalid Country, Please try again</em></p>"; } while ($C_name = mysqli_fetch_array($CNo2Cty_res)) { } mysqli_free_result($CNo2Cty_res); //mysqli_close(mysqli); ?> <?php echo $display_block; ?> <div class="fb-comments" data-href="http://www.1066cards4u.co.uk" data-width="470"></div><br /> <div class="fb-like" data-href="http://www.1066cards4u.co.uk" data-send="true" data-layout="box_count" data-width="300" data-show-faces="true" data-font="arial"></div> <!-- end fb-like --> </div> <!--end main--> <div id="side"> <!--Start side--> <div id="sidea"> <!--Start sidea--> <h3>Main Menu</h3> <p><ul> <li><a href="index1.html">Home</a></li> <li><a href="iLinks.html">Links</a></li> <li><a href="iTechniques.html">Techniques</a></li> <li><a href="iVerse_Menu.html">Verse's</a></li> <li><a href="icontact.html">Contact Us</a></li> <li><a href="iblog.php">Blog</a></li> <li><a href="iAboutUs.html">About Us</a></li> <li><a href="iGallery.html">Gallery</a></li> <li><a href="iStats_Menu.html">Stats</a></li> <li><a href="iRelHol_Menu.html">Religious Holiday's</a></li> <li><a href="iSub_form.html">Subscribe to Newsletter</a></li> </ul></p> </br> </div> <!--end sidea--> <div id="sideb"> <!--Start sideb--> </div> <!--end sideb--> <div id="sidec"> <!--Start sidec--> </div> <!--end sidec--> </div> <!--end side--> </div> <!--end content--> <div id="footer"> <!--Start footer--> <p>© 2012 Content:1066 Cards 4U. All rights reserved. <br /> With thanks to Matt Taylor - matthewjamestaylor.com</p> </div> <!--end footer--> </div> <!--end wrap--> </body> </html>Here is the CSS: * { margin:0; padding:0; } h2 { padding:1em 0 0 0; } p { line-height:1.4em; } p + p { text-indent:2em; } body { font-size:100%; text-align:center; background:#ddd; } pre { display:block; margin:1em 0 0 0; width:488px; } pre code { background:#eee; display:block; padding:10px; } .r { float:right; padding:0 0 10px 20px; } /* Landscape mode (default) */ #wrap { margin:0 auto; width:1024px; position:relative; overflow:hidden; text-align:left; background:#fff; } #header { float:left; width:1024px; padding:10px 0 20px 0; background:#fff; border-bottom:1px solid #000; } #header h1 { padding:10px 30px 0 30px; } #header p { padding:0 30px; line-height:1.4em; } #content { float:left; width:1024px; background:#eee; position:relative; left:768px; } #main { float:left; width:708px; position:relative; right:738px; padding:20px 0; } #side { float:right; width:216px; position:relative; right:788px; padding-bottom:20px; } #sidea, #sideb, #sidec { clear:left; float:left; width:216px; } #footer { clear:both; float:left; width:1024px; border-top:1px solid #000; background:#ddd; } #footer p { padding:20px 30px; } @media only screen and (orientation:portrait){ /* portrait mode */ #header, #wrap, #footer { } #content { left:0; background:#fff; } #main { float:left; width:708px; position:relative; right:0; left:30px; padding:20px 0; } #side { clear:left; float:left; width:768px; right:0; padding-bottom:20px; background:#eee; } #sidea { clear:none; width:216px; float:left; position:relative; left:30px; padding-top:20px; } #sideb { clear:none; width:216px; float:left; position:relative; left:60px; padding-top:20px; } #sidec { clear:none; width:216px; float:right; position:relative; right:30px; padding-top:20px; } #footer { position:absolute; bottom:0; width:100%; height:60px; /* Height of the footer */ background:#6cf; width:768px; } }I have spent hours trying different things, but I can't find a solution. I believe its a CSS problem, but if you think it is HTML can the moderator move it? Your help would be appreciated. Am trying to redirect a user based on their login details. it works fine till it get to a particular department.. "Marine Logistics". when i try to log in with ID of someone in that department, it redirects to invalid login page. the code below. what am i missing?
$sql1 = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'"); $data = mysql_fetch_array($sql1); $department = $data['department']; if ($department== "Admin") { header("Location: admin/dash_admin.php"); exit; } else if ($department == "ICT" ) { if ($data['position'] == "HOD") { header("Location: ICT/HOD/hod_dash.php"); exit; } else{ header("Location: ICT/staff/staff_dash.php"); exit; } exit; } // check if user is in account department else if ($department == "Account" ) { if ($data['position'] == "HOD") { header("Location: account/HOD/account_dash.php"); exit; } else { header("Location: account/staff/staff_dash.php"); exit; } exit; } //check if user is in Supply chain/ Asset Integrity department else if ($department == "Supply Chain/ Asset Integrity" ) { if ($data['position'] == "HOD") { header("Location: supply_chain/HOD/hod_dash.php"); exit; } else{ header("Location: supply_chain/staff/staff_dash.php"); exit; } exit; } // check if user is in manpower department else if ($department == "Manpower" ) { if ($data['position'] == "HOD") { header("Location: manpower/HOD/hod_dash.php"); exit; } else{ header("Location: manpower/staff/staff_dash.php"); exit; } exit; } // check if user is in Business Development Department else if ($department == "Business Development" ) { if ($data['position'] == "HOD") { header("Location: business_development/HOD/hod_dash.php"); exit; } else{ header("Location: business_development/staff/staff_dash.php"); exit; } exit; } // check if user is in HR else if ($department == "HR" ) { if ($data['position'] == "HOD") { header("Location: HR/HOD/hod_dash.php"); exit; } else{ header("Location: HR/staff/staff_dash.php"); exit; } exit; } //check if user is in Marine Logistics Department else if ($department== "Marine Logistics" ) { if ($data['position'] == "HOD") { header("Location: logistics/HOD/hod_dash.php"); exit; } else{ header("Location: logistics/staff/staff_dash.php"); exit; } exit; } //check if user is from Maintenance Department else if ($department == "Maintenance" ) { if ($data['position'] == "HOD") { header("Location: Maintenance/HOD/hod_dash.php"); exit; } else{ header("Location: Maintenance/staff/staff_dash.php"); exit; } exit; } //check if user is from Admin/services Department else if ($department == "Admin / Services" ) { if ($data['position'] == "HOD") { header("Location: admin_services/HOD/hod_dash.php"); exit; } else{ header("Location: admin_services/staff/staff_dash.php"); exit; } exit; } } else{ header("Location: indexWrongPassOrUser.php"); exit; } Hello, All the names in database are uppercase. Would like to run string formating functions before displaying them. Code: [Select] $name = ucfirst(strtolower($results[$i]['name'])); It turns everything nicely into lowercase but doesn't capitalize the first letter. Why could that be? Best regards, laanes Hey guys, I am just wondering what method is used to give my PHP loop lists there own page based on the same template for each one.
A perfect example of this is eBay, if you look at the listing pages they then link to the actual product pages. I am just wondering how I can do this?
Here is my code setup:
<?php while($row = $results->fetch(PDO::FETCH_ASSOC)) { echo ' <div class="listing-container"> <h3 class="model-listing-title clearfix">'.$row["Make"].' '.$row["Model"].' '.$row["Variant"].'</h3> <h3 class="price-listing">£'.number_format($row['Price']).'</h3> </div> <div class="listing-container-spec"> <img src="'.(explode(',', $row["PictureRefs"])[0]).'" class="stock-img-finder"/> <div class="ul-listing-container"> <ul class="overwrite-btstrp-ul"> <li class="diesel-svg list-svg">'.$row["FuelType"].'</li> <li class="saloon-svg list-svg">'.$row["Bodytype"].'</li> <li class="gear-svg list-svg">'.$row["Transmission"].'</li> <li class="color-svg list-svg">'.$row["Colour"].'</li> </ul> </div> <ul class="overwrite-btstrp-ul other-specs-ul h4-style"> <li>Mileage: '.number_format($row["Mileage"]).'</li> <li>Engine size: '.$row["EngineSize"].'cc</li> </ul> <button href="#" class="btn h4-style checked-btn hover-listing-btn"><span class="glyphicon glyphicon-ok"></span> History checked </button> <button href="#" class="btn h4-style more-details-btn hover-listing-btn tst-mre-btn"><span class="glyphicon glyphicon-list"></span> More details </button> <button href="#" class="btn h4-style test-drive-btn hover-listing-btn tst-mre-btn"><span class="test-drive-glyph"></span> Test drive </button> <h4 class="h4-style listing-photos-count"><span class="glyphicon glyphicon-camera"></span> 5 More photos</h4> </div> '; } ?> </div>So as you can see I am using PDO to fetch this data from my database and sort the results to list every row of the SQL table into the HTML template I have made and is then looped. My question is how can I give each row in my SQL table it's own page just like the eBay example I mentioned? Does anyone know of any useful tutorials to achieve this or any examples of how this is done? Thanks Hello, i just install LAMP server. wrote simple code <?php #error_reporting(E_ALL); #printf "hello"; print "print_keyword."; ?>but in browser, it does not show me an error. i m using linux envionment. plz help. any help would be appriciable. |