Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by doddsey_65

  1. you need to put a ; at the end of your </div> </div>';
  2. okay this is what ive done, but its showing one record on the top row then 2 underneath it and 2 thereafter. $sql = "SELECT * FROM publicgallery $max"; echo '<div class="post">'; echo '<p class="meta">PUBLIC GALLERY</p>'; echo '<div class="entry"">'; echo '<table border="1" style="padding-top:10px;">'; $i=0; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $i++; if ($i=='2') { echo '</tr><tr>'; $i=0; } echo '<td>'; echo '<center><img src=' .$row['thumbpath']. ' height="100" width="125" hspace="10" style="border: 1px solid #fff;"></center></td><td>'; echo $row['name']. '<br>' .$row['username']; } echo '</tr></table></div>'; echo '</div><br>';
  3. yes it has the correct permissions, basically everything is the same as the other upload script I am using, but this one is sending more than just the image path to the database.
  4. The following is a query i use to get all the records from the database. They are currently laid out by showing the thumbnail with the name next to it. The only thing is that it shows all records on the same row and i only want three on the same row then the others to go onto a new row so there are only ever three on a single row. How would i do this? echo '<div id="page">'; echo '<div id="content"><br />'; echo '<div class="post"><p class="meta">Public Gallery (click images for lager versions)</p></div>'; ?> <form action="searchpublic.php" method="post" style="padding-top:10px;"> <input type=text name=user value=Username maxlength=50> <input type=submit value=Search name=search> </form> <?php $sql = "SELECT * FROM publicgallery $max"; echo '<div class="post">'; echo '<p class="meta">PUBLIC GALLERY</p>'; echo '<div class="entry"">'; echo '<table border="1" style="padding-top:10px;"><tr>'; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { echo '<td>'; echo '<center><img src=' .$row['thumbpath']. ' height="100" width="125" hspace="10" style="border: 1px solid #fff;"></center></td><td>'; echo $row['name']. '<br>' .$row['username']; } echo '</tr></table></div>';
  5. you mean: echo '<div id="menu-container">';
  6. the following is a script that is already in use for a different part of my site to upload a profile picture to a directory and then send the path of it to the database. Hoever i have copied the script and tried to use it in a different way. Same premise but a bit more information being sent with it. When I click upload it says there was an error uploading. Is this because i have done something wrong? or is it because i am inserting info into the database and sending the file to the directory? <?php ob_start(); $uploadDir2 = 'tutcovers/'; if(isset($_POST['upload_btn3'])) { $fileName2 = $_FILES['userfile3']['name']; $tmpName2 = $_FILES['userfile3']['tmp_name']; $filePath2 = $uploadDir2 . $fileName2; $result = move_uploaded_file($tmpName2, $filePath2); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $filePath2 = addslashes($filePath2); } $sql = ("INSERT INTO tutorials (name, description, username, fullname, link, path, category, length) VALUES ('".$_POST['name']."', '".$_POST['description']."', '".$_POST['username']."', '".$_POST['fullname']."', '".$_POST['embedd']."', '".$filepath2."', '".$_POST['category']."', '".$_POST['vidlength']."')"); $result = mysql_query($sql, $db); } echo ' <div id="page"> <div id="content"> <div class="post"> <p class="meta">Your image has been successfully uploaded</p> <div class="entry">'; echo 'Your tutorial has been successfully uploaded. Click <a href=myaccount.php>here</a> to go back. </div></div></div>'; include('footer.php'); ob_flush(); ?>
  7. Okay i will try to explain this the best I can. the page in question is tutorials.php. As you can see i am using if statements because depending on the link they click they are either taken to tutorials.php?sort=animation or tutorials.php?sort=basics. My code decides which page they are viewing and then displays records from a database that match the link they clicked, being either animation or basics. This works fine but when i added my pagination script it went wrong. When i click next i get no results displayed and the page reverts back to the else statement because the url doesnt match the if or elseif statements. This pagination works fine when i am not including these if statements but i need it to work for these. Anyone know how? Heres the code. <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); $url = $_SERVER["REQUEST_URI"]; echo '<div id="page">'; echo '<div id="content">'; if ($url == '/tutorials.php?sort=animation'): $pagenum = $_GET['pagenum']; if (!(isset($pagenum))) { $pagenum = 1; } $data = mysql_query("SELECT * FROM tutorials WHERE category='1'") or die(mysql_error()); $rows = mysql_num_rows($data); $page_rows = 5; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $result = mysql_query("SELECT * FROM tutorials WHERE category = '1' $max") or die(mysql_error()); while($row = mysql_fetch_object($result)) { echo '<div class="post">'; echo '<p class="meta">'; echo $row->fullname. ' | ' .$row->name; echo '</a>'; echo '</p><div class="entry">'; echo '<center>' . $row->path .'<br>'; echo $row->description; echo '</center></div></div>'; } echo " Page $pagenum of $last <p>"; if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?sort=animation&&pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?sort=animation&&pagenum=$previous'> <-Previous</a> "; } echo " ---- "; if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?sort=animation&&pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?sort=animation&&pagenum=$last'>Last ->></a> "; } elseif ($url == '/tutorials.php?sort=basics'): $pagenum = $_GET['pagenum']; if (!(isset($pagenum))) { $pagenum = 1; } $data = mysql_query("SELECT * FROM tutorials WHERE category='2'") or die(mysql_error()); $rows = mysql_num_rows($data); $page_rows = 5; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $result = mysql_query("SELECT * FROM tutorials WHERE category = '2'") or die(mysql_error()); while($row = mysql_fetch_object($result)) { echo '<div class="post">'; echo '<p class="meta"><a href="tutorials.' . $row-fullname. '.php">' . $row->fullname. ' | ' .$row->name.'</a>'; echo '</p><div class="entry">'; echo '<img src="' . $row->path .'">'; echo $row->description; echo '</div></div>'; } echo " Page $pagenum of $last <p>"; if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } echo " ---- "; if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?sort=basics&&pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?sort=basics&&pagenum=$last'>Last ->></a> "; } else: echo '<div class="post">'; echo '<p class="meta">Choose a Category'; echo '</p><div class="entry">'; echo '</div></div>'; endif; echo '</div>'; include('footer.php'); ob_flush(); ?>
  8. How would i display the 4 newest records of a database? Im guessing the $date = now() function is involved but how would i get it to show the 4 newest? I was thinking of showing the newest by using the now() function by doing something like now() -4 or something like that to show the newest in the last 4 days but if there arent any then it would be blank.
  9. I have a message system that i have just made on my site. when the user clicks on their message in their inbox it takes them to inbox.php?id=the id of the message, and this is displayed through the (isset($_GET['id'])) method. But whats to stop the user typing into the address bar inbox.php?id=22 or whatever. This would allow the user to see messages sent to and from other members. all they hve to do is get lucky with the id. Is there anyway to get around this?
  10. i dont understand. lets say i have the variables: $id which is the id as it appears in the db $name which is the name of the record in the db $link which is a youtube embedd code which is in the database how would i get it to display the details of the specific one they click on.
  11. I am creating a page that lists all results found in the database that match the given username. It sets the url to that of the id. eg tutorials.php?id=1 Up to now i have been using If statements like so: if url = tutorials.php?id=1 then show video 1 but since i have around 150 videos this option isnt feasable, as i would also like people to be able to submit their own. This was I will have to do all of it. I was told there was a simple loop thing i could do with the for each./ how would i go about this?
  12. Okay i thought this would be easier than it has been but now i need some help. The users have their own my account section. From here they can compose a new message which takes them to compose.php with a simple form. When they send a message, the contents of the form(sendto, subject, message) get sent to the database. Now they can also click on their inbox which displays all their messages by selecting all messages from the message table with their username in the sendto field. This all works fine and i am happy with it so far. The only problem is how would i do a reply option? meaning when the user clicks reply under the mesage how would i send them to compose.php with the message field already filled out with the message for which they are replying to? Here is the code for inbox.php if it helps. <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); $url = $_SERVER["REQUEST_URI"]; //checks cookies to make sure they are logged in if (isset ($_COOKIE['ID_my_site'])) { $username = mysql_real_escape_string($_COOKIE['ID_my_site']); $pass = mysql_real_escape_string($_COOKIE['Key_my_site']); $check = mysql_query("SELECT * FROM users WHERE username = '{$username}'")or trigger_error (mysql_error()); if (mysql_num_rows ($check) > 0) { $info = mysql_fetch_array ($check); //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: login.php"); } //otherwise they are shown the admin area else { $pagenum = $_GET['pagenum']; if (!(isset($pagenum))) { $pagenum = 1; } //Here we count the number of results //Edit $data to be your query $data = mysql_query("SELECT * FROM publicgallery") or die(mysql_error()); $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 3; //This tells us the page number of our last page $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; echo '<br><div id="page"><div id="content"><br>'; echo '<h2 class="title">Inbox</h2><br>'; $result = mysql_query("SELECT * FROM messages WHERE sentto = '$username' $max") or die(mysql_error()); while($row = mysql_fetch_object($result)) { echo '<div class="post"><p class="meta"><font size=2>'; if ($row->read == 0) { echo '<img src=new.png>'; } echo 'Sent From | ' . $row->sentfrom . '</p>'; echo '<div class="entry"><p>'; echo '<a href=inbox.php?message=' . $row->subject . '>' . $row->subject . '</a>'; echo '<hr>'; echo '</p><br><a href=compose.php>Reply</a> | <a href=#>Delete</a></div></div>'; } echo " Page $pagenum of $last <p>"; if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } echo " ---- "; if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } echo '</div>'; } } } else { header("Location: login.php"); exit (0); } include('footer.php'); ?> And here is the code for compose.php: <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); //checks cookies to make sure they are logged in if (isset ($_COOKIE['ID_my_site'])) { $username = mysql_real_escape_string($_COOKIE['ID_my_site']); $pass = mysql_real_escape_string($_COOKIE['Key_my_site']); $check = mysql_query("SELECT * FROM users WHERE username = '{$username}'")or trigger_error (mysql_error()); if (mysql_num_rows ($check) > 0) { $info = mysql_fetch_array ($check); //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: login.php"); } //otherwise they are shown the admin area else { $url = $_SERVER["REQUEST_URI"]; if (isset($_POST['send_btn'])) { if (!$_POST['username'] | !$_POST['subject'] | !$_POST['message'] ) { die('You did not complete all of the required fields'); } $insert = "INSERT INTO messages (sentfrom, sentto, subject, contents) VALUES ('".$_POST['username']."', '".$_POST['username']."', '".$_POST['subject']."', '".$_POST['message']."')"; $send_message = mysql_query($insert); ?> <br> <div id="page"> <div id="content"> <div class="post"> <p class="meta">Your message has been sent <img src="images/img08.png" alt="bullet"></p> <div class="entry"> <p><font size=2><a href=myaccount.php>My Account | <a href=compose.php>Send Another message</a></font></p> <?php } else { echo '<br><div id="page"><div id="content"><br>'; echo '<h2 class="title">Inbox</h2><br>'; echo '<div class="post"><p class="meta"><font size=2>'; echo 'Compose New Message</font><img src="images/video.png" alt="bullet"></p>'; echo '<div class="entry"><p>'; ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> To: <input type="text" name="username"> Subject: <input type="text" name="subject"><br><br> Your Message<br> <textarea name="message" rows=10 cols=40></textarea><br> <input type="submit" name=send_btn value=Send> </form> <?php } echo '</p></div></div></div>'; } } } else { header("Location: login.php"); exit (0); } include('footer.php'); ?>
  13. at the end of the code is an else statement which just displays the list of tutorials in the event that there is no id specified. sorry but i dont really understand what you mean?
  14. so in the queries instead of having WHERE id=7 i would just use WHERE id= $_GET['id']?
  15. Hi. At the minute i have a tutorials page for my website which lists all the tutorials in the database from a certain user. Lets call this user JOHN. the url would be tutorials.john.php When someone clicks on a tutorial it takes them to the url tutorials.john.php?id=the tutorial id. So my code is like: if URL = tutorials.john.php?id=1 then show embedd code for tutorial. then i have several elseif statements for when the id = another number. Because i have over 150 tutorials i have just been copying the elseif statement and changing the id numbers since there are about 4 queries in each statement. is there anyway to do this so i dont have to copy the elseif statement over 150 times? hopefully i described this clearly enough. here is an example of the elseif statement: elseif ($url == '/tutorials.derricksesson.php?id=7'): $sql="UPDATE tutorials SET views= views + 1 WHERE id=7"; $done=mysql_query($sql); echo '<div id="page">'; echo '<div id="content"><br />'; echo '<h2 class="title">Modeling An Ear (Part 1)</h2><br />'; echo '<div class="post">'; echo '<p class="meta">Derrick Sesson | Cganim8or (<a href=tutorials.derricksesson.php>Back To Tutorials)</a>'; echo '<div class="entry">'; echo '<center>Rate This Tutorial:<br>'; echo '<form name=rate action="' . $_SERVER['PHP_SELF'] . '?id=7" method="POST">'; echo '<input type=radio name=rate value=1>1'; echo '<input type=radio name=rate value=2>2'; echo '<input type=radio name=rate value=3 checked>3'; echo '<input type=radio name=rate value=4>4'; echo '<input type=radio name=rate value=5>5'; echo '<input type=submit name=rate_btn value=Rate id=rate><br>'; echo '</form>'; $update = $_POST['rate']; if (isset($_POST['rate'])) { $rated = mysql_query("UPDATE tutorials SET RatedBy = RatedBy + 1, Rating = Rating + '$update' WHERE id = 7") or die (mysql_error()); $res = mysql_query($rated); }else{ echo ' '; } $result = mysql_query("SELECT * FROM tutorials WHERE id=7 AND username='cganim8or'") or die(mysql_error()); while($row = mysql_fetch_object($result)) { $ratedby = $row->RatedBy; $rating = $row->Rating; if ($ratedby == 0){ $avg = 0; } elseif ($ratedby == 1){ $avg = $rating; } else { $avg = $row->Rating/$row->RatedBy; } $avg = round($avg, 2); echo 'Average Rating: ' . $avg . ' - Rated by ' . $ratedby . ' users.<br><br>'; } echo ' <object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/JpVbfOfBdfo&hl=en_GB&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/JpVbfOfBdfo&hl=en_GB&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object> <br><br><div class=content><div class=post><p class=meta>Leave A Comment<div class=entry>'; require('inc_rate.php'); getComments("5"); submitComments("5","$_SERVER[php_SELF]"); echo '</div></div></div></p></div></div>';
  16. I am trying to update a column in the table with the selected radio value. This is for a rating system i am trying to create but it isnt working. No value is entered into said column. <form name=rate action="<?php echo $_SERVER['PHP_SELF']?>?id=6" method="POST"> <input type=radio name=rate value=1>1 <input type=radio name=rate value=2>2 <input type=radio name=rate value=3 checked>3 <input type=radio name=rate value=4>4 <input type=radio name=rate value=5>5 <input type=submit name=rate value=Rate id=rate><br> </form> <?php $update = $_POST['rate']; if (isset($_POST['rate'])) { $rated = mysql_query("UPDATE tutorials SET RatedBy = RatedBy + 1, Rating = Rating + '$update' WHERE id = 6") or die (mysql_error()); $res = mysql_query($rated); Anyone know where Im going wrong?
  17. okay im gonna try and explain this one last time in the hope that someone knows what i mean and can help. I list all tutorials by cganim8or $result = mysql_query("SELECT * FROM tutorials WHERE username='cganim8or' $max") or die(mysql_error()); while($row = mysql_fetch_object($result)) { echo '<div class="post">'; echo '<p class="meta">' .$row->fullname. ' | ' .$row->name; echo '<div class="entry">'; echo '<a href=tutorials.php?id='.$row->name.'>'.$row->name.'</a><br />'; echo '</p>'; echo '<br><br><br></div>'; echo '</div>'; } and as you see when you click on a tutorial by him you aere taken to tutorials.php?id=nameoftutorial. How do i make that page? How do i display the tutorial video on that page? I am assuming i put the code in this same file but what code? i dont even know where to start. In my code fullname refers to the full name of the tutorial artist name refers to the name of the tutorial( i cant use id cos the id is for the id of the tutorial not the user So, when a user clicks a tutorial they are taken to the video and the url will read tutorials.php?id=nameoftutorial this is so i dont have to make a single page for every tutorial that i have. All i would need on this page is the youtube embed code. So can anyone help? Im really struggling. And even if this is easy then pplease say so and try to help.
  18. Okay i will try to describe things better: a user is given a list of tutorials on the page tutorials.php. when a user clicks a tutorial name they are taken to the tutorial video which will appear on tutorials.php?id=1 so how do i set up the page tutorials.php?id=1? I can get the tutorials in tutorials.php to go to their id pages(tutorials.php?id=) but i dont know how to set up the pages to show the video which is relative to whatever tutorial they click.
  19. i can see where in that page it explains what i need to do
  20. anyone got any advice or know what i should type into google to look for?
  21. post? im not using the post variable al i want is when you click on a link in tutorials.php it wil take you to tutorials.php?username=whatever, within which resides the video. so how would i get the video of the clicked tutorial to display under tht url?
  22. but would i be putting that in a new page or in tutorias.php with the code above?
  23. Ok i have gotten it to display the tutorials(even though the pagination isnt working), but how do i go about creating the next file that will display the tutorial they clicked on? instead of id i have gone for username since id in my table is the tutorial id and not the userid. when i click on a tutorial by 'carl' it takes me to tutorials.php?username=test so how would i make that page? When i click the link i just get sent back to the previous page(the list of tutorial publishers)
  24. Okay here is the current layout of tutorials.derricksesson.php I tried your code but couldnt get it to work. <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); $pagenum = $_GET['pagenum']; if (!(isset($pagenum))) { $pagenum = 1; } //Here we count the number of results //Edit $data to be your query $data = mysql_query("SELECT * FROM tutorials WHERE username='cganim8or'") or die(mysql_error()); $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 3; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; echo '<div id="page">'; echo '<div id="content"><br />'; echo '<h2 class="title">Tutorials By Derrick Sesson</h2><br />'; $result = mysql_query("SELECT fullname, name FROM tutorials WHERE username='cganim8or'") or die(mysql_error()); while($row = mysql_fetch_object($result)) { print "<a href='/tutorials.php?id=".$row->fullname."'>".$row->name."</a><br />"; } echo '<br><br><br></div>'; echo '</div>'; } echo " Page $pagenum of $last <p>"; if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } echo '</div>'; include('footer.php'); ob_flush(); ?> The rows in the tutorials table are: ID - tutorial id not userid name - name of tutorial description - of tutorial username - of tutorial provider fullname - of tutorial provider link - link to tutorial path - path the the image thumbnail hopefullyyou will be able to show me how i would get it to display the tutorial once the user clicks the tutorial they want.
×
×
  • 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.