PHP - Adding More Then One Item In A Link
Is it possible to add more then one thing in a link? so i can $_GET more then one thing from a link
signup.php?state=1?name=sam i tried that and a few other things and it didnt work. Similar TutorialsHi All, not sure if this is a php Q but maybe someone has experience with this. I use a form for people to add an item to the bulletin board. Sometimes the loading of the page takes very long and people think it didn't work so they click reload and post the item twice. I thought of adding a loading.gif so people know they have to wait. Anyone know how and where to put that in? Code: [Select] <?PHP if(isset($_POST['submit'])) { if ($_POST['type']<>"") { $poster_id = $_SESSION['id']; $ID=$_GET['ID']; $short=$_POST['short']; $location=$_POST['location']; if(isset($_POST['type'])) { $type=$_POST['type']; } $starthour=$_POST['starthour']; $startmin=$_POST['startmin']; $endhour=$_POST['endhour']; $endmin=$_POST['endmin']; $reminders=$_POST['reminders']; $reminders=addslashes($reminders); if(isset($_POST['view'])) { $view=$_POST['view']; } if(isset($_POST['val'])) { $val=$_POST['val']; } $sql = mysql_query("SELECT * from bl_calender where dateclass='$ID' AND viewable='1'"); $numrows = mysql_num_rows($sql); // if the event exists then we want to edit it if ($numrows > 0){ // only the owner can edit an event while($row = mysql_fetch_array($sql)){ if($row['poster_id'] == $logOptions_id || $account_type == 'c' ){ $editcal="update bl_calender set datecotent='$reminders', location='$location', type='$type', starthour='$starthour', startmin='$startmin', endhour='$endhour', endmin='$endmin', short='$short', viewable='$view' where dateclass='$ID'"; mysql_query($editcal) or die("Could not edit calendar"); $msgToUser = '<br /><br /><font color="#FF0000">Your event has been updated. Close this window.</font><p></p>'; include_once 'msgToUser2.php'; } else { // you are not the owner $msgToUser = '<br /><br /><font color="#FF0000">Sorry but only the owner can change the event details.<br> Close this window.</font><p></p>'; include_once 'msgToUser2.php'; } } } else { // it's a new event we want to add $createevent="Insert into bl_calender (poster_id, dateclass, starthour, startmin, endhour, endmin, location, type, short, datecotent, viewable ) values ('$poster_id', '$ID', '$starthour', '$startmin', '$endhour', '$endmin', '$location', '$type', '$short', '$reminders', '1')"; mysql_query($createevent) or die(mysql_error()); $sql2 = mysql_query("SELECT * FROM myMembers WHERE notification_calendar='1'"); // query the members who want an email $numrows = mysql_num_rows($sql2); if ($numrows > 0){ while($row = mysql_fetch_array($sql2)){ if($row['email'] =="") { $to = $row['email_work']; } else { $to = $row['email']; } $your_firstname = $row['firstname']; $your_lastname = $row['lastname']; // send an email to everyone who wants it $webmaster = "KAI-DEFAT@minbuza.nl"; $headers = "From: MAAC Webmaster<$webmaster>"; $subject = "A new message has been posted in the MAAC Calendar."; $message = "Hello $your_firstname $your_lastname, a new event has been posted in the MAAC Calendar.\n"; $message .= "Goto the MAAC website to get the details.\n"; $message .= "Click here to view the Calendar $dyn_www/Web_Intersect/calen.php\n"; // send email mail($to, $subject, $message, $headers); } } } $msgToUser = '<br /><br /><font color="#FF0000">Your event has been created, Close this window.</font><p></p>'; include_once 'msgToUser2.php'; } ?> Hi there, I'm creating a shopping cart and to work out postage cost I need to add all the items weights together. The weight of each item is in the database. I currently have this code: Code: [Select] $basket = $_SESSION['basket']; if ($basket) { $items = explode(',',$basket); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } foreach ($contents as $id=>$qty) { $sql = "SELECT * FROM store WHERE id LIKE '$id' AND live LIKE '0'"; $result = mysql_query($sql); while ($rows = mysql_fetch_array($result)) { extract($row); so to work out each item's weight I can do $rows['weight'] * $qty. but how could i add all the item's weight together? i hope that makes some sense. thanks, jack OK, so I have a form which submits the id of an item on a shopping site as well as the size selected by the customer. Size S/M is 1 Size M/L is 2 To get what has been submitted when they click "Add To Basket" i have this code: Code: [Select] $sizechoice = $_POST['sizechoice']; $basket = $_SESSION['basket']; $action = $_GET['action']; switch ($action) { case 'add': if ($basket) { $basket .= ','.$_GET['id'].'-'.$sizechoice; } else { $basket = $_GET['id']; } } I used to have it like that, but minus $sizechoice, so the basket was just ids like 1,5,3,2. Now each id is accompanied by a size choice, so it would be 1-1,5-1,3-2,2-1 for example. How can I later separate the id from the size again using the dash? Thanks, Jack I have am working on a shopping cart, for coupong buying. Here it only allows me to add one Item or One deal ata time into shopping cart. How can I change this code to accept more than one deal at a time before checking out. Code: [Select] { // add to cart /* $cart = unserialize(JFactory::getSession()->get('cart')); if (empty($cart)) $cart = new Cart(); */ // We only allow 1 item per cart from now one... $cart = new Cart(); $cart->addItem($deal); JFactory::getSession()->set('cart', serialize($cart)); $dealName = $deal->name; $buy4friend = $_GET['buy4friend']; $cartItemCount = $cart->getItem($dealId)->getCount(); if($buy4friend == 1) { $msg = $dealName . " :::<b> ". JText::_("DEAL_ADD_TO_CART_MESUN"); $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=viewCart&buy4friend=1", false); JFactory::getApplication()->redirect($link, $msg); }else{ $msg = $dealName . " ". JText::_( "DEAL_ADD_TO_CART"); $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=viewCart&buy4friend=0", false); JFactory::getApplication()->redirect($link, $msg); } I have a script that seems to work well to insert a bookmark into a users database when he/she is logged into the system but I am having a hard time figuring out how I would go about making a work-a-round for having an item selected before being logged in, and inserted after they have logged in or registered. For example, I would like a user to be able to select an Item to add to bookmark whether that user is logged in/registered or not and if they are not, they would be greeted with a login/registration form and after successful login the add bookmark script would be initiated on the item previously selected. What I've got this far: Simple form to add bookmark: <form name="bm_table" action="add_bms.php" method="post"> <input type="text" name="new_url" value="http://" /> <input type="submit" value="Add Bookmark"/> </form> Then I have the add bookmark script: BEGIN php $new_url = $_POST['new_url']; try { check_valid_user(); //cannot get past this part since it ends the script....code below if (!filled_out($_POST)) { throw new Exception('Form not completely filled out.'); } // check URL format if (strstr($new_url, 'http://') === false) { $new_url = 'http://'.$new_url; } // check URL is valid if (!(@fopen($new_url, 'r'))) { throw new Exception('Not a valid URL.'); } // try to add bm add_bm($new_url); echo 'Bookmark added.'; // get the bookmarks this user has saved if ($url_array = get_user_urls($_SESSION['valid_user'])) { display_user_urls($url_array); } } catch (Exception $e) { echo $e->getMessage(); } END php Checking valid user - the portion I cannot get past in the above script: function check_valid_user() { // see if somebody is logged in and notify them if not if (isset($_SESSION['valid_user'])) { echo "Logged in as ".$_SESSION['valid_user'].".<br />"; } else { // they are not logged in do_html_heading('Problem:'); echo 'You are not logged in.<br />'; do_html_url('login.php', 'Login'); do_html_footer(); exit; } } How would I go about modifying the script so that a user could fill in the form (later it would be a link...obviously they probably wouldn't be filling in a form that is log-in specific - but same concept I think) Thanks in advance for the help! tec4 Hi there, I think this is a big question but I'd appretiate any help you can provide!! I have a list of items and subitems in a table that looks like this: id parent_id title 1 0 House Chores 2 1 Take Out Trash 3 1 Clean Room 4 0 Grocery List 5 4 Eggs 6 4 Produce 7 6 Lettuce 8 6 Tomato 9 4 Milk I want to display it like this: (+) House Chores: > Take Out Trash > Clean Room (+) Grocery List: > Eggs (+) Produce > Letutce > Tomato > Milk So basically each entry in the table has an unique id and also a parent id if it's nested inside another item. I "sort of" got it figured out in one way, but it doesnt really allow for nested subgroups. I'd like to know how would y'all PHP freaks to this Also taking suggestions for the javascript code to expand/collapse the tree !! Thank you! Hey guys, Been working on a project but only recently started using php. What happens is.... I have a general quiz split accross a multipage form and then a results section. The problem is, is that when it comes to if statements on the last page and deciding the difficulty level for the users quiz, it wont let me add the 3rd and final link. Here is the code to explain. I have put bits in bold and a comment. (at the bottom section) I've tried everything, Thanks for any help in advance guys. Code: [Select] <?php session_start(); $_SESSION['q11'] = $_POST['q11']; $_SESSION['q12'] = $_POST['q12']; $_SESSION['q13'] = $_POST['q13']; $_SESSION['q14'] = $_POST['q14']; $_SESSION['q15'] = $_POST['q15']; $protectscore = 0; //initialize score to zero $detectscore = 0; $resolvescore = 0; $overallScore = 0; ?> <html> <head> <title>Results</title> <h1>Protection Section</h1> <p><b>Question 1</b> <?php if ($_SESSION['q1'] == "1"){ echo("<b>Correct</b>"); $protectscore = $protectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 2</b> <?php if ($_SESSION['q2'] == "2") { echo("<b>Correct</b>"); $protectscore = $protectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 3</b> <?php if ($_SESSION['q3'] == "3") { echo("<b>Correct</b>"); $protectscore = $protectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 4</b> <?php if ($_SESSION['q4'] == "1") { echo("<b>Correct</b>"); $protectscore = $protectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 5</b> <?php if ($_SESSION['q5'] == "2") { echo("<b>Correct</b>"); $protectscore = $protectscore +1; }else{ echo("<b>Incorrect</b>"); } ?> <h1>Detection Section</h1> <b>Question 1</b> <?php if ($_SESSION['q6'] == "3") { echo("<b>Correct</b>"); $detectscore = $detectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 2</b> <?php if ($_SESSION['q7'] == "3") { echo("<b>Correct</b>"); $detectscore = $detectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 3</b> <?php if ($_SESSION['q8'] == "1") { echo("<b>Correct</b>"); $detectscore = $detectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR><b>Question 4</b> <?php if ($_SESSION['q9'] == "2") { echo("<b>Correct</b>"); $detectscore = $detectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR><b>Question 5</b> <?php if ($_SESSION['q10'] == "1") { echo("<b>Correct</b>"); $detectscore = $detectscore +1; }else{ echo("<b>Incorrect</b>"); } ?> <h1>Resolve Section</h1> <b>Question 1</b> <?php if ($_SESSION['q11'] == "2") { echo("<b>Correct</b>"); $resolvescore = $resolvescore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 2</b> <?php if ($_SESSION['q12'] == "1") { echo("<b>Correct</b>"); $resolvescore = $resolvescore +1; }else{ echo("<b>Incorrect</b>"); } ?><b><BR>Question 3</b> <?php if ($_SESSION['q13'] == "3") { echo("<b>Correct</b>"); $resolvescore = $resolvescore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR><b>Question 4</b> <?php if ($_SESSION['q14'] == "3") { echo("<b>Correct</b>"); $resolvescore = $resolvescore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 5</b> <?php if ($_SESSION['q15'] == "1") { echo("<b>Correct</b>"); $resolvescore = $resolvescore +1; }else{ echo("<b>Incorrect</b>"); } ?> </p> <hr> <b>Total Sco </b>You answered <?php echo ($protectscore + $detectscore + $resolvescore); ?> question<?php if ($overallScore != 1) { echo("s"); } ?> Correctly <?php $qs = '15'; $overallScore = $protectscore + $detectscore + $resolvescore; $overallPercent = number_format(($overallScore * 100) / $qs); $ProtectionPercent = number_format(($protectscore * 100) / 5); $DetectionPercent = number_format(($detectscore * 100) / 5); $ResolvingPercent = number_format(($resolvescore * 100) / 5); ?><BR> <strong>Total Percentage is:</strong> <?php echo $overallPercent?> % <BR> Your Percentage From Protection Section is: <?php echo $ProtectionPercent?> % <BR> Your Percentage From Detection Section is: <?php echo $DetectionPercent?> %<BR> Your Percentage From Resolving Section is: <?php echo $ResolvingPercent?> %<BR> <HR> This section adds the link perfectly fine <?php if ($ProtectionPercent <= 30){ // beg echo '<li><a href="http://www.google.com> View Personalised Protection Content</a>'; } elseif ($ProtectionPercent > 30 && $ProtectionPercent <= 60){ //int echo '<li><a href="http://www.youtube.com"> View Personalised Protection Content</a>'; } else //exp { echo '<li><a href="http://www.facebook.com">View Personalised Protection Content</a>'; } ?><BR> <HR> This link add fine, however when i add the resolving if statement. This link disappear here and the Resolving section just doesnt appear <?php if ($DetectionPercent <= 30){ // beg echo '<li><a href="http://www.google.com> View Personalised Detection Content</a>'; } elseif ($DetectionPercent > 30 && $DetectionPercent <= 60){ //int echo '<li><a href="http://www.youtube.com"> View Personalised Detection Content</a>'; } else //exp { echo '<li><a href="http://www.facebook.com">View Personalised Detection Content</a>'; } When this part is added, this is when the error occurs <?php if ($ResolvingPercent <= 30){ // beg echo '<li><a href="http://www.google.com> View Personalised Resolving Content</a>'; } elseif ($ResolvingPercent > 30 && $ResolvingPercent <= 60){ //int echo '<li><a href="http://www.youtube.com"> View Personalised Resolving Content</a>'; } else //exp { echo '<li><a href="http://www.facebook.com">View Personalised Resolving Content</a>'; } ?> ?> MOD EDIT: [code] . . . [/code] tags added. Hey Guys, I'm querying a database that is going to return a html page. In this page I'm going to define content areas with a class. eg: <div class="category"></div> Anywhere I have this class in the html code, I want to dynamically insert a link into it. So when I retrieve the code from the database, I need the code to check for this tag (class="category") and add a standard link (<a href="..">Add new Category</a>) Not 100% sure whats the most efficient way to go about this. i have a database field called photo. it is used to generate photo id in a software progam for our soccer league. I also want to be able to view the photo on our approval page. could someone help me with the coding of the http h-link? i am having issues with it. the photo field has the following paramaters: images/picture.jpg i want the link on the approval page to look like this: <a href="http://bccsl.org/managers/images/picture.jpg">"http://bccsl.org/managers/images/picture.jpg</a> thanks stefan Code: [Select] <?php /* connection and protection */ include 'dbc.php'; page_protect(); mysql_query( "SET NAMES utf8" ); if(isset($_POST["update"]) AND isset($_POST["hiddenid"])) { $updated=false; $activateapproved=array(); $deactivateapproved=array(); foreach($_POST["hiddenid"] AS $value) { if(isset($_POST["checkboxapproved"][$value])) $activateapproved[]=intval($value); else $deactivateapproved[]=intval($value); } if(count($activateapproved)>0) { $SQL=sprintf("UPDATE players SET approved=1 WHERE id in (%s)" , implode(",", $activateapproved)); mysql_query($SQL) OR DIE(mysql_error()); $updated=true; } if(count($deactivateapproved)>0) { $SQL=sprintf("UPDATE players SET approved=0 WHERE id in (%s)" , implode(",", $deactivateapproved)); mysql_query($SQL) OR DIE(mysql_error()); $updated=true; } if($updated==true) { header("Location: ".$_SERVER["PHP_SELF"].""); exit(); } } ?> <!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" /> <title>Player Approval</title> <script type="text/javascript" src="public_smo_scripts.js"></script> <link href="styles.css" rel="stylesheet" type="text/css"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main"> <tr> <td colspan="3"> </td> </tr> <tr> <td width="160" valign="top"> <? include 'menu.php'; ?> <p> </p> <p> </p> <p> </p> <p> </p></td> <td width="732" valign="top"><p> </p> <?php if(isset($_GET["todo"]) AND $_GET["todo"]=="updated") { echo "Updated succesfully"; } ?> <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" name="Form"> <table border="1" cellpadding="2" cellspacing="2"> <tr> <td><div align="center">First</div></td> <td><div align="center">Last</div></td> <td><div align="center">Address</div></td> <td><div align="center">City</div></td> <td><div align="center">Postal</div></td> <td><div align="center">Phone #</div></td> <td><div align="center">Feet</div></td> <td><div align="center">Inches</div></td> <td><div align="center">Weight</div></td> <td><div align="center">Birthdate</div></td> <td><div align="center">Team ID</div></td> <td><div align="center">Type</div></td> <td><div align="center">photo</div></td> <td><div align="center">Date Added</div></td> <td><div align="center">Approved</div></td> </tr> <?php $sql="select * from players where teamid='$_POST[teamid]' order by status ASC"; $res=mysql_query($sql) or die(mysql_error()); while($r=mysql_fetch_assoc($res)) { ?> <tr> <input type="hidden" name="hiddenid[]" value="<?php echo $r["id"]?>"> <td> <div align="center"><?php echo empty($r["first"])?' ':htmlspecialchars($r["first"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["last"])?' ':htmlspecialchars($r["last"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["address"])?' ':htmlspecialchars($r["address"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["city"])?' ':htmlspecialchars($r["city"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["postal"])?' ':htmlspecialchars($r["postal"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["phone"])?' ':htmlspecialchars($r["phone"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["feet"])?' ':htmlspecialchars($r["feet"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["inches"])?' ':htmlspecialchars($r["inches"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["weight"])?' ':htmlspecialchars($r["weight"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["birth"])?' ':htmlspecialchars($r["birth"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["teamid"])?' ':htmlspecialchars($r["teamid"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["status"])?' ':htmlspecialchars($r["status"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["photo"])?'<a href="http://bccsl.org/managers/:htmlspecialchars($r["photo"])</a>'; ?> </div></td> <td> <div align="center"><?php echo empty($r["dateadded"])?' ':htmlspecialchars($r["dateadded"]); ?> </div></td> <td> <div align="center"> <input type="checkbox" name="checkboxapproved[<?php echo $r["id"]?>]" value="1"<?php echo empty($r["approved"])?'':' checked="checked"'; ?> /> </div></td> </tr> <?php } ?> </table> <p> <input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/> select/unselect <input type="submit" value="update" name="update"> </p> </form> <table width="178" border="1" cellpadding="0" cellspacing="1"> <tr> <th colspan="2" scope="col">Type</th> </tr> <tr> <td width="113"><div align="center">Church Player</div></td> <td width="50"><div align="center">1</div></td> </tr> <tr> <td><div align="center">Import Player</div></td> <td><div align="center">2</div></td> </tr> <tr> <td><div align="center">Witness Player</div></td> <td><div align="center">3</div></td> </tr> </table> </td> <td width="196" valign="top"> </td> </tr> <tr> <td colspan="3"> </td> </tr> </table> </body> </html> <a href="http://bccsl.org/managers/">http://bccsl.org/managers/</a> I am sending emails using PHPMailer. My configuration is below.
When adding a link to the message, should I use anchor tags? Both seem to work. What is the implication to recipients who are not using HTML email?
On a side note, if anything below seems wrong, please let me know.
Thanks
$msg='<p>Hello</p><p>Link: http://phpmailer.worxware.com/</p><p>Link: http://phpmailer.worxware.com</p><a href="http://phpmailer.worxware.com">http://phpmailer.worxware.com</a>'; $mail = new myPHPMailer(true); $mail->AddReplyTo('myEmail@xxx.com', 'Michael Reed'); $mail->SetFrom('myEmail@xxx.com', 'Michael Reed'); $mail->AddAddress('johndoe@xxx.com', 'John Doe'); $mail->Subject = "Here is your email"; //AltBody property need not be sent since PHPMailer will create an alternate automatically $mail->MsgHTML($message); return ($mail->Send()); class myPHPMailer extends PHPMailer { public function __construct($allow_exceptions=false){ $this->isSMTP(); $this->SMTPDebug = 0; $this->Host = "smtp.gmail.com"; $this->Port = 587; $this->SMTPSecure='tls'; // sets the prefix to the server. Used for gmail only. $this->SMTPAuth = true; $this->Username = 'xxx'; $this->Password = 'xxx'; } } I'm trying to add a link to edit my results. Not sure the best way to create the link, nothing I've tried works. There's probably a better way than what I've tried: echo 'There were ', mysql_num_rows($result), ' Matching Photographers:'; while ($row = mysql_fetch_array($result)) { echo "<br />Photographer Info:<br />"; echo "Photographer Name: $row[name]<br />"; echo "Photographer Email: $row[email]<br />"; echo "Photographer ID: $row[PHOTOGRAPHERID]<br />"; echo "Photographer Company: $row[c_name]<br />"; echo "Edit Photographer <a href="update.php?id=' . $row[PHOTOGRAPHERID] . '">Here</a>"; } I have an 'I agree' button on this page https://www.setstuffrentals.com/credit-card-authorization/
I basically need the button to redirect to another web page after a customer hits 'I agree'. I don't know PHP much. Can someone help step by step, please? I have been becoming more and more familiar with PHP over the past few months, but this problem stumps me. How can I take a string of words separated by spaces taken from an XML feed (example: word1 word2 word3 word4) and turn it into something like this: <a href="word1">word1</a> <a href="word2">word2</a> ... and so on. This has to be done on the fly, since it is taking the words from the XML feed, they change depending on the page. I want them to be in a vertical column, and be able to link each one to the search page for that word, so each link has to be different. An even more in-depth problem, how can I sort it then so that there are multiple columns if necessary, say one page only has 3 words, but another has 50. How can I split them up into multiple vertical columns, say with 10 words in each? Have I confused anyone yet? Hi,
I am using fancybox on my site and the function I am using to display the title and data-caption is this.
$(document).ready(function() { $('.fancybox').fancybox({ beforeShow : function(){ this.title = this.title +"<br>" + $(this.element).data("caption"); } }); }); // readyI would like to change this so that I can add a hypertext link. Here is what a sample of the HTML looks like: <img src="img/portfolio/GSI_web.png" height="194" width="400" alt="Globalsoftwareinc.com" /> <h4>www.globalsoftwareinc.com</h4> <div class="portfolio-desc align-center"> <div class="folio-info"> <h5><a title="globalsoftwareinc.com" href="#" title="www.globalsoftwareinc.com">Globalsoftwareinc.com</a></h5> <a title="Global Software Inc. website" href="img/portfolio/GSI_web_large.png" class="fancybox" data-caption="I was the interactive web designer at Global Software, Inc. and assisted in the re-design and development of Global Software, Inc. in Drupal<br>www.globalsoftwareinc.com"><i class="fa fa-plus fa-2x"></i></a> </div> </div> </div> </article>so for example I would want to make www.globalsoftwareinc a hyperlink and that isn't do-able currently. It breaks the code. thanks in advance! Hi, I am adding "active_filter", "passive_filter" classes to links based on regex pattern coming from the URL: Line 46: https://github.com/laanes/product_filtering/blob/master/APF_URL.php The function gets called on line 89 in he https://github.com/laanes/product_filtering/blob/master/boxes/advanced_product_filtering_box.inc.php You can see it in action he http://www.swanseatimber.co.uk/shop/hafele/brand_281.html by clicking on a category on the left, under the heading "Filter Your Results". The clicked category gets a green background because of the added "active_filter" class. When you click again, it will get "passive_filter" class and the products are not filtered any more. The problem: When moving to other pages by using the pagination at the top of the product results, the class doesn't get added. Therefore, you can't remove the filter because function creating the href on line 72 in he https://github.com/laanes/product_filtering/blob/master/APF_URL.php and the function clearing all filters on line 100 in he https://github.com/laanes/product_filtering/blob/master/APF_URL.php both fail. What's interesting - when selecting a filter, moving to the next page, clicking in the browser url bar and hiting enter(hard reload i think?), the problem disappears and you can play with the filters again. I really hope you find a minute to look into it and help me. Well I am looking to change this url Code: [Select] http://website.com/product.php?Item=2369 to Code: [Select] http://website.com/product.php?Item=Item-Name Heres a snip of the code that handles that. <?php include_once('mysql_connect.php');$id = (int)$_GET['Item'];?>() any help would be appreciated. Hi, I've read a lot of places that it's not recommended to store binary files in my db. So instead I'm supposed to upload the image to a directory, and store the link to that directory in database. First, how would I make a form that uploads the picture to the directory (And what kinda directories are we talking?). Secondly, how would I retrieve that link? And I guess I should rename the picture.. I'd appreciate any help, or a good tutorial (Haven't found any myself). Hi, I'm hoping someone can lead me in the right direction here. I'm creating a simple shopping cart that I will later pass on to Paypal for payment but my problem is, it won't add the items to my shopping cart when I click add to cart. My products are on different pages and I'm not sure if that is going to matter. When I click "add to cart" nothing gets added and it says my cart is empty. I have two tables with the following columns: 1. products: productId productName productDesc productPrice link (for dynamically creating the page links on the main product page) 2. productscents scentId scentName scentDesc Here is the add code that is in my first products page (Elite Hand Cream): Code: [Select] <?php if(isset($_GET['action']) && $_GET['action'] == "add") { $id = intval($_GET['id']); $desc=intval($_GET['desc']); if (isset($_SESSION['cart'][$id])) { $_SESSION['cart'][$id]['quantity']++; } else { $sql3 = "SELECT * FROM products WHERE productId=[$id]"; $sql4= "SELECT * FROM productscents WHERE scentId=[$desc]"; $query3 = mysql_query($sql3); $query4 = mysql_query($sql4); if(mysql_num_rows($query3) != 0) { $row3 = mysql_fetch_array($query3); $row4 = mysql_fetch_array($query4); $_SESSION['cart'][$row3['productId']] = array("quantity" => 1, "price" => $row3['productPrice'], "desc" => $row4['scentId']); } } } ?> Here is code I have for the $_SESSION: Code: [Select] <?php if(isset($_SESSION['cart'])) { $sql5= "SELECT * FROM products,productscents WHERE productId IN ("; foreach($_SESSION['cart'] as $id => $value) { $sql5 .= $id . ","; } $sql5 = substr($sql,0,-1) . ") ORDER BY productId, scentId ASC"; $query = mysql_query($sql5); if(!empty($query)) { while($row = mysql_fetch_assoc($query)) { ?> <?php echo $row['productName'];?><?php $_SESSION['cart'][$row['productId']]['quantity'];?> <?php } } else { echo "You need to add an item to your cart";} } Here is the code that I have for the "add to cart" and "view cart": Code: [Select] <a href=#&action=add&id=<?php echo $prodId;?>&desc=<?php echo $scent_id[$y];?>>Add to Cart</a><br><a href="cart.php">View Cart</a> This grabs the correct product Id and scent Id which I want and no errors are being displayed on the page. I'm not sure where to begin with this. LOL. I'm new to PHP and I used a tutorial to help with the code. Any help would be greatly appreciated. i have this while loop making my category links at the top of my page, but i still have the bullet after the last item. ive looked at other examples and CANNOT get mine to follow suit...help please? Code: [Select] $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query1 = "SELECT * FROM ob_category"; $data1 = mysqli_query($dbc, $query1); while($row=mysqli_fetch_array($data1)){ echo '<a href="viewlistings.php">' . $row['name'] . '</a> • '; } I am working on a script for a simple form with only 2 options that are dropdowns. I need to validate these two options that there is a selection made. I have gotten the first one to validate, but I cannot get the second one to validate. Can anyone steer me in the right direciton why only one is working? I get no errors in the script, so I assume I am just missing something. Code: [Select] <?php // options for drop-down menu $choices = array('-- Choose Your Item','Anniversary Jacket', 'Anniversary T-Shirt'); $sizes = array('-- Choose Your Size','L', 'XL'); if($_SERVER['REQUEST_METHOD'] == 'GET'){ // display form when GET showForm(array()); } else{ // process form if POST $errors = validateForm(); if(count($errors)) showForm($errors); // if errors show again else print 'Form submitted succesfully!'; // no errors } // function generating form function showForm($errors){ global $choices,$sizes; // set defaults $defaults = array(); foreach($choices as $key => $choice){ if(isset($_POST['item']) && ($_POST['item'] == $key)) $defaults['item'][$key] = 'selected'; else $defaults['item'][$choice] = ''; } foreach($sizes as $key => $size){ if(isset($_POST['size']) && ($_POST['size'] == $key)) $defaults['size'][$key] = 'selected'; else $defaults['size'][$size] = ''; } // print form print "<form action='{$_SERVER['SCRIPT_NAME']}' method='post'>"; print "<div>"; print "<select name='item'>"; foreach($choices as $key => $choice){ print "<option value='{$key}' {$defaults['item'][$key]}>{$choice}</option>"; } print "</select>"; showError('item', $errors); print "</div>"; print "<div>"; print "<select name='size'>"; foreach($sizes as $key => $size){ print "<option value='{$key}' {$defaults['size'][$key]}>{$size}</option>"; } print "</select>"; showError('size', $errors); print "</div>"; print "<input type='submit'/>"; print "</form>"; } // display error function showError($type, $errors){ if(isset($errors[$type])) print "<b>{$errors[$type]}</b>"; } // validate data function validateForm(){ global $choices,$sizes; // start validation and store errors $error = array(); // validate drop-down if(!(isset($_POST['item']) && (array_key_exists($_POST['item'], $choices)) && $_POST['item'] != 0)) $errors['item'] = 'Select Item'; return $errors; // validate drop-down if(!(isset($_POST['size']) && (array_key_exists($_POST['size'], $choices)) && $_POST['size'] != 0)) $errors['size'] = 'Select Size'; return $errors; } ?> |