PHP - Need Help Getting My Side Nav To Work With Loops (depending On Top Nav)
Hello.
I recently posted about getting my top nav to work which it does now (with thanks) but im having trouble getting my side navs to work. i have tried various things but i think its just a case of getting the where clause right. see what you think. any help would be great these are my files. includes/navL1.php - which does the top navigation includes/navL2.php - which does the left navigation main includes/navL3.php - which does the left navigation sub admin/layouts/admin_topnav.php admin/layouts/admin_leftnav.php admin/layouts/index.php ok so. admin topnav.php code looks like this and works Code: [Select] <?PHP require_once("../includes/initialize.php"); global $topNav; global $pageName; ?> <div id="navWrapper"> <?PHP $topNav = navL1::find_all(); ?> <div id="ddtabs3" class="solidblockmenu"> <ul> <?PHP foreach($topNav as $topNavs): ?> <li><a <?PHP echo ($pageName == $topNavs->title ? 'class="selected"' : '')?> href="<?PHP echo $topNavs->title; ?>.php" id="<?PHP echo $topNavs->title; ?>"><?PHP echo $topNavs->title; ?></a></li> <?PHP endforeach; ?> </ul> </div><!-- #ddtabs3--> </div><!-- #navWrapper--> now i need when a top nav is selected i need the correct left nav main and subs to show. this is how my left nav looks at the moment Code: [Select] <?PHP require_once("../includes/initialize.php"); global $topNav; global $pageName; ?> SOME ACCORDION SCRIPT GOES HERE <div class="arrowlistmenu"> <?PHP $nav1 = navL1::find_all(); $nav2 = navL2::find_by_nav(); $nav2 = navL2::find_by_nav(); ?> <?PHP foreach($nav2 as $nav2s): ?><h3 class="menuheader expandable"> // MAIN LEVEL <li><a <?PHP echo ($pageName == $nav2s->title ? 'class="selected"' : '')?> href="<?PHP echo $nav2s->title; ?>.php" id="<?PHP echo $nav2s->title; ?>"><?PHP echo $nav2s->title; ?></a></li></h3> <?PHP endforeach; ?> // SUB LEVEL <ul class="categoryitems"> <?PHP foreach($nav3 as $nav3s): ?> <li><a <?PHP echo ($pageName == $nav3s->title ? 'class="selected"' : '')?> href="<?PHP echo $nav3s->title; ?>.php" id="<?PHP echo $nav3s->title; ?>"><?PHP echo $nav3s->title; ?></a></li> <?PHP endforeach; ?> </ul> </div><!-- #End arrowlistmenu --> <img src="images/wrapper/loading.gif" alt="loading..." id="Pageloading" height="28" width="28" style="visibility:hidden;float:left;" /> this is the code im trying to get to work in my includes files that i can seem to get my head around includes/navL2.php Code: [Select] public static function find_by_nav(){ global $database; global $topNav; $sql = "SELECT * FROM ".self::$table_name." WHERE title="$topNav" LIMIT 1"; $result_array = self::find_by_sql($sql); return !empty($result_array) ? array_shift($result_array) : false; } the find_by_sql($sql) looks like this but i dont think you need it Code: [Select] public static function find_by_sql($sql){ global $database; $results_set = $database->query($sql); $object_array = array(); while($row = $database->fetch_array($results_set)){ $object_array[] = self::instantiate($row); } return $object_array; } im trying to use the same code to pull the sub levels inside includes/navL3.php if any of this makes sense please could you point out whats wrong thanks ricky Similar Tutorials I’m trying to write a post-panel where the user can see the preview of his post to the right of the text area he’s writing into. I tried the following into a file called writepost.php : <?php $text=(isset($_GET['message']))?$_GET['message']:''; $formatted_text=nl2br(stripslashes(htmlspecialchars($text))); echo '<form method="post" action="proceedtopost.php?>'. '<table>'. '<td style width="50%"><tr>'. '<fieldset> Write your post here : <br> <textarea cols="50" rows="12" '. 'id="message" name="message">'.$text.'</textarea>'. '</fieldset> <p> '. '<input type="submit" name="submit" formaction="writepost.php" value="Preview" /> '. '<input type="submit" name="submit" value="Sent" /> '. '</p>'. '</td>'. '<td>'. '<fieldset> Your post will appear as follows :<br><p> '. $formatted_text. '</fieldset>'. '</td></tr>'. '</table>'. '</form>';There are several things wrong with this code : 1) When the user hits the "Preview" button, I expect writepost.php to be reloaded (this is what happens), and the current content of the textarea to be stored in $_GET['message'] (this is not what happens). 2) Why does my browser output the preview part under the text area (or in other words outputs the HTML table as a single column of two cells), when I insist in my HTML code for the table to be displayed as a single row ? I have a web portal which is scripted using client side scripting language i.e HTML. I want to create a login page in .php and want the other pages to be in .hmtl. Can i do so? I want to do this because i want the login password to be stored in a database. Also I want the password to get encrypted (by either MD5 javascript or OpenSSL ) when user enters it inside the login form. I cannot create the entire portal in php because my portal makes use of C code. And php doesn't have an interface with C language. Can a user get directed to a .html page after a secure login from login.php page ? My main aim is to secure the access to my web portal using a password. I tried to authenticate the login using javascript where the password was stored in an array. But i feel any one having moderate knowledge can easily break that password. Any help would be greatly appreciated!! need a little help guys! I use the script below to display profile images, trouble is it shows 1 on top of the other, and i need it to double up 2 profile images on top of 2 profile images ect any ideas how i can do this. require("./include/mysqldb.php"); $con = mysql_connect("$dbhost","$dbuser","$dbpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$dbame", $con); $result = mysql_query("SELECT * FROM Search_profiles_up WHERE upgrade_one ='1' ORDER BY RAND() LIMIT 40"); print "<table width=\"293\" height=\"111\" border=\"0\"> <tr>\n"; while($row = mysql_fetch_array($result)) { print "<td width=\"142\"><img src=" . $row['search_small_image'] . " width=\"144\" height=\"169\" /></td>\n"; print " </tr>\n"; print " <tr> \n"; print "<td>" . $row['star'] . "</td>\n"; print " </tr>\n"; print " <tr>\n"; print "<td>" . $row['username_search'] . "</td>\n"; print " </tr>\n"; print " <tr> \n"; print "<td>" . $row['phone_search'] . "</td>\n"; print " </tr> \n"; } print "</table>"; mysql_close($con); ?> is it true that all the server side code runs before the client side code when accessing a webpage? if that is true, what about PHP code that is embedded inside HTML tags? wouldn't that result in an error a lot of times? I have a few tables in php and want them to be side by side instead of under each other like below. I have spent about 2 days trying to figure it out, Anyone got a clue? This is the code im using <?php $con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("People", $con); $result = mysql_query("SELECT * FROM wang"); echo "<table border='1'> <tr> <th>Wang Total Report</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['got'] . "</td>"; echo "</tr>"; } echo "</table>"; $result2 = mysql_query("SELECT * FROM miah"); echo "<table border='1'> <tr> <th>Miah Total Report</th> </tr>"; while($row = mysql_fetch_array($result2)) { echo "<tr>"; echo "<td>" . $row['got'] . "</td>"; echo "</tr>"; } echo "</table>"; $result3 = mysql_query("SELECT * FROM vinc"); echo "<table border='1'> <tr> <th>Vinc Total Report</th> </tr>"; while($row = mysql_fetch_array($result3)) { echo "<tr>"; echo "<td>" . $row['got'] . "</td>"; echo "</tr>"; } echo "</table>"; $result4 = mysql_query("SELECT * FROM ketarie"); echo "<table border='1'> <tr> <th>Ketarie Report</th> </tr>"; while($row = mysql_fetch_array($result4)) { echo "<tr>"; echo "<td>" . $row['got'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Alright, so meanwhile i wait for answer on the other thread i started another project, to fix the menu... but it was a bit confusing so now i ask you again!... Heres my current menu.php Code: [Select] <?php include "config.php"; if (!$_SESSION["valid_user"]) { echo '<a href="login.php">' . 'Login <br/><br/>' . '</a>'; } if ($_SESSION["valid_user"]) { echo '<a href="logout.php">' . 'Logout <br/><br/>' . '</a>'; echo '<a href="members.php">' . 'Control Panel <br/><br/>' . '</a>'; } echo '<a href="memberlist.php">' . 'Members <br/><br/>' . '</a>'; echo '<a href="ranking.php">' . 'Rankings <br/><br/>' . '</a>'; ?> Now it works perfectly when logged in, but when you logout the session dies, leaving me with this: Notice: Undefined index: valid_user in C:\wamp\www\kawaii\menu.php on line 5 Login Notice: Undefined index: valid_user in C:\wamp\www\kawaii\menu.php on line 10 Members Rankings Now, how can i make a login that depends on if your logged in if this happens when you logout..., i hope someone can find a solution that can work out i have a small search profile search and need to set $getuname variable to users username if((trim($country) !== ''&&($state) !== ''&&($city) !== '')){ $data = mysql_query("SELECT * FROM users WHERE users.state='$state' AND users.country='$Country' AND users.city='$city' ORDER BY RAND() DESC LIMIT 1 "); Echo "Country city state search"; $getuname = mysql_real_escape_string($_GET['username']); am i meant to use the get or is that only for forms? Is there a way to query some information depending on if a table field DOES NOT include a specific value? I've got a table that contains over 100 locations. I want to organize the data on the frontend by country (specifically US and International). How would I go about filtering out locations that DO NOT belong in USA? $q = "SELECT * FROM table WHERE COUNTRY='USA'"; Hi all, I am trying to produce a script that will send out an email but the user can basically choose how often they get this email... I want to give them the option of daily, weekly and monthly. I have the logic down on paper and in plain English it seems to make sense but I am having a hard time converting this to code: My logic is: 1. find out how often they want to get the email (we will call this frequency, as thats what my database field is called) 2. drag out last updated timestamp (this is called last_updated and is a unix timestamp) 3. some form of compare i.e. if frequency is weekly and $today is 7 days after last reminded alert them as I say this makes sense in plain English but I'm having a hard time converting it... this is what I have come up with so far: Code: [Select] <?php // Connect include("../connect.php"); $query = "SELECT * FROM resumes_bak WHERE jobseekerid = '2610'"; $result = mysql_query($query) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { $current_timestamp = time(); echo "Current Timestamp: ".$current_timestamp; echo "<br /><br />"; $frequency = $row['frequency']; echo "Frequency is: ".$frequency; echo "<br /><br />"; $lastReminded = $row['last_reminded']; echo "Last reminded: ".$lastReminded; echo "<br /><br />"; $daily = strtotime('+1 day', $lastReminded); echo "One day forward: ".$daily; echo "<br />"; $weekly = strtotime('+1 week', $lastReminded); echo "One week forward: ".$weekly; echo "<br />"; $monthly = strtotime('+1 month', $lastReminded); echo "One month forward: ".$monthly; echo "<br /><br />"; if($frequency = 'daily' && /* I THINK I NEED ADDITIONAL CLAUSES IN HERE TO DO THE COMPARISON */ ) { echo "I am daily"; } elseif ($frequency = 'weekly') { echo "I am weekly"; } else { echo "I am monthly"; } } ?> Can anybody help me on my way here, I seem to have hit a wall! Many thanks, Greens85 Did PHP a few years ago and for the life of me i can't work out why this doesn't work: Code: [Select] for ( $counter2=1; $counter2 < 1000; $counter2++) { for ( $counter1=1; $counter1 < 1000; $counter1++) { echo "Fixed bug"; } } and yet this does Code: [Select] for ( $counter2=1; $counter2 < 100; $counter2++) { for ( $counter1=1; $counter1 < 100; $counter1++) { echo "Fixed bug"; } } I tested it because I have a rather large amount of data to retrieve from an XML file and i kept receiving errors I do not have the option that I know of to do a LIMIT 10 in my odbc query. How can I get it to count the number of while loops and stop at 10? Code: [Select] while (odbc_fetch_row($rs)) { } Hello everyone, I've already posted a question trying to resolve my problem, but I've changed my code so much, I figured it may be best just to post a new thread with a better explanation of what I'm trying to do. Anyway, here's what I've got: I have a database with 2 tables: products and reservations. I have 3 products for now, that can be reserved for any date. I'm trying to create a page that will display all of the available products for a specific date. The user selects the date they want to check, and then the code should check their selected date and compare it with the database to display everything that is available on that date. The database looks like this: Products Table: prodid prodname 01 item 1 02 item 2 03 item 3 Reservations Table: prodid resdate 01 02/22/2012 01 02/23/2012 03 02/22/2012 Here is the code that I have now: Code: [Select] <?php $resultres = mysql_query("SELECT `prodid` FROM reservations WHERE `resdate` = '$resdate'") or die (mysql_error()); while ($rowres = mysql_fetch_row($resultres)) { $resprodid = $rowres[0]; $resultavail = mysql_query("SELECT `prodid` FROM products WHERE `prodid` != '$resprodid'") or die (mysql_error()); while ($rowavail = mysql_fetch_row($resultavail)) { $prodid = $rowavail[0]; echo $prodid; echo $proname; } } ?> When I select 02/21/2012, I get no results, where I should get all three products as a result, because none of them are reserved on this date. When I select 02/22/2012, I get a result of these products, in this order: 02, 03, 01, 02. I should get a result of ONLY 02, because this is the only product that isn't reserved for this date. When I select 02/23/2012, I get a result of 02 and 03, which in this case would be the correct return, because 01 is the only one reserved for this date. Any idea what I'm doing wrong here and how to fix it? Any help is GREATLY appreciated! Hi All, and thanks for your help on my last problem now solved. What i am doing is building a job site and it needs info put in from job seekers regarding their qualifications. Some will have 2 some may have 10 and so on. I need to set up a system that I can put say 10 text boxes in a form that can then go in a MySQL. I only want the filled out boxes to go into the database and not the ones left blank. I have no idea as to where to start with but I think I need to loop through until it comes to the last filled out box but not enter the blank text boxes. i have no idea where to start on this one so if any one has thoughts on this it would be great. Thank you all for your help in the past. i am a student and trying to figure out why this is not working for me i am trying to pull from my .txt file and add the lines. $numOrders should be 20 and $numCopies should be 52. it keeps telling me --Warning: feof() expects parameter 1 to be resource, string given on line 25. i really am having big trouble trying to understand how to use the while loop for this. any help would be great. here is my html code <html> <head> <title>Software1</title> <link rel ="stylesheet" type="text/css" href="sample.css" /> </head> <body> <h1>SOFTWARE ORDERS: REPORT</h1> <form action = "software1Boles.php" method = "post" > <p><input type = "submit" value = "Display the Report" /></p> </form> </body> </html> my php code <?php $totalCopies = $_POST['totalCopies']; $totalOrders = $_POST['totalOrders']; $nextOrder = $_POST['nextOrder']; $totalCopies = 0; $totalOrders = 0; $orderFile = fopen("ordersBoles.txt", "r"); $nextOrder = fgets ($orderFile); while (!feof($nextOrder)) { list($totalCopies, $totalOrders) = explode (":", $nextOrder); if ($totalCopies >=1 and $totalCopies >=1) { $totalCopies = $totalCopies + $nextOrder; $totalOrder = $totalOrder + $nextOrder; } $nextOrder = fgets($orderFile);} fclose($orderFile); print ("<h1>SOFTWARE ORDERS: REPORT</h1>"); print ("<p>TOTAL COPIES ORDERED: $totalCopies</p>"); print ("<p>TOTAL ORDERS: $totalOrders</p>"); ?> </body> </html> and my .txt file 1 Linux:1 2 Macintosh:1 3 Windows:1 4 Macintosh:1 5 Macintosh:2 6 Linux:5 7 Macintosh:10 8 Windows:10 9 Macintosh:1 10 Windows:1 11 Windows:1 12 Linux:1 13 Macintosh:5 14 Linux:4 15 Windows:1 16 Macintosh:1 17 Windows:1 18 Linux:2 19 Macintosh:2 20 Windows:1 21 anything you can give me would help alot, thanks Hi guys
I just wanted to make a short post and talk about an issue im having and maybe get some advice. I know that loops aren't that hard to grasp and I shouldn't be having this much trouble understanding them but im just not getting it. I dont really know how to explain it but loops (like looping through mysql in an update statement) is foren to me and i was wondering if anyone had any advice for maybe learning them or maybe something im just over looking or maybe some good tutorials. I really want to get them down and start using them in scripts i right but im getting so frustrated because i constantly hear how easy they are and im just not getting it. if i wasn't clear please let me know and ill try to explain more clearly thanks guys JL i am having issues with my class work. this needs to start at the $startNum and end with the $endNum and display results in the increments submitted by the html. I can not get it to print out correctly it is supposed to say: The square of $startNum is $square //until it hits the end number and is going up by the correct increments, It wont go up by any increments and only shows a list if i leave out the increment-----any suggestions??? please i have to keep it very simple since i am just learning-ty html </head> <body> <h1>Squares</h1> <p> <form action = "squares2Boles.php" method = "post" > <p>Start with: <input type = "text" size = "5" name = "startNum" /> </p><p>End with: <input type = "text" size = "5" name = "endNum" /> </p><p>Increment by: <input type = "text" size = "5" name = "increment" /> </p><p><input type = "submit" value = "Display the Squares" /></p> </form> </body> </html> my php: <html> <head> <title>Squares</title> <link rel ="stylesheet" type="text/css" href="sample.css" /> </head> <body> <?php $startNum = $_POST['startNum']; $endNum = $_POST['endNum']; $increment = $_POST['increment']; $square = $_POST['square']; print ("<h1>SQUARES</h1><hr />"); for ($startNum = $startNum; $startNum <= $endNum; $startNum = $startNum + $increment) { $square = $startNum * $startNum; print ("The square of $startNum is $square<br />"); } print ("<hr />"); ?> </body> </html> i have been given this task in in uni. i was wondering it some one would be so kind to help me with it. all i have so far is this <?php for($x=1; $x<=3; $x=$x+1) { print "$x <br>"; } if ($x== "A") { } ?> the task is below Generate a number between 1 & 3 If 1 then assign A, If 2 then assign B, If 3 then assign C Add to a wordstring (using string concatenation with .) We need 3 letters generated to give a 3 letter word For loop (3) Generate a number between 1 & 3 If 1 then assign A, If 2 then assign B, If 3 then assign C Add to a wordstring (string concatenation with .) End loop Print 3 letter word how can i set the color of a table background depending on what a variable is in my database? I currently have a table which echos data from my database, but i want the background too be a color depending on the value of a variable called 'status' (there are 3 variations) the variations are; order placed, processing and complete so for example: Code: [Select] if (status == placed) { background would be red } Code: [Select] if (status == processing) { background would be orange } Code: [Select] if (status == complete) { background would be green } appreciate any help. thank you. |