PHP - Veiwing Multiple Pages Of Details For A Record Based On Id Number
Hi Everyone.
i have a page which list all records. i then have several detail pages which i need to link via the id number. for ex. records: id number name 1 john smith 2 peter parker the detail page is layout out like so: View details page 1 | view details page 2 | view details page 3 Any help would be appreciated. Thanks. Similar TutorialsHi, I have successfully implemented a master details page with the results aligned in columns linking to a details page. I wish to maintain the recordID passed from the master details page and make the dynamic text, which reads Shade A tree that is capable of..... in the attached screen shot a link to another details page referencing the same recordID. The detailspage2.php would look the same as the screenshot except the Shade text and description below will be highlighted, which I can do, there will be a new image and a new image description. All other dynmaic elements on the page will remain the same. I tried to simply save as my detailspage.php to detailspage2.php and create a link to detailspage2.php. It linked to detailspage2.php but none of the record info showed up in their respective table cells. I have all the names desc's, images, etc setup in a table in my database. Please let me know what code and other info you need to help me out with this procedure. Thanks. Hi all, I've done a LOT of googling on this and found things that match what I need but nothing actual achieves what I need. I've used one php file before for doing multiple jobs (ie registration?step=2 / 3 etc), but I've boo-booed somewhere and it only works up until step 2, step 3 doesn't work. Here's what I have currently, it also leads me on to the next question. Code: [Select] <?php if(isset($_GET['step']) == 2) { ?> Please select the problem you are encountering. <a href="registration.php?step=3&console=<?php $_GET['console'] ?>&issue=1rrod"><img src="store/image/data/1rrod.gif" width="92" height="92" /></a> <?php } if (isset($_GET['step']) == 3) { ?> END <?php } else {?> Please select which type of Xbox 360 you have<br /> <a href="registration.php?step=2&console=xbox"><img src="images/xbox360.gif"></a> <a href="registration.php?step=2&console=xboxslim"><img src="images/xbox360e.gif"></a> <?php } ?> So, first step (which is bottom), lets you select which type of console it is - only two possible choices. That then passes that data to step 2, which is what issue the console is having. Now I've tried this with $_POST, as I would prefer to work that way. I've experimented with $_SESSION to try and pass everything I need, using code found elsewhere. But I just can't get it to pass from page to page and finally be able to use it to email in the final step. Final issue - I want to use images instead of buttons to be able to pass the variables. I've found that using hidden type input does work but I think this issue is related to the above one. Thanks! Jason Hello, I had 8 select boxes(dropdowns) in a form. Its like a search kind of implementation in the website. I don't know what the user selects, he may choose different select boxes, any number of select boxes. So, based upon the user selection, I need to generate the data. The data fields to be generated would be almost same. So, How would I know what the user selection is and how many select boxes has been selected and how could I generate different data based upon selected boxes. I had to make a small note abt this, that the data generation fields may change for some of the user select combinations, but most of the result fields would be same. so, can you please help me out, how to do, how to make different combination data generations, because, i had 8 fields, i had to make 8! combinations, that would result in a big code. Hello there, I'm trying to make when you click on a record, it opens another page with full details about this record the code for it is Code: [Select] <td><a href=\"user.php?id=".$row['id']."\">".$row['id']."</a></td> and it's working right, but when it opens the other page, no records is shown about the user with that ID So I figure the problem that I need to pass $row['id'] to my second page and make it search for it in the database how can I do that? here is the code from the second page (details of the record) Code: [Select] $dbObj = new DB(); $result = mysql_query("select * from users where id = '$userID'"); return $result; $row = @mysql_fetch_array($result); echo "<table width=98%>"; echo "<tr>"; echo "<td valign=\"top\" width=\"120px\">"; $rowid = $row['id']; echo "<td valign=\"top\">"; echo "<table> <tr> <td valign=\"top\" class=\"searchtitle\"> ".$row['fname']. ' ' .$row['mname']. ' ' .$row['lname']." </td> </tr> <tr> <td class=\"text\" valign=\"top\"> ".$row['mobile']." </td> </tr> <tr> <td> <a href=\"user.php?id=".$row['recruiterid']."\" class=\"link\">".$row['recruiterid']."</a> </td> </tr> </table>"; echo "</td>"; echo "</tr>"; echo "</table>"; Hi there got a bit of a logic question here. I have been looking at doing a remember username and password for a persons login form. You'd need to set this as a cookie right? But when doing so would you place it just as the user has entered the form, or when the user has actually successfully logged in, I know mostly this 1st question would be up to me, but what would you do in your own opinion? On a second note to that, I have been going on this logic, just to try and work it out for myself but it keeps coming out with the encrypted password, is there a much better tutorial than going off my own assumptions? Here's the logic: Code: [Select] <?php session_name('jeremysmith_remember_login'); session_start(); ini_set('display_errors', true); // see whats in the cookies overall! print_r($_COOKIE); // now do logic on the form example: if(!array_key_exists('login', $_POST)) { $message = 'User has not logged in yet, please login below:'; require 'form.php'; } else { if(strlen(trim($_POST['username'])) > 0 && strlen(trim($_POST['password'])) > 0) { // now save them to a cookie maybe? mysql_connect('localhost', '******', '*****') or die (mysql_error()); mysql_select_db('test') or die (mysql_error()); $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $sql = sprintf("SELECT * FROM users WHERE username LIKE '$username' AND password LIKE sha1('$password')"); $result = mysql_query($sql) or die (mysql_error()); if($result) { if(mysql_num_rows($result) === 1) { $_SESSION['logged_in'] = true; // this will be our only check for now though! if(IsSet($_POST['remember_login'])) { // but don't remember if they have not logged in, what would be the point in that? setcookie("username", $_POST['username']); setcookie("password", $_POST['password']); header('location: success.php'); } } } else { die(mysql_error()); } } else { $username = trim($_POST['username']); $error = 'You did not enter all the fields required to login, please try again'; require 'auth_form.php'; } } I am just a bit confused, any guidance is massively appreciated, Jeremy. Hi all . I have a script , which will display the records from sql . If user wish to view more details of the record , they can click view . Code: [Select] echo "<td>$objResult[Message] </td>"; echo "<td>$objResult[mylocaltime] </td>"; echo '<td><a href="historydetails.php?id=' . $objResult[Groupnumber] . '">View</a></td>'; Then it will link to a page which will display more details according to the Groupnumber . Which will display 2 records per page . Code: [Select] <? $groupnumber = $_GET['id']; $strSQL = "SELECT * FROM esp WHERE Groupnumber='$groupnumber'"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 2; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by id DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> But when I click next to view the third record , then the table will become blank . Is it because when I click to next page , the $groupnumber is no longer getting the data from $_GET['id'] ? Or is there any other problem? Thanks for every reply . Dear all, I would like to find the total number of individual record in MySQL with php. For example: I have different department name stored in a column in MySQL. I would like to find out the total number of each department. But I do not know the names of the department How can I do it?? Counting the total of each department without knowing their names Thanks! Hey! First timer here, please be gentle on me. 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> <title>Leettarin Uploader</title> //<link href="style.css" rel="stylesheet" type="text/css" /> <BODY BACKGROUND="Ready.jpg"> <link rel="shortcut icon" href="xxx/twg/favicon.ico"> </head> <?php ob_start(); define("MAX_COUNT", 10); define("UPLOAD_DIRECTORY", "valokuvat/"); define("MAX_SIZE", 1000000); if(!is_dir(UPLOAD_DIRECTORY)) { mkdir(UPLOAD_DIRECTORY, 0777); } if(file_exists($_FILES['file1']['tmp_name'])) { for($i=1; $i<=MAX_COUNT; $i++) { if($_FILES['file'.$i]['size'] > MAX_SIZE) { echo "Liian iso tiedosto!<br>".MAX_SIZE." on raja"; break; } while(file_exists(UPLOAD_DIRECTORY.$_FILES['file'.$i]['name'])) {$_FILES['file'.$i]['name']="$k".$_FILES['file'.$i]['name']; $k++; } move_uploaded_file($_FILES['file'.$i]['tmp_name'], UPLOAD_DIRECTORY.$_FILES['file'.$i]['name']); echo "xxx/waddap/valokuvat/".$_FILES['file'.$i]['name']; exit(); } } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" ENCTYPE="multipart/form-data"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="102400000"> <?php for($i=1;$i<=MAX_COUNT;$i++) { echo " <b><font style=\"color: #00FFFF;\">$i</font></b> <input type=\"file\" name=\"file".$i."\" size=\"75\"><br>"; } ?> <input type="submit" value="Upload"></form><?php ob_end_flush(); exit; ?> Basically, I want this to also display details concerning EVERY uploaded file. I can fix the text and decoration part later, but for now I'd like to know how to make it display information from every uploaded file upon multi-uploading. Information, as in a simple link to the image will do now just fine. So it kind of would redirect you after an upload process to page where are links to all uploads just done. I can only get it to work with 1st file and evidently other files won't even be uploaded then, hm. Also would appreciate a code for blocking other filetypes but .jpeg, .jpg, .png, .gif and .bmp. I'd highly appreciate help! 1 Total number of likes work, but I'm guessing it can be done differently, any input would be appreciated. /controllers/indexController.php $posts = Post::find('all', [ 'limit' => 4, 'include' => ['likes'] ]); foreach ($posts as $post) { $post->assign_attribute('likeCount', count($post->likes)); } } /models/Post.php class Post extends ActiveRecord\Model { static $has_many = [ ['comments', 'class_name' => 'PostComments'], ['likes', 'class_name' => 'UserLikePosts'] ]; } /models/UserLikePosts.php class UserLikePosts extends ActiveRecord\Model { static $belongs_to = [ ['user'], ['post'] ]; }2 The big question is, how can I get a true/false for "if current user has liked post"? I was thinking something like this, but using vars won't work here, and I would have to use a ternary or a function call to do it like this as the session var might not be set (guest). class Post extends ActiveRecord\Model { static $has_many = [ ['comments'], ['likes', 'class_name' => 'UserLikePosts'], ['user_likes', 'class_name' => 'UserLikePosts', 'conditions' => ['user_id = ?', [$_SESSION['user']['id']]] ]; } Edited by JimL, 21 June 2014 - 03:36 PM. hi guy's i have on one page select from table, and i don't know how to limit showing content from database on 3, and rest to make number under it and when i click on that number next 3 is showen? Something like on forum when you have more topics then you can show, on botom of page are showen numbers (links). Can some explain me how to do this? i put in while loop something like this Code: [Select] while ($prom = mysql_fetch_object($res) and $i<3) and now it is limited on showing first 3, my problem is showing next 3, and if there is more how to split it on 3 per page? <?php $ThreadID = $_GET['threadid']; If (isset($_GET['page'])) { $Page = intval($_GET['page']); } Elseif (isset($_POST['page'])) { $Page = intval($_POST['page']); } Else { $Page = 1; } $ThreadQry = "SELECT * FROM ".FORUM_THREADS." WHERE thread_id='{$ThreadID}'"; $ThreadRes = mysql_query($ThreadQry, $db); $ThreadTitle = mysql_result($ThreadRes, 0, 'thread_title'); $ForumID = mysql_result($ThreadRes, 0, 'forum_id'); $Locked = mysql_result($ThreadRes, 0, 'locked'); If ($Page == 1) { $Limit = 0; } Else { $Limit = $Page * 20; } $Limit2 = $Limit + 20; $PostsTotal = mysql_num_rows(mysql_query("SELECT * FROM ".FORUM_POSTS." WHERE thread_id='{$ThreadID}'", $db)); $PostsQry = "SELECT * FROM ".FORUM_POSTS." WHERE thread_id='{$ThreadID}' ORDER BY `post_id` ASC LIMIT {$Limit}, {$Limit2}"; $PostsResult = mysql_query($PostsQry, $db); $PostsOnPage = mysql_num_rows($PostsResult); $PostCounter = 0; $PermissionQuery = "SELECT * FROM ".PERMISSIONS." WHERE forum_id='".$ForumID."'"; $PermissionResult = mysql_query($PermissionQuery, $db); $PermissionPostReply = mysql_result($PermissionResult, 0, 'min_post_reply'); $PermissionReply = intval($PermissionPostReply); ?> <div class='tableborder'> <?php if ($MemLevel >= $PermissionReply) { If ($Locked == 'no') { ?> <div align="right" style="background-color: #979797"> <a href="./index.php?act=reply&threadid=<?php echo $ThreadID; ?>"><img src="./images/reply.png"></a> </div> <?php } Else { ?> <div align="right" style="background-color: #979797"> <?php If ($MemLevel >= 1000) { Echo "<a href='./index.php?act=reply&threadid={$ThreadID}'>"; } ?><img src="./images/locked_reply.png"> <?php If ($MemLevel >= 1000) { Echo "</a>"; } ?><br> </div> <?php } } ?> <div class='maintitle' align='left'><img src='./images/nav_m.gif' border='0' alt='' width='8' height='8'> <a href="./index.php?act=viewthread&threadid=<?php echo $ThreadID; ?>"><?php echo $ThreadTitle; ?></a></div> <table width="100%" border="0" cellspacing="1" cellpadding="4"> <tr> <th align="Center" width="20%" class='titlemedium'>Author</th> <th align="Left" width="80%" class='titlemedium'>Post</th> </tr> <?php While ($PostCounter < $PostsOnPage) { ?> <?php $PostCounter++; } ?> </table> </div> This is what I have so far for displaying a thread in a forum. This is set to retrieve 20 Posts per page for each thread. What I want to do is At the bottom under </table> is display a drop down box which will add a selection for each page of posts. How would I work out how many pages this drop down box needs to add? The posts table is stored in a constant called FORUM_POSTS and they are sorted into threads by thread_id in that table. Hi, I have a menu that is generated from my mysql database and I want it on every page of my website as the main menu. However I can''t figure out how to do this. I managed to get it on the view article page by duplicating the my query like this: Code: [Select] function viewArticle() { if ( !isset($_GET["articleId"]) || !$_GET["articleId"] ) { homepage(); return; } $result['article'] = Article::getById( (int)$_GET["articleId"] ); //single record $result['pageTitle'] = $result['article']->title . " | Widget News"; $results = array(); $all_data = Article::getList( HOMEPAGE_NUM_ARTICLES ); //multiple record $results['articles'] = $all_data['results']; $results['totalRows'] = $all_data['totalRows']; require( TEMPLATE_PATH . "/viewArticle.php" ); } However I can't figure out how to place it on for example the new article page. Code: [Select] function newArticle() { $results = array(); $results['pageTitle'] = "New Article"; $results['formAction'] = "newArticle"; if ( isset( $_POST['saveChanges'] ) ) { // User has posted the article edit form: save the new article $article = new Article; $article->storeFormValues( $_POST ); $article->insert(); header( "Location: admin.php?status=changesSaved" ); } elseif ( isset( $_POST['cancel'] ) ) { // User has cancelled their edits: return to the article list header( "Location: admin.php" ); } else { // User has not posted the article edit form yet: display the form $results['article'] = new Article; require( TEMPLATE_PATH . "/admin/editArticle.php" ); } } Can anybody help me out i'm really struggling? Thanks Hello everyone, I'm trying to code a section of the site which is like an advertising website (i.e, gumtree) where people can post an Ad on the site and have any responses sent to them via email. The thing is that I have a form where they can enter their details and need to POST the information to the following page which is a preview page of their Ad. I have the form action returning to the same page for validation but I need the $_POST vaules to populate the following page without sending information to the database (in an effort to keep the database clean should they decide not to publish their Ad. There are 3 pages in total CREATE AD > PREVIEW AD (where they can go back and edit if they need to) > Publish AD (where they confirm terms and send to database). I do have session variables already set after login in and a seperate table to hold the details after they have confirmed the Ad & terms. Any ideas would be greatly appreciated. Thanks, L-plate Hi.
I have a product database w/ tables each for product series, model, sub-model and optionals. One item in each of these makes up one product. So Series K, Model 7, sub-model 2, optional 3 will be a product called K 7/2-3 .The permutations and combinations of these are all possible products.
In the same db, I have a quotations table. Each quotation has a unique id / record. A quotation can include any number of products : it can have K 7/2-3, KA 561/1-2 , FPN 311/2-1 or it can only have KA 561/1-2 etc.
Now I am stuck. Don't know how to
a. structure the quotations table
b. create a MySQL select so that one statement can make multiple selections . I thought of using a checkbox but that doesn't work either since the series/model/sub model/optionals must chosen sequentially.
Any ideas I can follow thru ?
Many thanks
Swati
Hi everyone, I have this script that identify's the current page in the navigation Code: [Select] <?php $currentPage = basename($_SERVER['SCRIPT_NAME']); ?> <ul id="nav"><!-- Open Nav --> <li><a href="index2.php" <?php if ($currentPage == 'index2.php') {echo 'class="selected"';} ?>>Home</a></li> <li><a href="salon-information.php" <?php if ($currentPage == 'salon-information.php') {echo 'class="selected"';} ?>>Salon Information</a></li> <li><a href="about-us.php" <?php if ($currentPage == 'about-us.php') {echo 'class="selected"';} ?>>About us</a></li> <li><a href="hair-care-advice.php" <?php if ($currentPage == 'hair-care-advice.php') {echo 'class="selected"';} ?>>Hair Care Advice</a></li> </ul><!-- Close Nav --> My problem is that hair-care-advice.php has a number of sub pages. How do I get it so the selected class remains selected for all the sub pages as well as the main page. Any help would be greatly appreciated Thank you Barry Hi all, Im really struggling to build an update multiple records form, Ive built my table which calls all data i need from the db in a looped region which works fine I just cant understand how to then input these back into the table in the correct rows, if this makes sense? Ive been reading this tutorial but Its not very informative its more of a copy and paste http://www.phpeasystep.com/mysql/10.html Hi:
Am not sure if this is the best algorithm to go about saving a record and uploading (plus moving to another directory) files. I feel i need another algorithm?
if (self::post()->isPost()) { #check if there is any file if($this->request->hasFiles() == true){ $uploads = $this->request->getUploadedFiles(); $isUploaded = false; #do a loop to handle each file individually foreach($uploads as $upload){ #define a "unique" name and a path to where our file must go $path = 'temp/'.md5(uniqid(rand(), true)).'-'.strtolower($upload->getname()); #move the file and simultaneously check if everything was ok if($upload->moveTo($path)) { #Build an array to be sent to the API for moving the uploaded file to front end directory $files=""; $files = array( 'name' => $upload->getName(), 'link' => $this->di['url']->get('temp/' . $upload->getName()), 'direction' => 'adverts' ); $saveResult = self::request()->request('move-advert/', array('file' => $files), 'POST'); if($saveResult->response == 'success') $isUploaded = true; else $isUploaded = false; } } #if any file couldn't be moved, then throw an message if($isUploaded) { $save_response = self::request()->request('advert/' . $id, self::editValues(self::post()->getPost()), 'POST'); if ($save_response->response == 'success') { $this->flashSession->success('Advert Updated'); return $this->response->redirect('adverts/list-adverts'); } else { $this->flashSession->notice('Could not update Advert'); } } else { $this->flashSession->notice('Some error ocurred. Please try again'); } }else { $this->flashSession->notice('You must Choose an advert image'); } }Any suggestions? Hi, I need to write some code for this but unsure where to start. Basically i have a database of say 10 rows. I need to be able to input a number and some sort of fair algorithm will choose one of the rows. The number will be from 6 to 10 numbers long, and will need to pick the same result each time based on that number. Its for a lotto game Hi, I have a web site that sells both video and images. The full versions are located securely behind a paywall, however in a bid to get visitors to purchase them and to promote the members offering I have trailer videos of 30 seconds to one minute and four free images per imageset. I want to be able to restrict the number of images a visitor can view for free to 12 and the number of videos a visitor can play to 5. With a little graphic/overlay notifying the user when they have exceeded their free play/preview limit. I have been advised that a tracking cookie and php if statement would be the way to go to achieve this. I have got a cookie that is successfully logging views that is written to on a free preview link as an onclick function. I have tried writing some php if code that will have the normal thumbnail or video divs display as usual if the views recorded in the cookie are below 12 or five, respectively, and have a not allowed, please subscribe div that would show over the thumbnails or video divs should the number of views exceed the threshold. My PHP code does not seem to be working at all, I have ran it through an online syntax checker - corrected the mistakes and now it's supposed to be working but opts to display nothing instead of either if argument. Videos then become a whole other problem because at the moment I have no other way to track the view/visit other than to count the loading of the video summary page with the free player as the preview, whether or not the clip is played - ideally I would like the view to be counted when the video begins to play. But I have no idea how to write to the cookie from Flash (is that even possible?) Any help would be greatly appreciated. |