PHP - Ipad Css Giving Unexpected Results
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. Similar TutorialsI'm working to make my code more portable when moving it between servers. I am trying to use the $_SERVER['SERVER_NAME'] global variable to change the page's URL whenever I move it. Code: [Select] <a href="<?php print $_SERVER['SERVER_NAME'].'/index.php';?>">LINK TO SERVER'S HOME PAGE</a> This line is in a php page with this URL, http://localhost/php/tests/link_test.php However this is acting unexpectedly. The current directory of the file is being added before the server name and the link becomes, http://localhost/php/tests/localhost/index.php What am I doing wrong? Chris If there are two DataTime's which are exactly X seconds apart and the difference between those two DateTime's is added to a third DateTime, then the third DataTime's timestamp would change by exactly X seconds, true? Then why doesn't the second test below show those results, but is off by 1 day? <?php function test(string $start, string $end, string $newStart) { $startDt = new \DateTime($start); $endDt = new \DateTime($end); $intervalDt=$startDt->diff($endDt); $startSeconds=$startDt->getTimestamp(); $endSeconds=$endDt->getTimestamp(); $seconds = $endSeconds - $startSeconds; $dt = new \DateTime($newStart); $newStartSeconds=$dt->getTimestamp(); $dt->add($intervalDt); $newEndSeconds=$dt->getTimestamp(); $newSeconds = $newEndSeconds - $newStartSeconds; $newEnd = $dt->format(\DateTime::RFC3339); echo("original: $start => $end $endSeconds - $startSeconds = $seconds seconds<br>"); echo("new: $newStart => $newEnd $newEndSeconds - $newStartSeconds = $newSeconds seconds<br>"); echo("Error: seconds - newSeconds = ".($seconds - $newSeconds)); } test("2017-06-26T00:00:00Z", "2017-07-09T00:00:00Z", "2018-03-05T00:00:00Z"); echo('<br><br>'); test("2017-12-08T00:00:00Z", "2018-02-15T00:00:00Z", "2018-03-05T00:00:00Z");Quote
original: 2017-06-26T00:00:00Z => 2017-07-09T00:00:00Z 1499558400 - 1498435200 = 1123200 seconds
I have the following four tables. The query below is supposed to retrieve all projects and related data in associated tables where the project has been archived (i.e., archive field in project_info table set to '1') and user ID = '599zxj'. http://buildmyweb.org/testing/starter/
at the link above, you can see a test-page. the problem im having is that the content in the footer gets cutoff on the right side of the footer when viewed in an ipad. id love to hear it if anyone can figure out why
here is the html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="keywords" content = "Under Construction" /> <meta name="description" content="is currently Under Construction." /> <title>Under Construction</title> <link rel="stylesheet" type="text/css" href="bmw_footer_abs.css" /> </head> <body id="page_home"> <div id="wrapper"> <div id="banner"> </div> <!-- close banner --> <div id="main"> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> <!-- close main --> </div> <!-- close wrapper --> <div id="footer"> <div id="footer_content"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> <!-- close footer_content --> </div> <!-- close footer --> </body> </html>and the css: html { position: relative; min-height: 100%; } body { margin: 0 0 100px; /* bottom = footer height */ } #footer { position: absolute; left: 0; bottom: 0; height: 100px; width: 100%; min-width:1000px; background:gray; } #wrapper { position:relative; top:0px; margin:0 auto; width:1000px; text-align:left; background:pink; padding:0px; } /* **************** BANNER *************** */ #banner { float:left; background:green; width:100%; height:10px; } /* **************** MAIN *************** */ #main { float:left; width:100%; background-color:#f0f3f8; } /* **************** FOOTER *************** */ #footer { font-size:85%; line-height:1.3; } #footer_content { width:1000px; margin:0px auto; background:orange; } Hi Guys,
I have a navigation menu that works great on a desktop however on a mobile or touch screen device the navigation menu doesn't seem to pause when i click on the drop down menu. Any help with a solution to this?
index.php with menu
<div class="header"> <div class="nav"> <ul class="drop-menu"> <li><a class="first current" href="#"><span class="first-border-left"> </span>home</a></li> <li><a href="#" title="About Us">about us</a> <ul> <li><a href="#" title="Latest News">Latest News</a></li> <li><a href="#" title="Why choose us">Why choose us</a></li> <li class="end"><a href="#" title="Mission Statement">Mission Statement</a></li> </ul> </li> <li><a class="last" href="#" title="Contact Us"><span class="first-border-right"> </span>Contact Us</a></li> </ul> </div> </div>css file .header .nav {min-height:58px; position:absolute; top:193px; z-index:6;} .drop-menu { margin:0 0 0 0px; padding:0 0 0 0px; list-style: none; width:940px; font-size:14px; line-height:58px; text-transform:uppercase; } .drop-menu li a { text-decoration:none; color:#fff; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; width:146px; text-align:center; display:block; border-right:1px solid #616161; background:url(menu-tail.gif) 0 0 repeat-x #0c2362; } .drop-menu li a:hover { color:#fff; background:url(menu-hover.gif) 0 0 repeat-x #0c2362; } .drop-menu li.dropHover a { background:url(menu-hover.gif) 0 0 repeat-x #0c2362; } .drop-menu a.current { color:#3e3e3e; background:url(menu-active.png) 0 0 repeat-x #d8d6d6; border-top:none; } .drop-menu li.dropHover a.current { color:#3e3e3e; background:url(menu-active.png) 0 0 repeat-x #d8d6d6; } .drop-menu ul { position: absolute; top: -999em; background:url(submenu-tail.png) 0 0 repeat !important; } .drop-menu ul li { width: 100%; } .drop-menu li:hover { visibility: inherit; } .drop-menu li { position: relative; background:none; float:left; line-height:58px; height:58px; } .drop-menu li li { font-size:12px; height:40px; line-height:40px; background:url(menu-spacer.gif) center bottom no-repeat; } .drop-menu li .end { border:none; background:none; } .drop-menu li li a { font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-weight:bold; color:#fff; line-height:40px; height:40px; width:188px; overflow:hidden; display:block; border:none; background:none !important; } .drop-menu li li li { height:34px; line-height:34px; } .drop-menu li li a:hover, .drop-menu li li.dropHover a { color:#038ee7; } .drop-menu li li li a { height:34px; width:200px; font-size:12px; padding:0; margin:0; color:#fff !important; text-align:center; line-height:34px; border:none; background:url(menu-spacer.gif) center bottom no-repeat; } .drop-menu li li li a:hover { color:#038ee7 !important; } .drop-menu li li li li { height:34px; line-height:34px; } .drop-menu li li li li a { height:34px; width:200px; font-size:12px; padding:0; margin:0; color:#0c2362 !important; text-align:center; line-height:34px; border:none; background:url(menu-spacer.gif) center bottom no-repeat; } .drop-menu li li li li a:hover { color:#038ee7 !important; } .drop-menu a { display: block; position: relative; } .drop-menu li:hover ul, .drop-menu li.dropHover ul { left: -1px; top: 58px; z-index: 99; } ul.drop-menu li:hover li ul, ul.drop-menu li.dropHover li ul { top: -999em; } ul.drop-menu li li:hover ul, ul.drop-menu li li.dropHover ul { left: 188px; top: 0; } ul.drop-menu li li:hover li ul, ul.drop-menu li li.dropHover li ul { top: -999em; } .drop-menu .first { width:84px; border-right:1px solid #616161; position:relative; } .drop-menu .first span.first-border-left { width:6px; height:58px; float:left; background: url(nav_left.png) top left no-repeat; } .drop-menu .last span.first-border-right { width:6px; height:58px; float:right; background: url(nav_right.png) top right no-repeat; } .drop-menu .last { width:120px; border-right:none; position:relative; } My php and MySQL scripting works perfectly, but when someone enters data into the php form, using an iPad with Safari browser, all number entries are inserted into the database table incorrectly. It is still a number entry but the number differs substantially from the original input. Note: All other entries, where the individual selects something from a drop-down list and date selecter works perfectly from the same form. Please help me here, since at least 70% of my employees use iPads, thus I need to find a cure for this problem ASAP. Thanks in advance for any help offered. JayDude Hello 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 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; 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. 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']) 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 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 &. 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,
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'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; } ?> 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> 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? |