PHP - Help Adding <a Href> To Echo
Hi guys,
I'm trying to add this link <a href="<?php CONFIG_SITE_PATH ?>/settings.php"> to somewhere in the red text below. Can someone please show me how/where I would do this. $userObj->_userId = $_SESSION['G_userId'.CONFIG_SITE_NAME]; $userObj->getUserDetails(); echo '.$userObj->_name.'</span> / <a href="logout.php" >Logout</a></span>'; Similar TutorialsHi, my PHP skills are kinda weak and I've been trying to get this to work, but for some reason, the href isn't linking properly. Can anyone help me with this? Code: [Select] $titlehigh = preg_replace ( "'($var)'si" , "<strong> \1</strong>" , $row_linkcat[ 'sid' ] ); $linkhigh = preg_replace ( "'($var)'si" , "<strong> \1</strong>" , $row_linkcat[ 'title' ] ); $linkdesc = preg_replace ( "'($var)'si" , "<strong> \1</strong>" , $row_linkcat[ 'creator' ] ); $filehigh = preg_replace ( "'($var)'si" , "<strong> \1</strong>" , $row_linkcat[ 'file' ] ); $linkpic = preg_replace ( "'($var)'si" , "<strong> \1</strong>" , $row_linkcat[ 'parent' ] ); foreach($trimmed_array as $trimm){ if($trimm != 'b' ){ $titlehigh = preg_replace( "'($trimm)'si" , "<strong> \1</strong>" , $titlehigh); } //end highlight ?> <p> <center> <?php echo "<a href='http://www.wootability.com/WootStrips/newstrips.php?id='" . $linkpic . "'>$linkhigh</a>"; ?><br /> For some reason, the href is just a blank id. I'd be very appreciate if anyone could help. Thanks! how to echo href id value Thanks ! Code: [Select] if (isset($_GET['edit']) && $_GET['edit'] == 'textupdate') { echo " {$_GET['id']} ! <br>" ; } <a href= \"{$_SERVER['PHP_SELF']}?edit=textupdate\" id=\"edit{$row['id']}\" >Edit</a> I can't figure out how to write the a href part to make it blend in with the existing img syntax. How do I alter this? Code: [Select] <?php echo '<a href=\"{$r['feedusername']\"><img src="', getUserAvatar($r['feedusername']), "\" class=\"avatar mediumsmall newspadding f_left mrl\" title=\"${r['associate_name']}\" alt=\"${r['associate_name']}\" /></a>"; ?> Hi all, I am trying to add the echo " AND "; below to the variable $model if the $_POST['purchasetype'] has a value. how can you add echos within IF statements to a variable, if at all possible? Many thanks, <?php if ($_POST[model] !="") { $model = "model='". $_POST['model'] ."'"; if ($_POST['purchasetype'] !="") { echo " AND "; } } else { $model = ""; } ?> I posted yesterday and wasnt very clear or the question was way to broad... here is my issue condensed and hoping someone can help me... I am using a sports component and mods in Joomla 1.5 --- that displays a standings table with game results- next game... i am trying to drop/add the team logo next to the team name in the table/s... this is the code from the team page echoing the logo and putting it next to the team name--- see bottom where i have it spaced out.... as you can expect it isn't working of course Code: [Select] <?php if ($this->params->get('team_logo') == 1 && $this->team->logo) { ?> <!-- team logo --> <div style="display: inline; float: left; padding-left: 2px;"> <img src="<?php echo JURI::base() . $this->params->get('images_path') . $this->team->logo;?>" alt="<?php echo stripslashes($this->team->name);?>" title="<?php echo stripslashes($this->team->name);?>" border="1" /><br /> <br /> </div> <!-- team logo --> <?php } ?> and here is the code from the standings module: i highlighted where in the table the logo would be called... i understand broad question here; but, was hoping someone could help me out with this... Code: [Select] <?php /** * @version $Id: mod_gridiron_win_loss.php, v1.5.0 March 2011 01:32:15 * @author Fastball Productions * @package Gridiron * @copyright Copyright (C) 2011 Fastball Productions * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // no direct access defined('_JEXEC') or die('Restricted access'); $db =& JFactory::getDBO(); // get the module parameters $heading = $params->get( 'heading', '' ); $seasonid = $params->get( 'seasonid', '1' ); $gametypes = $params->get( 'gametypes', '1' ); $teamids = $params->get( 'teamids', '' ); $leagueids = $params->get( 'leagueids', '' ); $divisionids = $params->get( 'divisionids', '0' ); $wheading = $params->get( 'wheading', 'Wins' ); $lheading = $params->get( 'lheading', 'Losses' ); $winpctheading = $params->get( 'pctheading', 'Winning Percentage' ); $gamesplayedheading = $params->get( 'gpheading', 'Games Played' ); $pointsforheading = $params->get( 'pfheading', 'Points For' ); $pointsagainstheading = $params->get( 'paheading', 'Points Against' ); $theading = $params->get( 'theading', 'Ties' ); $showties = $params->get( 'showties', 0 ); if (is_array($gametypes)) { $gametypes = implode(',', $gametypes); } if (is_array($teamids)) { $teamids = implode(',', $teamids); } if (is_array($leagueids)) { $leagueids = implode(',', $leagueids); } if (is_array($divisionids)) { $divisionids = implode(',', $divisionids); } // win/loss/ties variables; $wins = 0; $losses = 0; $ties = 0; // if there are team ids, division ids, or league ids configured, get all of the divisions to separate them; if ($teamids || $divisionids || $leagueids) { if ($teamids) { //$db->setQuery("SELECT d.id, d.division FROM #__fastball_division AS d LEFT JOIN #__fastball_team AS t ON d.id = t.divisionid WHERE (t.published = 1 AND t.divisionid IS NOT NULL AND FIND_IN_SET(t.id, '{$teamids}')) GROUP BY d.id ORDER BY d.division"); $divisions[] = -1; } else if ($divisionids) { //$db->setQuery("SELECT d.id, d.division FROM #__fastball_division AS d LEFT JOIN #__fastball_team AS t ON d.id = t.divisionid WHERE (t.published = 1 AND t.divisionid IS NOT NULL AND FIND_IN_SET(d.id, '{$divisionids}')) GROUP BY d.id ORDER BY d.division"); $db->setQuery("SELECT d.id, d.division FROM #__gridiron_division AS d LEFT JOIN #__gridiron_team AS t ON d.id = t.divisionid LEFT JOIN #__gridiron_schedule AS s ON (t.id = s.visitingteam OR t.id = s.hometeam) WHERE (t.published = 1 AND t.divisionid IS NOT NULL AND FIND_IN_SET(d.id, '{$divisionids}') AND s.season = {$seasonid} AND FIND_IN_SET(s.gametype, '$gametypes')) GROUP BY d.id ORDER BY d.division"); $divisions = $db->loadObjectList(); } else { $db->setQuery("SELECT d.id, d.division FROM #__gridiron_division AS d LEFT JOIN #__gridiron_team AS t ON d.id = t.divisionid LEFT JOIN #__gridiron_schedule AS s ON (t.id = s.visitingteam OR t.id = s.hometeam) WHERE (t.published = 1 AND t.divisionid IS NOT NULL AND FIND_IN_SET(d.leagueid, '{$leagueids}') AND s.season = {$seasonid} AND FIND_IN_SET(s.gametype, '$gametypes')) GROUP BY d.id ORDER BY d.division"); $divisions = $db->loadObjectList(); } } if (!function_exists('getStandingsTeamsModule')) { function getStandingsTeamsModule($divisionid, $seasonid, $teamids, $gametypes) { $db =& JFactory::getDBO(); $seasonid = intval($seasonid); $divisionid = intval($divisionid); if ($teamids) { $db->setQuery("SELECT a.id AS value, a.name AS text FROM #__gridiron_team AS a LEFT JOIN #__gridiron_schedule AS s ON (a.id = s.visitingteam OR a.id = s.hometeam) WHERE (a.published = 1 AND FIND_IN_SET(a.id, '$teamids') AND FIND_IN_SET(s.gametype, '$gametypes') AND s.season = {$seasonid}) ORDER BY a.name"); } else { $db->setQuery("SELECT a.id AS value, a.name AS text FROM #__gridiron_team AS a LEFT JOIN #__gridiron_schedule AS s ON (a.id = s.visitingteam OR a.id = s.hometeam) WHERE (a.published = 1 AND a.defaultteam = 1 AND a.divisionid = {$divisionid} AND FIND_IN_SET(s.gametype, '$gametypes') AND s.season = {$seasonid}) ORDER BY a.name"); } $teamlist = $db->loadObjectList(); /* array to store the wins, losses, ties, and teamid; */ $gamedata = array(); /* go through each teams schedule and get their wins, losses, and ties so that we know how to order the league standings; */ foreach ($teamlist as $team) { $wins = $losses = $ties = $gamesplayed = 0; /* now get the total points for each team and each game; */ $db->setQuery("SELECT s.hometeam, s.visitingteam, b.finalv, b.finalh FROM #__gridiron_schedule AS s LEFT JOIN #__gridiron_boxscore AS b ON b.gameid = s.id WHERE (s.scored = 1 AND s.season = {$seasonid} AND (s.visitingteam = {$team->value} OR s.hometeam = {$team->value}))"); $games = $db->loadObjectList(); /* go through each game and count the wins/losses/ties for the team then dump the results into an array for sorting; */ foreach ($games as $game) { $gamesplayed++; if ($game->hometeam == $team->value) { if ($game->finalh > $game->finalv) { $wins++; } else if ($game->finalh < $game->finalv) { $losses++; } else { $ties++; } } else { if ($game->finalv > $game->finalh) { $wins++; } else if ($game->finalv < $game->finalh) { $losses++; } else { $ties++; } } } /* calculate winning percentage; */ $winpct = $wins + ($ties*.5); if ($gamesplayed > 0) { $winpct = $winpct/$gamesplayed; } else { $winpct = 0; } $winpct = number_format($winpct, 3); $gamedata[] = array('winpct' => $winpct, 'wins' => $wins, 'losses' => $losses, 'ties' => $ties, 'teamid' => $team->value); } /* sort the gamedata array by winpct, wins, losses, ties; */ $winpct = $wins = $losses = $ties = array(); foreach ($gamedata as $key => $value) { $winpct[$key] = $value['winpct']; $wins[$key] = $value['wins']; $losses[$key] = $value['losses']; $ties[$key] = $value['ties']; } array_multisort($winpct, SORT_DESC, $wins, SORT_DESC, $losses, SORT_ASC, $ties, SORT_ASC, $gamedata); $teamsort = array(); foreach ($gamedata as $game) { $teamsort[] = $game['teamid']; } /* teamsort will be used to order the database results so that the team with the best record is on top; */ $teamsort = implode(',', $teamsort); if ($teamids) { $db->setQuery("SELECT t.* FROM #__gridiron_team AS t WHERE (t.published = 1 AND FIND_IN_SET(t.id, '$teamids')) ORDER BY FIND_IN_SET(id, '$teamsort')"); } else { $db->setQuery("SELECT t.* FROM #__gridiron_team AS t WHERE (t.published = 1 AND t.defaultteam = 1 AND t.divisionid = {$divisionid}) ORDER BY FIND_IN_SET(id, '$teamsort')"); } $teams = $db->loadObjectList(); return $teams; } } if (!function_exists('getStandingsStatsModule')) { function getStandingsStatsModule($teams, $seasonid, $gametypes) { $db =& JFactory::getDBO(); $i = 0; $standings = array(); /* go through each team and get their wins, losses, and ties; */ foreach ($teams as $team) { $wins = $losses = $ties = $gamesplayed = $pointsfor = $pointsagainst = 0; /* now get the total points for each team and each game; */ $db->setQuery("SELECT s.hometeam, s.visitingteam, b.finalv, b.finalh FROM #__gridiron_schedule AS s LEFT JOIN #__gridiron_boxscore AS b ON b.gameid = s.id WHERE (s.scored = 1 AND s.season = {$seasonid} AND (s.visitingteam = {$team->id} OR s.hometeam = {$team->id}))"); $games = $db->loadObjectList(); /* go through each game and count the wins/losses/ties for the team then dump the results into an array for sorting; */ foreach ($games as $game) { $gamesplayed++; if ($game->hometeam == $team->id) { $pointsfor = $pointsfor + $game->finalh; $pointsagainst = $pointsagainst + $game->finalv; if ($game->finalh > $game->finalv) { $wins++; } else if ($game->finalh < $game->finalv) { $losses++; } else { $ties++; } } else { $pointsfor = $pointsfor + $game->finalv; $pointsagainst = $pointsagainst + $game->finalh; if ($game->finalv > $game->finalh) { $wins++; } else if ($game->finalv < $game->finalh) { $losses++; } else { $ties++; } } } /* create an object with the team stats to return in the array; */ $obj = new stdClass(); $obj->id = $team->id; $obj->name = stripslashes($team->name); $obj->leagueid = $team->leagueid; $obj->gamesplayed = $gamesplayed; $obj->wins = $wins; $obj->losses = $losses; $obj->ties = $ties; $obj->pointsfor = $pointsfor; $obj->pointsagainst = $pointsagainst; $obj->winpct = $wins + ($ties*.5); if ($obj->gamesplayed > 0) { $obj->winpct = $obj->winpct/$gamesplayed; } else { $obj->winpct = 0; } $standings[] = $obj; $i++; } return $standings; } } ?> <?php if ($teamids || $divisionids || $leagueids) { ?> <table width="100%" border="0" align="center"> <tr> <td colspan="4" style="text-align:center;font-size:18px;"><b><?php echo $heading;?></b></td> </tr> <?php foreach ($divisions as $did) { ?> <tr> <td style="text-align:center; width:4px; "></td> <td bgcolor="#990000" style="text-align:left; width: 200px; border-bottom: 0px #000 solid; color: #FFF;"><b>Team</b></td> <td bgcolor="#990000" style="text-align:center; width:20px; border-bottom: 0px #000 solid; color:#FFF;"><b><?php echo $wheading;?></b></td> <td bgcolor="#990000" style="text-align:center; width:20px; border-bottom: 0px #000 solid; color:#FFF;"><b><?php echo $lheading;?></b></td> <td bgcolor="#990000" style="text-align:center; width:50px; border-bottom: 0px #000 solid; color: #FFF;"><b>Pct.</b></td> <td bgcolor="#990000" style="text-align:center; width:30px; border-bottom: 0px #000 solid; color: #FFF;"><b>GP</b></td> <td bgcolor="#990000" style="text-align:center; width:30px; border-bottom: 0px #000 solid; color: #FFF;"><b>PF</b></td> <td bgcolor="#990000" style="text-align:center; width:30px; border-bottom: 0px #000 solid; color: #FFF;"><b>PA</b></td> <td style="text-align:center; width:4px; "></td> <?php if ($showties) { ?> <td style="text-align:center; width:25px;"><b><?php echo $theading;?></b></td> <?php } ?> </tr> <?php $teams = getStandingsTeamsModule($did->id, $seasonid, $teamids, $gametypes);?> <?php $statdata = getStandingsStatsModule($teams, $seasonid, $gametypes); ?> <?php foreach ($statdata as $stats) { ?> <?php $stats->shortname == '' ? $name = $stats->name:$name = $stats->shortname;?> <tr> [color=purple][i][b]<td style="text-align:center; width:4px;"></td>[/b][/i][/color] <td style="text-align:left; width: 200px; font-size: 12px;"><a href="<?php echo JRoute::_("index.php?option=com_gridiron&view=team&id=$stats->id");?>"><?php echo $name;?></a></td> <td style="text-align:center; width:20px;"><?php echo $stats->wins ? $stats->wins:0;?></td> <td style="text-align:center; width:20px;"><?php echo $stats->losses ? $stats->losses:0;?></td> <td style="text-align:center; width:50px;"><?php echo number_format($stats->winpct, 3)?></b></td> <td style="text-align:center; width:30px;"><?php echo $stats->gamesplayed;?></td> <td style="text-align:center; width:30px;"><?php echo $stats->pointsfor;?></td> <td style="text-align:center; width:30px;"><?php echo $stats->pointsagainst;?></td> <td style="text-align:center; width:4px;"></td> <?php if ($showties) { ?> <td style="text-align:center; width:25px;"><?php echo $stats->ties ? $stats->ties:0;?></td> <?php } ?> </tr> <?php } ?> <tr><td colspan="4"></td></tr> <?php } ?> </table> <?php } ?> thanks trey Hi, I am pretty much a new newbie when it comes to PHP, and have a problem that I need to solve, for a website that has to go live tomorrow. Basically I have been using a javascript upload script called 'uploadify' which had an option for the upload folder which was added to the script in the form: Code: [Select] 'folder' : '/songs/<?php echo $_SESSION["name"];?>', I added the php echo to return the username from a PHP login, so it gets added to the path to the upload folder (each user has their own subfolder for uploading to). With the new version of the uploadify script, the folder option has been moved to a separate PHP file where it is now in the form: Code: [Select] $targetFolder = '/songs/'; I need to find a way of adding the username variable to this line. I have tried using echo in various ways, and googled about, but it has stumped me, simple as it may be. If anyone could let me know how I construct this line I'd be very grateful. Time is of the essence, as they say... Thanks, Nick Hi guys; I've managed to find my way into something of a maze. <td> <a href="'Details/21/index.php'"?id= . $id .'>" . $row['id'] . "</a> </td> I'm looking at this line in the code. I realise it's currently in the wrong syntax but I'm just trying multiple different variations. At the moment I'm actually just trying to make it go to a static link but my real goal is to - get it to pick up the id number, of the id row I click, and concatenate that with the rest of my address string. Then use that as the href. Something like this: - "'Details/' + $id + '/index.php'" It's really confusing me though inside this loop and for some reason the id number is being picked up as an int, by the looks of things. It's getting above my level of understanding. Any chance one of you masters would through a n00b a lifeline?
This is my code below
<!DOCTYPE html> <html> <head> <title>LifeSaver DB</title> <h1> LifeSaver Database </h1> </head> <body> <table> <tr> <th>Id</th> <th>Location</th> <th>Initials</th> <th>TimeStamp</th> <th>Notes</th> </tr> <?php $conn = mysqli_connect("localhost", "meh", "pas", "DB"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM LifeSaver1 ORDER BY id DESC"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { //for href row $id = $row['id']; $Footage = ['Footage']; echo "<tr> <td> <a href="'Details/21/index.php'"?id= . $id .'>" . $row['id'] . "</a> </td> <td>" . $row["Location"] . "</td> <td>" . $row["Initials"]. "</td> <td>" . $row["TimeStamp"]. "</td> <td>" . $row["Notes"] . "</td> </tr>";} //show table echo "</table>"; } else { echo "0 results"; } $conn->close(); ?> </table> </body> <style> table, td, th { border: 1px solid black; margin: auto; } table { border-collapse: collapse; color: #000; <!--font colour --> font-family: monospace; font-size: 18px; text-align: center;} th { background-color: #337AFF; color: white; font-weight: bold; } tr:nth-child(odd) {background-color: #add8e6} </style> </html> Edited February 8, 2020 by JonnyDriller OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> Hi All, I'm trying to echo the response from an SLA query, the query works and returns the data when I test it on an SQL application.. but when I run it on my webpage it won't echo the result. Please help? <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $sql = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1'"; $result = mysqli_query($mysqli, $sql); echo {$result['message']}; ?> I have a log system that allows 10 logs on each side(Left and right). I am trying to make it so that the left side has the 10 most recent logs, then the right as the next 10. Any ideas? So I need to echo a row from my database with php, but where i need to echo is already inside an echo. This is my part of my code: $con = mysql_connect("$host","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("main", $con); $result = mysql_query("SELECT * FROM Vendor"); while($row = mysql_fetch_array($result)) { //I need to echo right here .................. but I get a blank page when I try this. Please Help. echo '<option value=$row['vendor_id']>'; echo $row['vendor_id']; echo '</option>'; } mysql_close($con); Result: A Blank page. Thanks in advance! Hi
I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems.
1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that?
for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; }I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } }If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. Hi all, I have written a piece of code querying the database to display the last ten posts from different users on a forum/blog. This is displaying the titles of the posts but I am unsure how to create a link (complete novice) to read the content of those posts. I get the syntax etc but can't really get my head around the target, if you catch my drift. I have created a new php file called recentposts but am unsure of how to take it from there. The code for both is below. The first piece of code works fine but when I click read more I am getting an undefined variable message on line 11 (I'm guessing there should be a link between the two pieces of code) and I am getting mysqli_fetch_array() expects parameter 1 to be mysqli_result on line 12. Any thoughts/hints/suggestions welcome. Thanks in advance. Code: [Select] <?php $connection = @mysqli_connect('localhost','root','','BLOG_PROJECT') //Make a connection to the database or die(mysqli_connect_error("Could not connect to the server")); //If it doesn't connect give the error message $latestposts= mysqli_query($connection,"SELECT author_id, title FROM blogposts ORDER BY timeofpost DESC LIMIT 9");//Query the database while($displayposts=@mysqli_fetch_array($latestposts)){ //go and get the information echo "{$displayposts['title']}</br>"; echo "<a href='recentposts.php'>Read more</a></br>"; } ?> And the recentposts.php is Code: [Select] <?php $connection = @mysqli_connect('localhost','root','','BLOG_PROJECT') or die(mysqli_connect_error("Could not connect to the server")); $detail= mysqli_query($connection,"SELECT * FROM blogposts WHERE 'title', 'content', 'timeofpost' = $content"); while($singlepage = mysqli_fetch_array($connection,$detail)){ extract($singlepage); echo "<h2>{$singlepage['title']}</h2></br>"; echo "{$singlepage['content']}</br>"; echo "{$singlepage['timeofpost']}"; } ?> Hi, im trying to create a link where it takes the row reference number and direct user to the revelant page, however i can get it work, this is my URL HREF can u please tell me what im doing wrong? thanks <td><?php echo $reference; ?><?php echo "a href='display.php?reference=".$row['reference']."'?>View Here</a>"</td> Good day: Im trying to get the image of an article, which is stored in a folder, and href it with a page and the article id, which is the variable to be passed to the next page. I had href it but when I add the id to be passed I get an error. Here is the code: Code: [Select] <?php $connection = mysql_connect("localhost", "username", "password"); mysql_select_db("articles", $connection); $query="SELECT imagename, description, articledid FROM article_description ORDER BY visits DESC LIMIT 0,9"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table width ="1000" border="1" cellspacing="2" cellpadding="2"> </tr> <?php $j=0; $f6='articles.php'; while ($j < $num) { $f8=mysql_result($result,$j,"articleid"); $f9=mysql_result($result,$j,"imagename") ?> <td><a href="<?php echo $f6?aid=$f8; ?>"> <img src="articleimages/<?php echo $f9; ?>"alt="" name="picture" width="100" height="70" border="1" /> </a> </td> <?php $j++; } ?> Any help will be appreciated. Hi there! I'm trying to put 2 variables using href. Ive got it already, but when I tried to insert the page=1, which is the the variable for my paginated code.It doesn't work. When I used the codes below, from other page (I don't used variable) it works Code: [Select] <a href='module_viewpaginated.php?page=1' but when I used this code, I've got the variable $course and $program, but I don't know how to insert page for my pagination Code: [Select] <a href='module_viewpaginated.php?course=".$courseid."&program=".$program." ' I hope my problem is clear. I want to combine the two. Any help would be greatfull!! Hey there. Firstly may I apologise if this is the wrong forum for this question. I wasn't overly sure. I'm currently developing an aplication within php which allows a user to upload a file which is saved to a directory and information on the file which is saved to a databse (including the file name). This information is then displayed in a table along with the directory location concatinated with the file name to provide a file location. My only issue is that being new to PHP I am unsure how to change this address to a workable link using a href. Any help in adapting the below script would be much apreciated. Thanks, Rick. echo "<table border='1'><tr>"; for($fieldIterator = 1; $fieldIterator < $numFields; $fieldIterator++) { echo "<th>".mysql_field_name($result, $fieldIterator)."</th>"; } echo "</tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row[1] . "</td>"; echo "<td>" . $row[2] . "</td>"; echo "<td>" . $row['Price'] . "</td>"; echo "<td>" . $row['Genre'] . "</td>"; echo "<td>" . $row['Category'] . "</td>"; echo "<td>$ref= C:\wamp\www/.$row[ImageAddress] </td>"; echo "</tr>"; } echo "</table>"; I'm using the code from Chapter 12 in Beginning PHP4 to display my data. For some reason, the hyperlinks that are suppose to sort columns do not work neither does the "View Record" function. The "Next" button also fails to load the next set of data. I also set register_global=on in the php.ini. Below is the code: Code: [Select] <?php include "./common_db.inc"; function list_records() { global $default_dbname, $user_tablename; global $default_sort_order, $default_order_by, $records_per_page; global $sort_order, $order_by, $cur_page; global $PHP_SELF; $link_id = db_connect($default_dbname); if(!$link_id) error_message(sql_error()); $query = "SELECT count(*) FROM $user_tablename"; $result = mysql_query($query); if(!$result) error_message(sql_error()); $query_data = mysql_fetch_row($result); $total_num_user = $query_data[0]; if(!$total_num_user) error_message('No User Found!'); $page_num = $cur_page + 1; $total_num_page = $last_page_num = ceil($total_num_user/$records_per_page); html_header(); echo "<CENTER><H3>$total_num_user records found. Displaying the page $page_num out of $last_page_num.</H3></CENTER>\n"; if(empty($order_by)) { $order_by_str = "ORDER BY $default_order_by"; $order_by = $default_order_by; } else $order_by_str = "ORDER BY $order_by"; if(empty($sort_order)) { $sort_order_str = $org_sort_order = $default_sort_order; $sort_order = 'DESC'; } else { $sort_order_str = $org_sort_order = $sort_order; if($sort_order == 'DESC') $sort_order = 'ASC'; else $sort_order = 'DESC'; } if(empty($cur_page)) { $cur_page = 0; } $limit_str = "LIMIT ". $cur_page * $records_per_page . ", $records_per_page"; $query = "SELECT project, route, config FROM $user_tablename $order_by_str $sort_order_str $limit_str"; $result = mysql_query($query); if(!$result) error_message(sql_error()); ?> <DIV ALIGN="CENTER"> <TABLE BORDER="1" WIDTH="90%" CELLPADDING="2"> <TR> <TH WIDTH="25%" NOWRAP> <A HREF="<?php echo "$PHP_SELF?action=list_records&sort_order=$sort_order&order_by=route"; ?>"> Route </A> </TH> <TH WIDTH="25%" NOWRAP> <A HREF="<?php echo "$PHP_SELF?action=list_records&sort_order=$sort_order&order_by=project"; ?>"> Project </A> </TH> <TH WIDTH="25%" NOWRAP> <A HREF="<?php echo "$PHP_SELF?action=list_records&sort_order=$sort_order&order_by=config"; ?>"> Config </A> </TH> <TH WIDTH="25%" NOWRAP>Action</TH> </TR> <?php while($query_data = mysql_fetch_array($result)) { $route = $query_data["route"]; $project= $query_data["project"]; $config = $query_data["config"]; echo "<TR>\n"; echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">$route</TD>\n"; echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">$project</TD>\n"; echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">$config</TD>\n"; echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\"> <A HREF=\"javascript:open_window('$PHP_SELF?action=view_record& project=$project');\">View Record</A></TD>\n"; echo "</TR>\n"; } ?> </TABLE> </DIV> <?php echo "<BR>\n"; echo "<STRONG><CENTER>"; if($page_num > 1) { $prev_page = $cur_page - 1; echo "<A HREF=\"$PHP_SELF?action=list_records&sort_order=$org_sort_order& order_by=$order_by&cur_page=0\">[Top]</A>"; echo "<A HREF=\"$PHP_SELF?action=list_records&sort_order=$org_sort_order& order_by=$order_by&cur_page=$prev_page\">[Prev]</A> "; } if($page_num < $total_num_page) { $next_page = $cur_page + 1; $last_page = $total_num_page - 1; echo "<A HREF=\"$PHP_SELF?action=list_records&sort_order=$org_sort_order& order_by=$order_by&cur_page=$next_page\">[Next]</A> "; echo "<A HREF=\"$PHP_SELF?action=list_records&sort_order=$org_sort_order& order_by=$order_by&cur_page=$last_page\">[Bottom]</A>"; } echo "</STRONG></CENTER>"; html_footer(); } function view_record() { global $default_dbname, $user_tablename; global $project; global $PHP_SELF; if(empty($project)) error_message('Empty User ID!'); $link_id = db_connect($default_dbname); if(!$link_id) error_message(sql_error()); $query = "SELECT route, project, config, opfieldc, opfieldrd, mod FROM $user_tablename WHERE project = '$project'"; $result = mysql_query($query); if(!$result) error_message(sql_error()); $query_data = mysql_fetch_array($result); $route = $query_data["route"]; $project = $query_data["project"]; $config = $query_data["config"]; $mod = $query_data["mod"]; html_header(); echo "<CENTER><H3> Record for User No.$route - $project($config) </H3></CENTER>"; ?> </TR> </TABLE> </DIV> <?php } html_footer(); switch($action) { case "view_record"; view_record(); break; default: list_records(); break; } ?> Appreciate any insight you can offer this one is form2 .php and there is action link button where im want the target to open new browser for example now m using google chrome so when im click the action link it will open another browser which is bit actually the photo is in one im dont know how to combine that why im splitted but how to target like that Hello, I have created a webpage that essentially generates an sql query and then puts the results into a table that is displayed. On one of the columns in this displayed table, I want to allow the user to click on each of the values which will in turn execute a php function. I have the hyperlink working but this is to a separate page. What I actually need to do is firstly - just ran a php function that will create a new table beneath the currently displayed one. Secondly, once this is achieved, I need to pass some value to the function so that the generated table is dependent on the value that was clicked. I've tried a few things and researched but I am struggling. I am a beginner. Any help would be greatly appreciated. Here is an extract of the code used for inputting data into the original table - showValuesSR is the function name <?php while (!$rsMetrics->EOF) { ?> <tr> <?php for ($x=0; $x<$numberOfFields; $x++) { if ($fieldNames[$x] == "Values_SR"){ ?> <td><a href= ?showValuesSR><?php echo $rsMetrics->fields[$fieldNames[$x]]->Value?></a></td> <?php } else{ ?> <td><?php echo $rsMetrics->fields[$fieldNames[$x]]->Value?></td> <?php } } ?> </tr> <?php $rsMetrics->MoveNext(); } ?> </table> <?php function showValuesSR(){ ?> <table border="0" cellpadding="5" width="100%"> <tr><td background="../images/table_toolbar_bkg.gif" align="center"><font color="Blue" face="verdana" size="2"><strong>function working</strong></td></tr> </table> <?php } ?> |