Jump to content

MATLAB

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Everything posted by MATLAB

  1. That makes sense. I was looking into putting a div in each <li> but it didnt work as planned. Thanks for the reply
  2. I am trying to display images and a description of the image underneath the image. I am trying to display the images in one line, and have the corresponding description displayed underneath each of the images (as shown in the image below, where i is the image, and d is the corresponding description. Uploaded with ImageShack.us Below is my current code to display the images in one line, but when I try to add the description, the description is added on the same line as the image, instead of underneath the image. <!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>Index</title> <style type="text/css"> #latest_media li { display: inline; list-style-type:none; margin-left:110px; width:4000px; height:400px; background-color:#F00; } </style> </head> <body> <ul id='latest_media'> <li><img src="images/2.PNG" /></li> <li> <img src="images/1.PNG" /></li> </ul> </body> </html> Another problem I am having (not important) but the colour of the <li> item is not the colour which I have specified in the CSS (no colour is displayed!), any idea why? Thanks for any replies
  3. Ok, I have completed the majority of the work for this website, but there is only one problem I am faced with now. I have displayed all of the videos and short information about them from a database using pagination. My problem is, how do I make it so when the title of one of the videos is clicked, it takes the user to a new page, containing ONLY that video, and ONLY information relating to that video? I assume it will involve some question marks in the URL of the page, but I simply dont know how to do this. Currently, all videos are displayed on several pages, with limited information. The idea (like youtube) is to give a taste of the video from the page, but then a user can click the title to go to a page just for that video to view more details on it. how can i achieve this? Thanks, MATLAB
  4. I had that in a previous version of the script but it was not working correctly and forgot to put it back in when I got it working how I want. Thanks very much for your help, silly mistake by me!
  5. Can somebody please help me sort this code out I have wirtten/got from a tutorial from phpfreaks - http://www.phpfreaks.com/tutorial/basic-pagination. The code correctly knows the number of pages needed in order to display the records from the database, but it displays all records on each page. I have 4 records and want 2 records to be shown on each page, but the code below displays all 4 records on both pages. Can someone please shed some light onto how I can display the first 2 records on the first page, and the second 2 records on the second page? code below: <?php //Connect to the database $user="username"; $password="password"; $database="database"; $con = mysql_connect("localhost",$user,$password) or die ('Could not connect: ' . mysql_error()); mysql_select_db($database, $con) or die( "Unable to select database"); // Determine number of rows in database $query = mysql_query("SELECT * FROM vids"); $numrows=mysql_num_rows($query); // number of rows to show per page $rowsperpage = 2; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db $result = mysql_query("SELECT * FROM vids"); while($row = mysql_fetch_array($result)) { $id = $row['id']; $url = $row['url']; $page_url = $row['page_url'];; $title = $row['title']; $desc = $row['desc']; $date_add = $row['date_add']; $date_rec = $row['date_rec']; $place = $row['place']; $altitude = $row['altitude']; $jump_no = $row['jump_no']; //Display video echo "<div class='sky_cont'> <div class='sky_vid'><a class='video' href=\"$url\"><img src='http://www.netlinksurveyors.co.uk/test/images/lgo.jpg' alt=\"$title\" Border='0' /></a></div> <p><h4><a href=\"$page_url\" target='_blank'>$title</a></h4>$desc</p> </div>"; } /****** build the pagination links ******/ // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // range of num links to show $range = 3; // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } } } // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?>
  6. changing the code you said didnt do anything unfortunately, infact it removed the description and title from the records echo'd. Thanks anyway
  7. thanks a lot. Do you know what this concept is called so i can look at it in more detail please?
  8. Thanks! Would it be a simple if statement so if the value of $_GET = "h" then echo this e.t.c?
  9. I have solved the problem of the script only displaying a few of the variables. I had to create hard links to them and they work. I have come up against another problem. When I am looping through the entries in my database and echoing the data to the webpage, only the first data gets echoed back, and any subsequent echo's are of the first data i.e. if i want to show the first 3 entries of the database, 3 entries are shown, but its the first entry and another 2 repeats of the first entry. Below is my code for the PHP: <?php //Connect to the database $user="USERNAME"; $password="PASSWORD"; $database="DATABASE"; $con = mysql_connect("localhost",$user,$password) or die ('Could not connect: ' . mysql_error()); mysql_select_db($database, $con) or die( "Unable to select database"); // find out how many rows are in the table $sql = "SELECT * FROM vids"; $result = mysql_query($sql, $con); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 10; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db /*$sqql = "SELECT * FROM vids LIMIT $offset, $rowsperpage"; $result = mysql_query($sqql, $con) or trigger_error("SQL", E_USER_ERROR);*/ // Assign variables for videos $query = "SELECT * FROM vids"; $result = mysql_query($query) or die ('Error: '.mysql_error ()); $row = mysql_fetch_row($result); $id = $row[0]; $url = $row[1]; $page_url = $row[2]; $title = $row[3]; $desc = $row[4]; $date_add = $row[5]; $date_rec = $row[6]; $place = $row[7]; $altitude = $row[8]; $jump_no = $row[9]; // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) { // echo data $id = $row[0]; $url = $row[1]; $page_url = $row[2]; $title = $row[3]; $desc = $row[4]; $date_add = $row[5]; $date_rec = $row[6]; $place = $row[7]; $altitude = $row[8]; $jump_no = $row[9]; echo "<div class='sky_cont'> <div class='sky_vid'><a class='video' href=\"$url\"><img src='images/5.png' alt=\"$title\" Border='0' /></a></div> <p><h4><a href=\"$page_url\" target='_blank'>$title</a></h4>$desc</p> </div>"; } /****** build the pagination links ******/ // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // range of num links to show $range = 3; // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } } } // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?>
  10. I have not created any code for this as I dont know where to start, or what its even called. I am on about trying to create a page dynamically depending on the id which is selected. Parts of the URL will change depending on what id is selected for example: 'http://www.facebook.com/home.php?sk=h. i am wanting to create a video website, where when the thumbnail of a video is clicked, a new page is loaded with that more details of the video and the video itself, and im guessing the url would change to identify the id of the video. I cannot create a page for every video by hand, as i will have many videos and this is not very efficient. I am just after the name of this technique or a pointer to a tutorial for how to achieve this. Thanks, Matlab
  11. Also, when i add more entries to the database, only the first one shows up. When using: $num_rows = mysql_num_rows($result); echo $num_rows; I get a result of 1, when there are 4 entries in the database. Any ideas how to fix this script?
  12. Ok, so I have worked throug ha tutorial on basic pagination from phpfreaks website, built a database and started to design the page. Im having a few problems displaying all of the fields from the database table. Certain fields just will not show in the page, for an unknown reason. I have made sure I have spelt them the same as how they are spelt in the database, but still, only some fields show up. Below is my code for the HTML, PHP and the structure of the database: HTML: <!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>Skydiving</title> <link rel="stylesheet" type="text/css" href="stylesheet.css" /> <script type="text/javascript" src="scripts/jquery.js"></script> <script type="text/javascript" src="scripts/psed.js"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="fancy_box/fancybox/jquery.mousewheel-3.0.2.pack.js"></script> <script type="text/javascript" src="fancy_box/fancybox/jquery.fancybox-1.3.1.js"></script> <script type="text/javascript" src="fancy_box/fancybox/fancy.js"></script> <link rel="stylesheet" type="text/css" href="fancy_box/fancybox/jquery.fancybox-1.3.1.css" media="screen" /> </head> <body> <div id="main_container"> <!--Header Content--> <div id="header_container"> <a href="index.html"><img id="lgo" src="images/lgo.jpg" /></a> <div id="nav"> <ul id='navlist'> <li><a href='index.html'>Home</a></li> <li><a href='contact.php'>Contact</a></li> </ul> </div> </div> <!--Main content--> <div id="main_content_container"> here is my videos<br /> <?php include('scripts/display_vids.php');?> <div class="push"></div> </div> <div class="push"></div> <?php include('scripts/footer.php');?> </body> </html> PHP (display_vids.php): <?php //Connect to the database $user="USERNAME"; $password="PASSWORD"; $database="DATABASE"; $con = mysql_connect("localhost",$user,$password) or die ('Could not connect: ' . mysql_error()); mysql_select_db($database, $con); // find out how many rows are in the table $sql = "SELECT COUNT(id) FROM vids"; $result = mysql_query($sql, $con); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 10; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db $sqql = "SELECT * FROM vids LIMIT $offset, $rowsperpage"; $result = mysql_query($sqql, $con) or trigger_error("SQL", E_USER_ERROR); // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) { // echo data echo "<div class='sky_cont'> <div class='sky_vid'><a class='video' href='" .$list['url'] . "'><img src='images/4.PNG' alt='" . $list['title'] ."' border='0' /></a></div><p><h4><a href='" . $list['page_url'] . "' target='_blank'>" . $list['title'] . "</a></h4>" . $list['desc'] . "</p></div>"; } /****** build the pagination links ******/ // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // range of num links to show $range = 3; // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } } } // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?> Database structure: id - int(11) - Auto increment url - varchar(1000) page_url - varchar(10000) title - varchar(10000) desc - varchar(10000) date_add - varchar(10000) date_rec - varchar(10000) place - varchar(10000) altitude - int(11) jump_no - int(11) Now, the fields which display in my webpage are the following: url desc which means, that the following fields are not displaying at all, for some unknown reason: title page_url Can someone please offer an explination as to why some fields from the database are shown, and others are not, even though they are spelled correctly? Thanks, Matlab
  13. thanks for the answer! il have to look at a tutorial for this, im quite new to php.
  14. How can I make a new page be created on the fly, when a thumbnail of a video is clicked? I know how I could display the details of the video, its just the creation of the page I am struggling to figure out.
  15. I have not started coding anything, I was unsure on how to go about it in the first place. I was just looking for some ideas on how to do it, instead of code alterations.
  16. I was not sure on which board to put this thread, so please move it if there is a more appropriate board. I am wanting to create a website that displays images which I have put into a database. I would like the number of images on one page not to exceed 10, for example, and when the number of images in the database exceeds this number, a new page will be created. I would like it to function similar to Google Images where the number of pages is dictated by the number of images in the database. I cant figure out how to achieve this, so any pointers or thoughts would be great Thanks, Matlab
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.