PHP - Dynamic Url's???
Hello!
If you search Google, you'll notice the URL: http://www.google.com/webhp?hl=en#hl=en&source=hp&q=php+freaks&aq=f&aqi=g10&aql=&oq=&gs_rfai=CtdaTdtdRTNnPD5HuzASZtMWiCgAAAKoEBU_Q0ZT5&pbx=1&fp=19d754eee0b4f223 You can copy that URL anywhere you like... and the user will still see the same results. So basically the URL dynamically does an action, and accesses the database. How on do I make a URL like this? Meaning when you change the URL parameter values, it request a slightly different database query? Does that make sense? Similarly with NexTag.com: http://www.nextag.com/serv/main/buyer/ProductCompare.jsp?search=camera&page=0&node=500001&psort=%2FDigital-Cameras--zzcameraz500001zB6z5---html&zipcode=&cptitle=657166355&cptitle=656751324&cptitle=620051906&cptitle=705150048 That was a Dynamically made URL (I selected from check boxes which products to compare) and it makes that URL so anyone can see those products. Any ideas on how to do this? More examples on the URL: http://www.cars.com/go/compare/modelCompare.jsp?myids=9721,11439 (i select the cars, it generates that URL. Notice the IDs 9721,11439) Similar TutorialsFolks, I need help (Php code ) to generate a Dynamic Text on a Base Image. What i want to do is, to make this Image as header on my Site and to make this Header Specific to a Site, i want to Add the Domain Name on the Lower Left of the Image. Got the Idea? Here is the Image link: Quote http://img27.imageshack.us/i/shoppingheader1.jpg/ PHP Variable that holds the Domain name is: $domain All i need the Dynamic PHP Codes that i can put on all my sites to generate this Text on Image (Header) Dynamically... May Anyone Help me with this Please? Cheers Natasha T. Hi all I need to combine these two scripts: Firstly, the following decides which out of the following list is selected based on its value in the mySQL table: <select name="pack_choice"> <option value="Meters / Pack"<?php echo (($result['pack_choice']=="Meters / Pack") ? ' selected="selected"':'') ?>>Meters / Pack (m2)</option> <option value="m3"<?php echo (($result['pack_choice']=="m3") ? ' selected="selected"':'') ?>>Meters / Pack (m3)</option> <option value="Quantity"<?php echo (($result['pack_choice']=="Quantity") ? ' selected="selected"':'') ?>>Quantity</option> </select> Although this works OK, I need it also to show dynamic values like this: select name="category"> <?php $listCategories=mysql_query("SELECT * FROM `product_categories` ORDER BY id ASC"); while($categoryReturned=mysql_fetch_array($listCategories)) { echo "<option value=\"".$categoryReturned['name']."\">".$categoryReturned['name']."</option>"; } ?> </select> I'm not sure if this is possible? Many thanks for your help. Pete Hi guys, I've got this php script which display the users of my database in a dynamic dropdown: <?php include "leadscript/connect_to_mysql.php"; $canvass_name=""; $sql = mysql_query("SELECT * FROM csj_canvasser"); $appointmentCount6 = mysql_num_rows($sql); // count the output amount if ($appointmentCount6 > 0) { while($row = mysql_fetch_array($sql)){ $c_employee = $row["c_employee"]; $canvass_name .='<option value="' . $c_employee . '">' . $c_employee . ' </option>'; } } ?> <form> <select name="c_employee"> <option value="">Select a person:</option> <?php echo $canvass_name; ?> </select> </form> I was wondering if there's a way I can write a code to GET value I select from the dynamic dropdown and use it to write a select query. Thank I'm trying to make my menu dynamic for example I will have a menu with it's submenus and when the user logs on the submenu account will then be shown where it wasn't shown before the user logged on. here is my submenu.controller Code: [Select] <?php class submenus_controller extends controller{ protected $_helpers = array('form', 'html'); protected $_observers = array('seo_uris'); public $model='submenus'; public function ajax_set_submenu($submenu_id){ $submenu=$this->_model->get($submenu_id); $_SESSION['submenu']=$submenu; } } ?> and here is my default page Code: [Select] <!doctype html> <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]--> <!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <head> <title><?php echo $this->get_title();?></title> <meta name="author" content="team digitalpro"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name = "Description" content = "<?php echo $this->get_description();?>" /> <meta name = "Keywords" content = "<?php echo $this->get_keywords(); ?>" /> <link rel="stylesheet" href="/css/style.css"> <script src="js/libs/modernizr-2.0.6.min.js"></script> </head> <body> <div id="container"> <header> <div class="inhoud"> <div id="logo"><a href="/"><img src="/img/logo.gif" width="306" height="126" border="0" /></a></div> <nav> <div class="menu"> <ul> <?php if (isset($this->_params['menus']) && is_array($this->_params['menus'])){ foreach ($this->_params['menus'] as $menu){ if (!empty($menu['submenus.page_id'])){ $uri=$this->get_uri('/pages/view/'.$menu['submenus.page_id']); }else{ $uri=$this->get_uri("/{$menu['submenus.controller']}/{$menu['submenus.action']}"); } // p($menu); ?> <li><a href="<?php echo $uri ?>" onclick="javascript:return setMenu(<?php echo $menu['id'] ?>);"><?php echo strtoupper($menu['name'])?></a></li> <?php } } ?> </ul> </div> </nav> </div> </header> <div id="hero-pic"> <div id="slogans"><img src="../img/slogans.png" width="277" height="214" /></div> <img src="../img/hero.gif" width="996" height="286" /></div> <main> <div id="left"> <div class="inhoud"> <div id="left-nav"> <ul> <?php if (isset($this->_params['submenus']) && is_array($this->_params['submenus'])){ foreach ($this->_params['submenus'] as $submenu){ if (!empty($submenu['page_id'])){ $uri=$this->get_uri('/pages/view/'.$submenu['page_id']); }else{ $uri=$this->get_uri("/{$submenu['controller']}/{$submenu['action']}"); } ?> <li<?php if ($_SESSION['submenu']['id'] == $submenu['id']){?> class="active"<?php ;} ?>> <a href="<?php echo $uri ?>" onclick="javascript:return setSubMenu(<?php echo $submenu['id'] ?>);"> <?php echo strtoupper($submenu['name'])?> </a> </li> <?php } } ?> </ul> </div> <form method="post" action=""> <input type="text" id="search" /> <input type="submit" name="button" value="GO" class="go" /> </form> <div class="sub-links"> <ul> <li><a href="#">Home</a></li> <li><a href="#">Contact us</a></li> <li><a href="#">Sitemap</a></li> <li><a href="#">Privacy policy</a></li> </ul> </div> </div> </div> <div id="right"> <div class="inhoud"> <?php echo $this->page('view') ?> </div> </div> </main> <footer> <!-- <div class="inhoud"> <ul> <li><a href="#">COMPANY </a></li> <li><a href="#">PRIVATE EQUITY </a></li> <li><a href="#">CONSULTING </a></li> <li><a href="#">INVEST </a></li> <li><a href="#">PARTNERS </a></li> <li><a href="#">NEWS</a></li> </ul> --> <p> </p> <p> </p> </div> </footer> </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="/js/libs/jquery-1.6.2.min.js"><\/script>')</script> <script defer src="/js/plugins.js"></script> <script defer src="/js/script.js"></script> <script> window._gaq = [['_setAccount','UAXXXXXXXX1'],['_trackPageview'],['_trackPageLoadTime']]; Modernizr.load({ load: ('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js' }); setMenu = function(menu_id){ $.ajax({ url: "/menus/ajax_set_menu/"+menu_id, type: 'POST', dataType: "html", data: { format: 'JSON', }, success: function(data) { } }); } setSubMenu = function(submenu_id){ $.ajax({ url: "/submenus/ajax_set_submenu/"+submenu_id, type: 'POST', dataType: "html", data: { format: 'JSON', }, success: function(data) { } }); } </script> <!--[if lt IE 7 ]> <script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script> <script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script> <![endif]--> </body> </html> I want to get the ibase_blob_echo function and I was told I need to uncomment the extension=php_interbase.dll in my php.ini. So I did and now I get the message: Unable to Load Dynamic Library in a pop-up window. I'm lost and don't know how to solve this I'm trying to figure out for the months I can get it to display the last 5 months including the current month. The reason for this is I"m going to get the total number of hits for my website for each month as well as the number of successful logins for my CMS script. Any thoughts? Code: [Select] <table class="visualize_dashboard"> <caption> Dashboard Chart Example </caption> <thead> <tr> <td></td> <th scope="col">March</th> <th scope="col">April</th> <th scope="col">May</th> <th scope="col">June</th> <th scope="col">July</th> </tr> </thead> <tbody> <tr> <th scope="row">Visits</th> <td>175</td> <td>145</td> <td>212</td> <td>175</td> <td>182</td> </tr> <tr> <th scope="row">Logins</th> <td>94</td> <td>53</td> <td>124</td> <td>92</td> <td>105</td> </tr> </tbody> </table> Hi, I hope someone can help. I currently have a page that includes the main page after login, however I am looking into changing this so that when a user logs in they get 3/4 linked images that, when clicked dynamically load/include the page based on the select i.e. user selects the image laptop, that has a hyperlink, it loads the laptop page. If anyone has any ideas or suggestion,i'd appreciate it. Hi, I'm learning php and I'm trying to get to grips with dynamic xml and php coming from a database. The trouble I am having is I can't get my code to give any output. I don't get an error I message, I just can't get the xml to display. If anyone can give me any pointers as to what I'm doing wrong that would be great... Here's the code I have. Code: [Select] <?php DEFINE ('DB_USER', 'root'); DEFINE ('DB_PASSWORD', 'password'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'flashphpbible'); $link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query = "SELECT * FROM dynamicxml WHERE id=1"; $result = mysqli_query($link, $query); $xmlData .= " "; $xmlData .= "<store>\n"; while($row = mysqli_fetch_array($result)); { $xmlData .= " <item>\n"; $xmlData .= " <name>".$row['name']."</name>\n"; $xmlData .= " <section>".$row['section']."</section>\n"; $xmlData .= " <price>".$row['price']."</price>\n"; $xmlData .= " <inStock>".$row['instock']."</inStock>\n"; $xmlData .= " </item>\n"; } $xmlData .= "</store>\n"; echo "response=".$xmlData; ?> Thanks for any help offered. Ben. Hey guys does anyone know of a good dynamic directory solution? What i mean by this is when i am creating an application and i use require_once 'includes/config.php'; and then i create a class that needs the config file so i include it into the class like so: require_once '../include/config.php'; then i make a new folder named member then i have to require this class (created above) and it fails to find the directory. What would be a good solution for this? Thanks guys!! Hello: I am trying to make a StyleSheet updateable from my admin panel, but I'm not sure if what I want to do is possible. So ... I have a TEXTAREA in my admin panel that writes to the DB just fine. it has styles like: Code: [Select] body { margin: 5px 0; padding: 0; background-color: #ebe9e6; background-image: url('../images/Site-BG2.jpg'); background-position: center bottom; background-repeat: no-repeat; background-attachment: scroll; font-family: arial, sans-serif; font-size: 100%; line-height: 1.4em; } ... Etc... On the frontend, it writes into the StyleSheet just fine like: Code: [Select] <?php include('myConn.php'); //contains your mysql connection and table selection $query=mysql_query("SELECT * FROM myStyleSheet") or die("Could not get data from db: ".mysql_error()); while($result=mysql_fetch_array($query)) { $myPageData=$result['myPageData']; } ?> <?php echo $myPageData; ?> So, what I want to see is if I can somehow pull the styles onto the page like: Code: [Select] <link rel="stylesheet" type="text/css" href="include/StyleSheet.css" /> Now, if I do it as listed above it and look at the code it displays the Code: [Select] <?php include('myConn.php'); //contains your mysql connection and table selection Etc... If I do it like Code: [Select] <link rel="stylesheet" type="text/css" href="include/StyleSheet.php" /> It displays the styles fine, but the browser doesn't read it as a StyleSheet and therefore the page doesn't get formatted. So, is there any way to make this work? Anyone have any ideas about this? The idea is so I can manage the Styles via an admin panel remotely without having to login with web editing software. Thanks. Okay, so I have a page with a heap of fields and buttons on it (and want to keep it like that really) inside one form. Layout Box 1 Button 1 Box 2 Button 2 Box 3 Button 3 Box 4 Button 4 etc... Box 1 is called 'amount1$id' Box 2 is called 'amount.$id' where $id is the $id of the data being displayed etc So a sample form may look like Box: "amount22" Button: "Pay22" Box: "amount25" Button: "Pay25" Box: "amount32" Button: "Pay32" Box: "amount39" Button: "Pay39" Box: "amount420" Button: "Pay420" Its working fine up to that point. My problem now is that I can't work out how to get that id number from the form once submitted. If I could get the button name somehow I could do it, although I don't know the button or box names when writing the processing script. I could use a loop and check if button1 to buttonX was posted etc, although if there is a large number of entries in the database, then that starts to become a problem. Thoughts? I really can't get my head around this dynamic drop box. What I want is for a drop box to be populated with values in my database. I have this that connects to my SQL and picks out the table required: function displayUsers(){ global $database; $q = "SELECT username," ."FROM ".TBL_USERS." ORDER BY userlevel DESC,username"; $result = $database->query($q); ... I then have this to pick out any errors, and also using the num_rows to get the number of rows (values) there a $num_rows = mysql_numrows($result); if(!$result || ($num_rows < 0)){ echo "Error displaying info"; return; } if($num_rows == 0){ echo "Database table empty"; return; } From here, I guess I want the num_rows to keep 'adding on' the number of <option value=""> in my selection box according the number of values I have in my database. At this point, I can pull out the values into a dynamic table ... but I want it into a drop box -- but I'll but up the code for the dynamic table so you can get an idea: /* Display table contents */ echo "<table align=\"left\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n"; echo "<tr><td><b>Username</b></td></tr>\n"; for($i=0; $i<$num_rows; $i++){ $uname = mysql_result($result,$i,"username"); echo "<tr><td>$uname</td></tr>\n"; } echo "</table><br>\n"; } I hope you can use the code above to help me develop this darn drop box! Thanks, Ollie! trying to be able to store client information in mysql db for reference later in an admin area. The code I have so far allows me to list the client names, but once I "select" the name I want it to show the rest of the database information stored for that user (email, height, weight, phone number, etc...) which it currently is not doing. Any and all help will be greatly appreciated, tired of struggling through this blindly. Code: [Select] <? // Connect database mysql_connect("localhost","",""); mysql_select_db("mydb"); if(isset($select)&&$select!=""){ $select=$_GET['select']; } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <form id="form1" name="form1" method="get" action="<? echo $PHP_SELF; ?> "> Client Name : <select name="select"> <option value="">--- Select ---</option> <? // Get records from database (table "users"). $list=mysql_query("select * from users order by id asc"); while($row_list=mysql_fetch_assoc($list)){ ?> <option value="<? echo $row_list['id']; ?>" <? if($row_list['id']==$select){ echo "selected"; } ?>><? echo $row_list['name']; ?></option> <? } ?> </select> <input type="submit" name="Submit" value="Select" /> </form> <hr> <p> <? if(isset($select)&&$select!=""){ // Get records from database (table "users"). $result=mysql_query("select * from users where id='$select'"); $row=mysql_fetch_assoc($result); ?> Information about <strong><? echo $row['name']; ?></strong> client...</p> <p><? echo $row['email']; ?><br> ........................................<br> ........................................ <? // End if statement. } // Close database connection. mysql_close(); ?> </p> </body> </html> Hi guys. I am having a hard time finding a solution for this, is it possible to get not the value of a dropdown (oh what's it called??? ) but what is in between of the <option> tag?like, Code: [Select] <select name="catID"> <option value=$row['c_id']>$row['c_name']</option> and save it to the database??cuz I'm using a dynamic dropdown which bases the content of another dropdown by the id of the previous. And so, if i save it to the database, instead of for example "BSA" is saved, the id of "BSA" which is "1" is saved..any ideas guys? How can I go about making dynamic pages? eg. user types "phpfreaks.com/index.php?page=name" Hi, I am using php dynamic listing from database. it is working but I wanna integrate to a horizontal css menu how can i integrate my codes to any css horizantal dropdown menu. thans. here my dynamic list. <?php function sinirsiz_kategori($parent) { $sql = mysql_query("SELECT * FROM kategoriler ORDER BY id DESC"); while($row = mysql_fetch_array($sql)) { $diziler[$row['id']] = array('baslik' => $row['baslik'],'parent' => $row['parent']); } $has_childs = false; foreach($diziler as $key => $value) { if ($value['parent'] == $parent) { if ($has_childs === false){ $has_childs = true; echo "\t<ul>"; } echo "<li><a href=\"".$value['baslik'].".php\">".$value['baslik']."</a>"; sinirsiz_kategori($key); echo "</li>\n"; } } if ($has_childs === true) echo "</ul>"; } ?> <?=sinirsiz_kategori(0)?> I'm having trouble getting the dynamic data from my <select> menus to write into my MYSQL database. Can anyone see what I'm doing wrong here? First post btw The output looks like this, which is obviously wrong: Code: [Select] <html> <head> </head> <link rel="stylesheet" type="text/css" href="./css/newuser.css" /> <body> <?php session_start(); require 'default.inc.php'; ?> <?php if (isset($_POST['amount'])): $host = 'localhost'; $user = 'user'; $pass = 'password'; $conn = mysql_connect($host, $user, $pass); if (!$conn) { exit('<p>Unable to connect to the database server</p>'); } if (!@mysql_select_db('spikesusers')) { exit('<p>Unable to locate the database</p>'); } $locationname = $_POST['donor']; $donorid = mysql_query("SELECT id FROM donors WHERE locationname='$locationname'"); $amount = $_POST['amount']; $year = $_POST['year']; $type = $_POST['type']; $typeid = mysql_query("SELECT id FROM donationtype WHERE type='$type'"); $player = $_POST['player']; //$playerid = mysql_query("SELECT id FROM players WHERE $sql = "INSERT INTO donations SET donorid='$donorid', amount='$amount', yearofdonation='$year', typeid='$typeid'"; mysql_query($sql); ?> <div class='standard'> <h1>Donation Management</h1> <?php if ($sql) { echo "New donation added "; echo "<p></p>"; echo "<a href=managedonations.php>Back to donation management</a>"; exit(); } else { echo "Error adding new donation"; echo "<a href=adddonation.php>Try again</a>"; exit(); } ?></div> <?php else: $host = 'localhost'; $user = 'user'; $pass = 'pass'; $conn = mysql_connect($host, $user, $pass); if (!$conn) { exit('<p>Unable to connect to the database server</p>'); } if (!@mysql_select_db('spikesusers')) { exit('<p>Unable to locate the database</p>'); } $donor=@mysql_query('SELECT id, locationname FROM donors'); ?> <div class='standard'> <h1>Donation Management</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label>Donor: <select class="text" name="donor"> <option value=new>Add a new donor...</option> <?php while ($donors=mysql_fetch_array($donor)) { $donorname=$donors['locationname']; echo "<option value='<?php echo $donorname;?>'>$donorname</option>"; //echo "<option value='hi'>hi</option>"; } ?> </option> </select> </label><br /> <label>Amount: <input class="text" type="text" name="amount" class="text" /></label><br /> <label>Year of donation: <select class="text" name="year"> <option value='2011'>2011</option> <option value='2010'>2010</option> <option value='2009'>2009</option> </select> </label><br /> <?php $player=@mysql_query('SELECT id, firstname, lastname FROM players'); ?> <label>Player: <select class="text" name="player"> <option value="player" selected="selected"></option> <?php while ($players=mysql_fetch_array($player)) { $playerfirstname=$players['firstname']; $playerlastname=$players['lastname']; echo "<option value=player>$playerfirstname $playerlastname</option>"; } ?> </select> </label><br /> <?php $type=@mysql_query('SELECT id, type FROM donationtype'); ?> <label>Donation type: <select class="text" name="type"> <?php while ($types=mysql_fetch_array($type)) { $donationtype=$types['type']; echo "<option value=type>$donationtype</option>"; } ?> </select> </label><br /> <input type="submit" value="SUBMIT" class="buttons"/> <input type="button" name="Cancel" value="CANCEL" onclick="window.location = 'managedonations.php'" class="buttons"/> </form> </div> <?php endif; ?> </body> </html> Hi all, completely new at this and have got myself stuck! I am trying to display a thumbnail image by connecting to my database and retrieving the URL that points to the image. I know that the connection is working but I can't seem to get it to point to the image. Probably something really simple. Here's my code: Code: [Select] <!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=iso-8859-1" /> <title>Image Swap Using CSS</title> <style type="text/css"> body { margin: 0; padding: 0; background-color:#000000; } img { margin: 0; padding: 0; border: none; } .test { margin: 0; padding: 0; width: 99px; height: 130px; } .test a:hover img { visibility:hidden; } </style> </head> <body> <?php // connect to the database mysql_connect("********", "****") or die(mysql_error()); mysql_select_db("eliteescorting") or die(mysql_error()); $start=0; // expand on the searches $data=mysql_query("SELECT * FROM escorts WHERE base = 'manchester' ORDER BY RAND()"); $num_results=@mysql_num_rows($data); for($ii = $start;$ii < $num_results; $ii++){ ?> <div class="test"><a href="#"><img src="<?php echo $data[$ii]['thumb'];?>" /></a></div> <?php } ?> </body> </html> In my mySQL field 'thumb' contains the full URL of the image ie http://www............ This is just for testing, I'll get round to sorting out security issues later. Your help will be greatly appreciated! Regards, Nortski. Is there a way to create dynamic content without the use of a Content Management System? I simply want to click on a link in my navigation menu and have that display the content in a div section and keep the content in a separate folder on the server. I didnt want to have to use a CMS to accomplish that because every other feature of it will be unused as I just simply want to display the content in a div when I click on the link. I use a simple test server on my Home PC that I use to format the articles in html from documents I have wrote in LibreOffice, so I dont really need all the features and sophistication of full blown CMS. But I also dont want a bunch of different files in my root folder if I can avoid it. I would rather keep the content in a separate folder and just pull it from there and display it on the main page when the link is clicked. Anyway, I dont know if its even possible or if its the best way, so I am open to suggestions as well. Some of the documents are quite long (like several chapters) and some are much shorter (just a few pages). Any help and ideas are much appreciated. Hi all This probarly looks really bad but im trying to replase tags that change. So far it only replaces the last tag and not well either. I will try to show you Code: [Select] function testfunc($value) { if ($value=='gallery'){$return .= "this gallery has worked = --$value--";} if ($value=='email'){$return .= "this email has worked = --$value--";} return $return; } $test = "this is a test {%email%} message {%gallery%} rtfgdsfgdsfg"; $test = preg_replace("#(.*){%(.*?)%}(.*)#is",'$1' . testfunc('$2') . '$3', $test); echo $test; this outputs this is a test {%email%} message rtfgdsfgdsfg but im trying to get this this is a test this email has worked = --email-- message this gallery has worked = --gallery-- rtfgdsfgdsfg Im sure im way off but I hope you can understand. Thank you for taking the time to read this post. |