PHP - Creating Link From Variable
ive done a page that works fine but id like to add links to the results so i can view the models.
working page here http://sts.hostei.com/dsgi/list_records.php in the make column i want a link that will only show the make clicked. if this was a fixed page i no how to do it but i cannot figure out to make it from the way ive discribed. i know i have to alter this line <td><div align="center"><?php echo $rows['make']; php?></div></td> but no idea how to do this. do i create a new page for the query? if so how do i pass the $var? is it possable to do this from the same page? ie appear undr the main table. Thanks <?php include("config.php"); // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql = "SELECT make, COUNT(*) AS total, SUM(IF(comments = \'pass\', 1, 0)) AS withComments FROM dsgi_serval GROUP BY make ORDER BY COUNT(*) DESC"; $result=mysql_query($sql); php?> <table width="319" border="1"><tr> <td colspan="4"><font size="4" face="Verdana"> <strong><div align="center">Validation Total's </div></strong></font> </td> </tr> <tr> <td width="137" align="center"><strong>Make</strong></td> <td width="85" align="center"><strong>Total</strong></td> <td width="75" align="center"><strong>Validated</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ php?> <tr> <td><div align="center"><?php echo $rows['make']; php?></div></td> <td><div align="center"><?php echo $rows['total']; php?></div></td> <td><div align="center"><?php echo $rows['withComments']; php?></div></td> </tr> <?php } php?> <tr> <td><div align="center">Totals</div></td> <td> <div align="center"> <?php // counts all rows $query = "SELECT make, COUNT(make) FROM dsgi_serval "; $result1 = mysql_query($query) or die(mysql_error()); // Print out result while($row1 = mysql_fetch_array($result1)){ echo $row1['COUNT(make)']; } ?> </div></td> <td><div align="center"> <?php // counts passes $query = "SELECT make, COUNT(make) FROM dsgi_serval where comments like 'pass'"; $result2 = mysql_query($query) or die(mysql_error()); while($row2 = mysql_fetch_array($result2)){ echo $row2['COUNT(make)']; } ?> </div></td> </tr> </table> <?php mysql_close(); php?> Similar TutorialsI need help making the variable $code in sessions.php to work with the email activation. sessions.php Code: [Select] <?php include(MODEL_PATH.'user.php'); switch ($route['view']){ case "register": break; case "signup": $errors = validate($register_validations, $params['register']); if($errors) { //$route['view'] = 'index'; $route['view'] = 'register'; //print_r($errors); flash_warning('Please correct errors!'); } else { $code = I need this variable to included the random number created in user.php so it can be sent in the email; $register = $params['register']; $username = $register['screen_name']; $to = $register['user_email']; $subject = "Activate your account"; $headers = "From: richard@whatsyouraction.com"; $body = "Hello $username,\n\nYou registered and need to activate your account by clicking the link below\n\nhttp://whatsyouraction.com/chatbox/emailactivation/activate?code=$code\n\nThanks!"; if (!mail($to,$subject,$body,$headers)) { flash_warning('We couldn\'t sign you up at this time. Please try again later.'); $route['view'] = 'register'; } else { create_user($params['user']); flash_notice('Successfully registered!'); redirect_to('sessions/login'); } } break; } ?>user.php Code: [Select] <?php function create_user($params) { db_connect_posts(); $code = rand(11111111,99999999); $query = sprintf("INSERT INTO users SET users.screen_name = '%s', users.user_email = '%s', users.user_pwd = '%s', users.image = '%s', created_at = NOW(), users.code = $code, users.active = '0'" , mysql_real_escape_string($params['screen_name']), mysql_real_escape_string($params['user_email']), md5($params['user_pwd']), mysql_real_escape_string($params['image']) ); $result = mysql_query($query); if(!$result) { return false; } else { return true; } } ?>register.php Code: [Select] <form action="<?php echo '/'.APP_ROOT.'/'; ?>sessions/signup" method="post"> <fieldset> <legend>Register</legend> <div> <label>Screen Name</label> <input name="register[screen_name]" size="40" type="text" /> </div> <div> <label>E-mail</label> <input name="register[user_email]" size="40" type="text" /> </div> <div> <label>Password</label> <input name="register[user_pwd]" size="40" type="password" /> </div> <div> <label>Image</label> <input name="register[image]" size="40" type="text" /> </div> <input type="submit" name="submit" value="Register" /> </fieldset> </form> ...snip...
function myFunction(){
title.php I have a small php script that runs a local command and outputs a simple text string.
I run myFunction every 5 seconds.
setInterval(function(){
rather than the above function setting the page title to "New Title", how do I set it to the output of title.php?
Thanks.
I'm working with classes and don't know much about them. It's pulling data from authorize.net when a transaction is run. Maybe this is a general thing someone can help with? I include an AIM.class.php file in the page that process the transaction, 'registration4.php'. In the AIM.class.php I have this code that does print the transaction id to the page. The variable $pstr_trimmed looks like it gets used over and over for each 'case' : Code: [Select] case 7: echo "Transaction ID: "; echo $pstr_trimmed; /* thought I could just add $trans_id_variable = $pstr_trimmed; (didn't work */ break; But I don't know how to use that to type echo "$trans_id_variable" on register4.php or to insert it into my database? Code: [Select] <?php require("AIM2.class.php"); // here the data is set and the card processed, then... if (!$approval = $aim->processCard("Workshops", $final_total)){ echo "<strong>Oops!</strong><br>Error proccessing credit card: " . print_r($aim->errorStack,1); $appcodedesc = "Error processing credit card."; $approval = 0; }else{ // If we made it this far, the card was successfully charged // here the code echoes "Transaction ID: 1111111 Payment Approved" echo "<strong><h3>Payment Approved</h3></strong><br>Successfully charged the credit card. Add the attendee(s) name(s) below and submit. On the next page, you can print for your records. Please note that these are secure pages for payment processing, and pressing the back button in your browser, will bring up an expired page<br><br>"; // Approval code: " . $approval; //echo $pstr_trimmed; echo "and the new variable?"; // but here's where I was hoping to take that transaction id and set it as a variable to put into the database. echo $trans_id_test; echo" should be before this"; $approval = 1; $appcodedesc = "Payment Approved"; Hello, forgive me if I didn't title this properly. I will try to make this short and sweet and explain it the best I can. I have a script I wrote that uses SimpleXML to parse data and that part works fine. Only problem is the data is kind of construed from the XML feed and I need to convert it to a more real world calculation. The script parses XML for lake level data. The problem is it returns conservation pool levels. The problem with that is lakes are not 400+ feet deep. As it is set up now the XML contains full pool and the current level. From that I display the full pool and the current levels. It then takes the full pool minus the current level to create two new variables, departure I.E. how low or high it is over full pool, then also create % full. The calculations are fine but, since it is basing it off conservation pool I need to translate this to display it in a more known way. What I am wanting to do is hard set the variable for full pool for the actual lake depth. I still need to use the full pool variable to calculate the rest even though I won't be showing that data. So full pool - minus current level to create the departure as it does. Then take the departure variable that was created and subtract/add it from the hard set lake depth to give me the actual new depth of the lake.
I.E.
$a +/- $b = $c
then
$c +/- $d = $e
I hope this makes sense. What I am trying to do is really simple. I am just not good at really explaining things and trying to comprehend how this needs to be laid out and the logic for it. If you need more info or the code I am working with please let me know. So how could I go about doing this?
-Thanks
Edited by Texan78, 28 November 2014 - 12:02 AM. Hello, all I know this isn't actually a PHP questions, but I thought you guys might be able to help. I am creating a software for a forum and would like to create a link to search for a tag word that can link to a search that can find the software. The website uses this for search: https://www.website.com/search.php?do=process I figured out this works to put the keyword in the tag box: https://www.website.com/search.php?tag=mysearchword I can't figure out how to combine the two to process the search. I tried things like this: https://www.website.com/search.php?do=process&tag=mysearchword But that and other variations did not work. Does anyone have any suggestions? Thanks! Edited July 5, 2019 by abberrationadded more info Hy, How can I put a link to a variable without doing like: Code: [Select] <a href='#'>$var</a> I heard that can be other ways. Thanks Hi guys, I want to find the most efficient way of setting a php variable through a link.
What I'm trying to achieve is to allow the user to select a category and their location and store the two variables to update my database results. I first used the GET method, but since the page refreshes when the user selects any other Get variable, so it ends up reseting the variables. Currently I have the category and locations as drop down menu with links to each of the options. I'll appreciate any help. Thank you. :]
Hi. I have a sort of security script which checks a few things, how can i save the url of the link that was clicked, so i can pass it through the script then if all is good, continue on to the url, if not send them somewhere else let me try to explain better with a little text picture user clicks link ----------------------> link goes to my security script --------------------> if the check passes, continue to original links url so basically i just need to know how to save the links url as a variable I have this link "https://localhost/what/index.php?album=parent%2Fsubalbum&image=1coffee.jpg" Am trying to insert a variable(eid=86) so that it comes before all other variables to read thus "https://localhost/what/index.php?eid=86&album=parent%2Fsubalbum&image=1coffee.jpg" Regards trying to post a link to the database Code: [Select] $amessage ="<a href="link.php">this is a link </a>"; then return that link later on another page. I have a page that lists out some basic information about each quiz this particular student has taken (call it "quiz summary"). I am creating another page that will have all details of a particular quiz by itself (call it "quiz detail"). If I have a link for each quiz on the "quiz summary" page, how do I tell the "quiz detail' page which link they clicked on? Or which quiz they have selected. I was thinking it would work if I assigned a session variable to each link and then the "quiz detail" page could verify which returns true still and show details for that quiz. Would this logic work? Npot sure how to do it anyone though. thanks for any help! Hey, I'm trying to save a MySQL-Link source as an instance variable in my query class. The problem is that MySQL sees it as an invalid MySQL-Link (supplied argument is not a valid MySQL-Link resource). What I'm I doing wrong? //Walle Code: [Select] private $connection; //Construct public function __construct(&$connection) { $this->connection = $connection; } //Where the error occurs public function exe_query($sql) { $result = mysql_query($sql, $this->connection); if(!$result) { throw new Exception(mysql_error()); } return $result; } Hi All, I'm sending an email with a link to a web page with a form on. Code: [Select] <tr style="padding:10px;"> <td align="center"> <a style="text-decoration:none;" href="http://www.foo.co.uk/bar.php?id=123"> <img src="/header.jpg" border="0" style="display: block;" width="380" height="64" alt="Logo" /> </a> </td> </tr> I currently GET the id from the URL and add it to a hidden field in the form which then sends the ID to the database on submit so I know from which email the user came from to fill out the form. This doesn't always work as I guess some people move from the form page to look at other pages on my site then come back to fill in the form. I think I need to use SESSION to keep the id 'active' but cannot figure out how to GET the id from the URL and put it into a SESSION, alas I am struggling to even start and finish a basic SESSION. Thanks in advance, Ben. I have to put a link that can be clicked around the first name and last name variables in the echo statement below. I also need to add a variable from the Select query to the link such as: 'www.phpfreaks.com/admin/customers.php?page=1&cID="VARIABLE HERE" &action=edit' I've tried a bunch of things and none seem to work. while($row = mysql_fetch_array($result)){ echo '<tr><td>' . $row['customers_firstname'] . " " . $row['customers_lastname'] . '</td><td>' . date("M. d, Y", strtotime($row['date'])) . '</td><td>' . $row['plan_id'] . '</td></tr>'; David Hello all! I am somewhat new to PHP and SQL, but I think I have a basic understanding of how the language works. I have read through a million different websites and forums, and have tried a million different ways but am just not getting anywhere! This is what I am trying to do... I have a text link that I want to click through to an outside URL from my website. This outside URL was already entered into an SQL database, and I just cant seem to get the text link to bring up the outside URL from the database. This is what I have so far... 1.) My webpage that I am working on is www.mywebsite.com/articles.php 2.) I want the text "Read more..." on this webpage to click through to an outside URL, like "http://www.google.com", which was already entered into an SQL database under the title of "article_link" in a new window 3.) So I would like for "Read more..." to click through the outside URL that was entered into "article_link" in the database Code: [Select] <?php echo <p><a href="\' . $article_link . '\" target="_blank">Read more...</a></p>; ?> Nothing I have tried has worked so far, nothing clicks through to the outside URL in the "article_link" entry from the database. Sorry if I am being redundant, I have been at this all day! Please help and thank you in advance!! $link = ?><a href="post?id=<?php echo $id; ?>&title=<?php echo $slug_title; ?>"><?php echo $title; ?></a><?phpBasically what I am trying to do is get a url link of a current page that I'll be sending in an email. I have all the $_GET variables I need to duplicate the current url. For some reason it's giving me an error. Can you please fix what is shown above into something that'll work? Thanks. Edited by man5, 15 July 2014 - 07:09 PM. Hi everyone, first of all let me thank you for this wonderful forum I come back here always when i need help... i'm trying to learn so soon i hope, i'll be helping others... I have a question for now, i have a code which goes like this: Code: [Select] <? $b = time (); $date1 =date( "Y-m-d;h:i:s" , mktime(date("h")+6, date("i"), date("s"), date("m") , date("d"), date("Y"))); $str_time = "&receivedtimestamp="; $str_msg = "&msg=bkt"; $str_from = "from="; ?> <a href="http://testext.i-movo.com/api/receivesms.aspx?<?echo $str_from;?><?=$getuser[0]['phone'];?><?echo $str_time;?><?echo $date1;?><?echo $str_msg;?>">Get a Cupon</a> What i need is that when the URL is generated, one of those variables to be hidden, for example the $str_from to be in the link but not visible... I must tell you that the link on the Get Cupon goes to an external link so i don't know if i can do it with .httpaccess as i've heard... This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=359149.0 Hi, I know it is probely not a regex question but I don't know the right category. I have 2 variables like $variable1 and $ variable2 which are placed in a loop now I want the $variable to be echo't in a link like <a href="http://exampe.com/$variable1"/> On this dynamicly generated page I want to output the $varible1 of this link and $variable2 while($row = mysql_fetch_assoc($result)) { echo " <tr>"; echo " <td>" . $row["variable1"] . "</td>"; echo " <td>" . $row["variable2"] . "</td>"; echo " </tr>"; Hi everybody,
I want to cloak my affiliate links or mask it so it looks like a pretty url. Also if possible, I want to track the clicked link with Google Analytics so I think I need a page where I can log the click.
I found lots of information but not for the situation I have. I get my links from my database like this:
echo '<a href="'.$info['url'].'">the link</a>';How can I accomplish this? So I need a url like www.mydomain.com/click and when a user click on the link the get a new page with a tracking code and a redirect script to the right url. Thanks so much for the help! Kind regards, Mark |