PHP - Want To Show The Database Field In The Url When Page Or Site Load 1st Time
hiii all, i want to show the database field (alise name) as the url after index.php when page or site loads first time. how i can achieve it? please help.... thanks in advance
Similar TutorialsI want to show a cookie of a referral's username on a sign up page. The link is like this, www.mysite.com/signup?ref=johnsmith. The cookie doesn't show if I go to that url page. But it does show up once I reload the page. So I'm wondering if it's possible to show the cookie the first time around, instead of reloading the page? Here is my code. // This is in the header $url_ref_name = (!empty($_GET['ref']) ? $_GET['ref'] : null); if(!empty($url_ref_name)) { $number_of_days = 365; $date_of_expiry = time() + 60 * 60 * 24 * $number_of_days; setcookie( "ref", $url_ref_name, $date_of_expiry,"/"); } else if(empty($url_ref_name)) { if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; } } else {} // This is for the sign up form if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; ?> <fieldset> <label>Referred By</label> <div id="ref-one"><span><?php if(!empty($user_cookie)){echo $user_cookie;} ?></span></div> <input type="hidden" name="ref" value="<?php if(!empty($user_cookie)){echo $user_cookie;} ?>" maxlength="20" placeholder="Referrer's username" readonly onfocus="this.removeAttribute('readonly');" /> </fieldset> <?php }
Hey, I need to generate a script which tells me how long it takes for an external page to load... Please can you help? Thanks hello, i want to get into a particular page if the user stays more than lets say 20 minutes to automatically load another php page. More specific i have a page which is a test. The user answears to some multiple choice questions. i want him to have only a particular time to anwear. Lets say after 20 min i want to load the results page. Any ideas? Hi, I have a problem. i want to show the current date and time in my tables of the database. I want to show it because i want to show it on my report generated in php. By the way i do not have a "date" field in my form. Can anyone help me out? Thanks, Heshan. hi! i dont know if the query below from mysql is slowing down the page or i have not written it properly: It is very slow, even when you limit the results to 100 . Thanks in advance.. Code: [Select] SELECT `tbl_business`.`appformno`, " _ & "`tbl_business`.`pobox`, `tbl_business`.`plotno`, `tbl_business`.`postalcode`, " _ & "`tbl_business`.`zonecode`, `tbl_business`.`ne`, `tbl_activities`.`act_code`, " _ & "`tbl_activity_codes`.`approved_fee`, `tbl_payment_status`.`status`, " _ & "`tbl_business`.`company`, `tbl_activity_codes`.`description` " _ & "FROM (`citycouncil`.`tbl_activity_codes` `tbl_activity_codes` " _ & "LEFT JOIN (`citycouncil`.`tbl_business` `tbl_business` " _ & "LEFT JOIN `citycouncil`.`tbl_activities` `tbl_activities` " _ & "ON `tbl_business`.`appformno`=`tbl_activities`.`appformno`) " _ & "ON `tbl_activity_codes`.`act_code`=`tbl_activities`.`act_code`) " _ & "LEFT JOIN `citycouncil`.`tbl_payment_status` `tbl_payment_status` " _ & "ON `tbl_activities`.`id`=`tbl_payment_status`.`activity_id` " _ & "WHERE tbl_business.appformno LIKE '%" & strFormNo & "%' " _ & "AND tbl_business.bid LIKE '%" & strBizIdNo & "%'" _ & " AND `tbl_business`.`contperson` LIKE '%" & strContPerson & "%' " _ & "AND `tbl_business`.`zonecode` LIKE '%" & strZoneCode & "%' " _ & " AND `tbl_activities`.`act_code` LIKE '%" & strBizActCode & "%' " _ & "AND `tbl_business`.`roadstreet` LIKE '%" & strStreet & "%' " _ & " AND `tbl_business`.`company` LIKE '%" & strBizName & "%' " _ & "AND `tbl_business`.`building` LIKE '%" & strBuilding & "%' " _ & "ORDER BY `tbl_business`.`appformno` Hi Guys and Gals, I run a simple fansite for some of my fellow MTG Tactics players at www.onlinegamekey.com I recently made a Booster Page value page he http://www.onlinegamekey.com/booster-packs.php And it seems the page loads really slow, but I kind of understand that since its doing a lot of math and dealing with a lot of data. I am wondering if there is a way to possibly optimize the page and querys in such a way that it doesn't take so long to load. I'm basically using 4 queries to get the value of each pack and 1 function to average the query data. And I add them up as I go. This is my function to find average values Code: [Select] ///AVERAGE FUNCTION function calculate_average($arr) { $count = count($arr); //total numbers in array foreach ($arr as $value) { $total = $total + $value; // total value of array numbers } $average = ($total/$count); // get average value return $average; } These are the queries to get the Average Values Code: [Select] <?php ///SETTING THE DAY $today = date("Y/m/d"); ///ALTERING DAY QUERY TIME (20 Days of Data) $minusday = mktime(0,0,0,date("m"),date("d")-20,date("Y")); ///SETTING THE DAY FOR THE QUERIES $queryday = date("Y/m/d",$minusday); ///DATA SET FOR BOOSTER PACK 1 //GET THE MYTHIC AVERAGE VALUE $sqlMythic=mysql_query("SELECT AVG( ab.Price_Per ) AS Aaverage FROM auctions AS ab INNER JOIN cardlist AS c ON c.card_name = ab.Card_Name WHERE ab.Day >= '$queryday' AND c.rarity = 'Mythic Rare' AND c.set = '1' GROUP BY c.card_name, ab.Card_Name") or die; while ($row=mysql_fetch_array($sqlMythic)) { $MythicValues[]=$row['Aaverage']; } ///MYTHIC VALUE IS 10% OF AVERAGE VALUE $Mythic = calculate_average($MythicValues) * .1; //GET THE RARE AVERAGE VALUE $sqlRare=mysql_query("SELECT AVG( ab.Price_Per ) AS Aaverage FROM auctions AS ab INNER JOIN cardlist AS c ON c.card_name = ab.Card_Name WHERE ab.Day >= '$queryday' AND c.rarity = 'Rare' AND c.set='1' GROUP BY c.card_name, ab.Card_Name") or die; while ($row=mysql_fetch_array($sqlRare)) { $RareValues[]=$row['Aaverage']; } ///RARE VALUE IS 90% OF AVERAGE RARE VALUE $Rare = calculate_average($RareValues) *.9; ///TOTAL CONTRIBUTION TO PACK 100% IS 10% MYTHIC + 90% RARE $raremythic= $Mythic + $Rare; ///GET THE UNCOMMON AVERAGE VALUE $sqlUncommon=mysql_query("SELECT AVG( ab.Price_Per ) AS Aaverage FROM auctions AS ab INNER JOIN cardlist AS c ON c.card_name = ab.Card_Name WHERE ab.Day >= '$queryday' AND c.rarity = 'Uncommon' AND c.set='1' GROUP BY c.card_name, ab.Card_Name") or die; while ($row=mysql_fetch_array($sqlUncommon)) { $ucValues[]=$row['Aaverage']; } ///UNCOMMON VALUE IS VALUE * 3 $Uncommon = calculate_average($ucValues); $urm= ($Uncommon * 3) + $raremythic; ///GET THE COMMON VALUE $sqlCommon=mysql_query("SELECT AVG( ab.Price_Per ) AS Aaverage FROM auctions AS ab INNER JOIN cardlist AS c ON c.card_name = ab.Card_Name WHERE ab.Day >= '$queryday' AND c.rarity = 'Common' AND c.set='1' GROUP BY c.card_name, ab.Card_Name") or die; while ($row=mysql_fetch_array($sqlCommon)) { $cValues[]=$row['Aaverage']; } ///COMMON VALUE IS VALUE * 10 $common = calculate_average($cValues); //TOTAL SET 1 VALUE IS ALL VALUES ADDED UP $curm= ($common * 10) + $urm; ?> But I'm not real sure where the strain is coming from. The page seems to load really slow, and I'm not sure if I should just try and write all these queries as a separate function then have it write the data to a separate table, or if there is another way to optimize this code. I'm still have a lot to learn so I would appreciate any thoughts or ideas you folks can offer me. Many thanks Hi,
In reference to my first attached image, I have a form which displays two SELECT/drop-down fields (labeled "Store Name" and "Item Description".....and both of which pull-in values from two separate lookup/master tables, in addition to providing an additional option each for "NEW STORE" and "NEW ITEM").
Now, when first-run, and/or if "NEW STORE" and "NEW ITEM" are not selected from the drop-down's then the two fields in green ("New Store Name" and "New Item Name" are hidden, by means of the following code:
<div class="new-store-container" id="new-store-container" name="new-store-container" style="display:none;"> <div class="control-group"> <div class="other-store" id="new_store_name"> <?php echo standardInputField('New Store Name', 'new_store_name', '', $errors); ?> </div> </div> </div>Conversely, if "NEW STORE" and/or "NEW ITEM" are selected from the two drop-down's then one (or both) of the "New Name" fields are unhidden by means of the following two pieces of code, one PHP and the second JS: <select class="store-name" name="store_id" id="store_id" onclick="toggle_visibility('store_id','new-store-container')"> <?php echo $store_options; ?> <?php if($values['store_id'] == "OTH") { echo "<option value='OTH' selected> <<<--- NEW STORE --->>> </option>"; } else { echo '<OPTION VALUE="OTH"> <<<--- NEW STORE --->>> </OPTION>'; } ?> </select> function toggle_visibility(fieldName, containerName) { var e = document.getElementById(fieldName); var g = document.getElementById(containerName); if (e.value == 'OTH') { if(g.style.display == 'none') g.style.display = 'block'; else g.style.display = 'none'; } }All of that is working just fine. The problem I'm having is that when I click the "Create" button, after having left any one of the form fields blank, the two "New Name" fields are hidden again, which I don't want to happen i.e. I want them to remain visible (since the values of "store_id" and/or "item_id" are "OTH"), so that the user can enter values into one or both of them, without havng to click on the drop-down a second time in order to execute the "on-click" code. The second attached image shows how the fields are hidden, after clicking "Create". How can I achieve that? It would be greate if someone could cobble-up the required code and provide it to me, since I'm relatively new to this. Thanks much. Snap1.png 26.14KB 0 downloads Snap2.png 149.47KB 0 downloads Hi guys, Should be a simple 1. If i have the following at the top of the page: $page_views = $row['page_views'] + 1; mysql_query("UPDATE table SET page_views='$page_views'"); and then the following at the bottom of the page: echo $row['page_views']; Should I see the page views as 1 the first time the page is visited, 2 the second time the page is visited, and so on......? At the moment im seeing 0 on the first page visit, 1 on the second page visit, 2 on the third..... I had this problem before on another page i was working, and i simply solved it by displaying the mysql query above the echo similar to the code above. However now it does not seem to be working. Am i missing something really simple? lol Thanks I'm not looking for code, mostly just some direction, but I'm sure I'll be back as I try to shape the code. Also, I know very little about coding jQuery, Ajax, etc. Here is what I'm looking for: Basketball coach enters a Page that only he (or admin) can see. (I have that part figured out.) Once there, he has a form to fill out with a player's name and other information. I'd rather there not be 12 rows of empty cells. (Coaches will view that as work) I'd rather not have the Page reload on each "Add", but that would be the lesser of two evils. Is there a way to keep a persistent connection so when a coach hits Add, the player gets added to the database, a new empty form shows up, and the player's information shows up below on a roster? Hi, Sorry if this is in the wrong place. I really just need a search term to use for what i'm trying to do. I would like my buttons to appear pressed on each page. For example if you are on the home page the home button will appear pressed. If you are on the screenshots page the screenshots button will appear pressed. Pretty much i want my nav bar to display what page is being viewed. I'm using SMF forums and i've created an extension of my forum that i'm using on the root of my site. As far as i can tell i have the correct code added to the forum that should highlight the home button while on the home page. The part i'm missing is the code to add onto the home page. This is the code I have on the button. $buttons = array( 'overview' => array( 'title' => $txt['overview'], 'href' => 'http://www.wararmada.com', 'show' => true, 'sub_buttons' => array( 'alliance' => array( 'title' => $txt['alliance'], 'href' => $scripturl . '?action=overview;area=alliance', 'show' => true, ), This is the code i have in the language file. $txt['overview'] = 'overview'; I'm not sure what this is called. I don't know anything about php but so far i've been able to get by just using google but I don't really know how to search for this. Thanks for all the help! What I am looking for is that if any field in a database is empty, the form comes back and puts in the word "empty" into the web page, but not the database. I got this right now, it shows the first part fine, but the second part it doesn't show the "Empty" comment... I don't understand why... as far as I can tell the code is fine... Code: [Select] <?php //Nonconformity, Disposition, Comments and Comments & Additional Details echo '<div id="box3">'; if (!empty($row['Nonconformity']) || !empty($row['Disposition']) || !empty($row['Comments']) || !empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />' . $row['Nonconformity'] . '</div>'; echo '<div id="dis"><span class="b">Disposition: </span><br />' . $row['Disposition'] . '</div>'; echo '<div id="comm"><span class="b">Comments: </span><br />' . $row['Comments'] . '</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />' . $row['CommentsAdditional_Details'] . '</div>';} else if (empty($row['Nonconformity']) || empty($row['Disposition']) || empty($row['Comments']) || empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />Empty</div>'; echo '<div id="dis"><span class="b">Disposition: <br /></span>Empty</div>'; echo '<div id="comm"><span class="b">Comments: <br /></span>Empty</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />Empty</div>';} echo '</div>'; ?> now i use this code to show where the visitors came from to my site. <?php $referer=$_SERVER['HTTP_REFERER']; echo $referer; ?> now, i want to show the 5 latest vistors referer's site url on my site ? I'm having a problem and need an answer to why its happening and how to prevent it. Scenario: I begin load my home page which starts with a session_start(); .... Before it FULLY completes loading I try to navigate to another page and BOOM, that page will not load and any other page that begins with session_start(); will not load unless I close and restart the entire browser or wait about 10 minutes.... I will note my website makes ajax calls every 5 seconds or so, but I use setTimeout for them. Any help??? Thanks ahead! Hi , I know my code sucks but i'm learning fast!! I'm trying to show a form if the qty value in a database == 10 or a different form if the value ==20. I tried but failed. Any help really appreciated. Code: [Select] <?php require_once('Connections/book.php'); ?> <?php $colname_cardpayment = "-1"; if (isset($_GET['orderid'])) { $colname_cardpayment = (get_magic_quotes_gpc()) ? $_GET['orderid'] : addslashes($_GET['orderid']); } mysql_select_db($database_book, $book); $query_cardpayment = sprintf("SELECT * FROM cards WHERE orderid = '%s' ORDER BY qty ASC", $colname_cardpayment); $cardpayment = mysql_query($query_cardpayment, $book) or die(mysql_error()); $row_cardpayment = mysql_fetch_assoc($cardpayment); $totalRows_cardpayment = mysql_num_rows($cardpayment); // Database connect $con = mysql_connect("mysql1.myhost.ie","admin_book","root123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); //Parse Values from Coupon.php Form $orderid = mysql_real_escape_string(trim($_POST['orderid'])); $name = mysql_real_escape_string(trim($_POST['name'])); $surname = mysql_real_escape_string(trim($_POST['surname'])); $add1 = mysql_real_escape_string(trim($_POST['add1'])); $add2 = mysql_real_escape_string(trim($_POST['add2'])); $town = mysql_real_escape_string(trim($_POST['town'])); $county = mysql_real_escape_string(trim($_POST['county'])); $postcode = mysql_real_escape_string(trim($_POST['postcode'])); $phone = mysql_real_escape_string(trim($_POST['phone'])); $email = mysql_real_escape_string(trim($_POST['email'])); $letterstyle = mysql_real_escape_string(trim($_POST['letterstyle'])); $sql="INSERT INTO custdetails (orderid, name, surname, add1, add2, town, county, postcode, phone, email, letterstyle) VALUES ('$orderid','$name','$surname','$add1','$add2','$town','$county','$postcode','phone','$email','$letterstyle')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Digital Scribe Books</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('images/buttons/home_over.png','images/buttons/books_over.png','images/buttons/cards_over.png','images/buttons/letters_over.png')"> <div id="snow"> <div id="wrapper"> <div id="header"> <div id="logo"><img src="images/digital_scripe.png" width="218" height="91" /></div> <div id="menu"><a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/buttons/home_over.png',1)"><img src="images/buttons/home_act.png" name="Home" width="131" height="132" border="0" id="Home" /></a><a href="books.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Books','','images/buttons/books_over.png',1)"><img src="images/buttons/books_act.png" name="Books" width="131" height="132" border="0" id="Books" /></a><a href="cards.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Cards','','images/buttons/cards_over.png',1)"><img src="images/buttons/cards_act.png" name="Cards" width="131" height="132" border="0" id="Cards" /></a><a href="letters.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Letters','','images/buttons/letters_over.png',1)"><img src="images/buttons/letters_act.png" name="Letters" width="131" height="132" border="0" id="Letters" /></a></div> </div> <div id="content"> <?php echo 'Order ID is : '. $orderid . '.<br />'; if ($row2['qty'] == 10) echo "<div> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="accounts@agraphics.ie"> <input type="hidden" name="lc" value="IE"> <input type="hidden" name="item_name" value="10 Christmas Cards"> <input type="hidden" name="item_number" value="<? echo $orderid; ?>"> <input type="hidden" name="amount" value="12.99"> <input type="hidden" name="currency_code" value="EUR"> <input type="hidden" name="button_subtype" value="services"> <input type="hidden" name="shipping" value="2.99"> <input type="hidden" name="return" value="http://www.digitalscribe/thanks.php"> <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </div>"; if ($row2['qty'] == 20) echo "<div> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="accounts@agraphics.ie"> <input type="hidden" name="lc" value="IE"> <input type="hidden" name="item_name" value="20 Christmas Cards"> <input type="hidden" name="item_number" value="<? echo $orderid; ?>"> <input type="hidden" name="amount" value="21.99"> <input type="hidden" name="currency_code" value="EUR"> <input type="hidden" name="button_subtype" value="services"> <input type="hidden" name="shipping" value="2.99"> <input type="hidden" name="return" value="http://www.digitalscribe/thanks.php"> <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </div>"; ?> </div> <div id="footer" class="clear"><div id="sign"><div id="sign_text">Personalised<br /> Books</div> </div></div> </div></div> </body> </html> <?php mysql_free_result($cardpayment); ?> Illl show you the files and maybe someone can help me figure out whats going on. Lil more about the script When explore.php is opened it selects a random approved link out of the database and posts it within the iframe. Explore.php also calls random.php which has a nice little menubar. When the explore.php is originally clicked on everything works great a random site is selected and ran inside the iframe and the javascript menubar is loaded above the iframe. The issue is i cant get this to happen again. In the menu bar i have a hyperlink that loads Code: [Select] <li><a href="http://localhost/Stumble/explore.php" rel="gotsubmenu[selected]">JavaScript Kit</a></li>But when i click this link it just opens the page behind the iframe instead of in the iframe like it does when the explore.php is originally loaded. So i guess i need a lil help figuring out how i can make the random approved site load in the iframe by clicking a hyper link located in the menubar Thanks for your time Random.php Code: [Select] <?php /** * @author moeller * @copyright 2011 */ ?> <html> <head> <link rel="stylesheet" type="text/css" href="mouseovertabs.css" /> <script src="mouseovertabs.js" type="text/javascript"> /*********************************************** * Mouseover Tabs Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more ***********************************************/ </script> </head> <body> <div id="mytabsmenu" class="tabsmenuclass"> <ul> <li><a href="http://localhost/Stumble/explore.php" rel="gotsubmenu[selected]">JavaScript Kit</a></li> <li><a href="http://www.cssdrive.com" rel="gotsubmenu">CSS Drive</a></li> <li><a href="http://localhost/Stumble/explore.php">No Sub Menu</a></li> </ul> </div> <div id="mysubmenuarea" class="tabsmenucontentclass"> <!--1st link within submenu container should point to the external submenu contents file--> <a href="submenucontents.htm" style="visibility:hidden">Sub Menu contents</a> </div> <script type="text/javascript"> //mouseovertabsmenu.init("tabs_container_id", "submenu_container_id", "bool_hidecontentsmouseout") mouseovertabsmenu.init("mytabsmenu", "mysubmenuarea", true) </script> </body> </html> explore.php Code: [Select] <?php /** * @author Brent Moeller * @copyright 2011 */ include ('functions.php'); db_connect(); $result = mysql_query("SELECT * FROM slinks where approval='1' ORDER BY RAND() LIMIT 1") or die(mysql_error()); ?> <html> <head> <title>DizzyUrl Discovery Engine</title> </head> <frameset rows="80,*" BORDERCOLOR="green" BORDER="3"> <frame src="random.php" name="surfbar" marginwidth="O" marginheight="0" NORESIZE SCROLLING="no" /> <frame src="<?php while ($row = mysql_fetch_array($result)){ print $row["url"];}?> " name="random" marginwidth="O" marginheight="0" noresize scrolling="auto" /> </frameset> <noframes> <body><p>This Browser does not support Frames.</p></body> </noframes> </html> I'm trying to control the load order of the browser. The default load order is from top to bottom. Well I have a table that is made in html with more code bellow the table. My php data that I put inside the html table is Code: [Select] <?php include("table/table.php"); ?> that grabs the data that will go into my html table. Well the problem I'm having is that the rest of the table with stuff under the table won't load till the php is done being processed. This makes my site look weird for 4 seconds and is the reason why I want to load the php content last. Is there a way to do this with php or javascript? Quesion: Show each movie in the database on its own page, and give the user links in a "page 1, Page 2, Page 3" - type navigation system. Hint: Use LIMIT to control which movie is on which page. I have provided 3 files: 1st: configure DB, 2nd: insert data, 3rd: my code for the question. I would appreciate the help. I am a noob by the way. First set up everything for DB: <?php //connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //create the main database if it doesn't already exist $query = 'CREATE DATABASE IF NOT EXISTS moviesite'; mysql_query($query, $db) or die(mysql_error($db)); //make sure our recently created database is the active one mysql_select_db('moviesite', $db) or die(mysql_error($db)); //create the movie table $query = 'CREATE TABLE movie ( movie_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, movie_name VARCHAR(255) NOT NULL, movie_type TINYINT NOT NULL DEFAULT 0, movie_year SMALLINT UNSIGNED NOT NULL DEFAULT 0, movie_leadactor INTEGER UNSIGNED NOT NULL DEFAULT 0, movie_director INTEGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (movie_id), KEY movie_type (movie_type, movie_year) ) ENGINE=MyISAM'; mysql_query($query, $db) or die (mysql_error($db)); //create the movietype table $query = 'CREATE TABLE movietype ( movietype_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, movietype_label VARCHAR(100) NOT NULL, PRIMARY KEY (movietype_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); //create the people table $query = 'CREATE TABLE people ( people_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, people_fullname VARCHAR(255) NOT NULL, people_isactor TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, people_isdirector TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (people_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Movie database successfully created!'; ?> ******************************************************************** *********************************************************************** second file to load info into DB: <?php // connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //make sure you're using the correct database mysql_select_db('moviesite', $db) or die(mysql_error($db)); // insert data into the movie table $query = 'INSERT INTO movie (movie_id, movie_name, movie_type, movie_year, movie_leadactor, movie_director) VALUES (1, "Bruce Almighty", 5, 2003, 1, 2), (2, "Office Space", 5, 1999, 5, 6), (3, "Grand Canyon", 2, 1991, 4, 3)'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the movietype table $query = 'INSERT INTO movietype (movietype_id, movietype_label) VALUES (1,"Sci Fi"), (2, "Drama"), (3, "Adventure"), (4, "War"), (5, "Comedy"), (6, "Horror"), (7, "Action"), (8, "Kids")'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the people table $query = 'INSERT INTO people (people_id, people_fullname, people_isactor, people_isdirector) VALUES (1, "Jim Carrey", 1, 0), (2, "Tom Shadyac", 0, 1), (3, "Lawrence Kasdan", 0, 1), (4, "Kevin Kline", 1, 0), (5, "Ron Livingston", 1, 0), (6, "Mike Judge", 0, 1)'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Data inserted successfully!'; ?> ************************************************************** **************************************************************** MY CODE FOR THE QUESTION: <?php $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); mysql_select_db('moviesite', $db) or die(mysql_error($db)); //get our starting point for the query from the URL if (isset($_GET['offset'])) { $offset = $_GET['offset']; } else { $offset = 0; } //get the movie $query = 'SELECT movie_name, movie_year FROM movie ORDER BY movie_name LIMIT ' . $offset . ' , 1'; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); ?> <html> <head> <title><?php echo $row['movie_name']; ?></title> </head> <body> <table border = "1"> <tr> <th>Movie Name</th> <th>Year</th> </tr><tr> <td><?php echo $row['movie_name']; ?></td> <td><?php echo $row['movie_year']; ?></td> </tr> </table> <p> <a href="page.php?offset=0">Page 1</a>, <a href="page.php?offset=1">Page 2</a>, <a href="page.php?offset=2">Page 3</a> </p> </body> </html> I found this function and take no credit for it, I'm trying to get it to show HH:MM:SS when I have the total number of seconds, but nothing is showing on the screen function sec2hms ($sec, $padHours = false) { // start with a blank string $hms = ""; // do the hours first: there are 3600 seconds in an hour, so if we divide // the total number of seconds by 3600 and throw away the remainder, we're // left with the number of hours in those seconds $hours = intval(intval($sec) / 3600); // add hours to $hms (with a leading 0 if asked for) $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT). ":" : $hours. ":"; // dividing the total seconds by 60 will give us the number of minutes // in total, but we're interested in *minutes past the hour* and to get // this, we have to divide by 60 again and then use the remainder $minutes = intval(($sec / 60) % 60); // add minutes to $hms (with a leading 0 if needed) $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ":"; // seconds past the minute are found by dividing the total number of seconds // by 60 and using the remainder $seconds = intval($sec % 60); // add seconds to $hms (with a leading 0 if needed) $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT); // done! return $hms; } The part of the code to show the data is below: Code: [Select] while ($row = mysql_fetch_array($result)) { $sec = time() - strtotime($row['starttime']); echo $sec; // print to screen to make sure $sec had a value sec2hms($sec); } Any guidance on where I went wrong? This is the code im using: Code: [Select] <?php include "config.php"; if (isset($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); $sql = "SELECT email FROM gusers WHERE id = $id LIMIT 1"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); echo "Email: " . $row['email']; } } } I am trying to get more informations than just the e-mail address, but everytime it seems to fail, i am a completly newb to php but ill try my best.... Could someone tell how this is done properly (like loading name, info, and so on from the database and showing it aswell) Ok so I basically have two textfields and a submit button. The first text field basically allows the user to input a duration of an event in the format of Hours:Minutes:Seconds such as: 02:30:00 is two and a half hours. The second textfield allows the user to put in an average time 'something' does something in the same format as above. So for example 00:20:00 is 20 minutes. 1st Textfield: Code: [Select] <input name="tmarrtextfield" type="text" class="textbox" id="tmarrtextfield" value="00:00:00"> 2nd Textfield: Code: [Select] <input name="tmatttextfield" type="text" class="textbox" id="tmatttextfield" value="00:00:00"> What I need is for when the form is submitted to the same page.. the code to...: 1. Convert the normal text info into actual time data. 2. Divide the duration by the average timing so for example: 02:30:00 (150 minutes) / 00:20:00 (20 minutes) = 7.5 (Would return a rounded down number or up, doesn't matter) then store the number as a variable that will be echoed later. Harry. |