Jump to content

alexsmith2709

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Everything posted by alexsmith2709

  1. I put stripslashes in a while back when trying something out and never removed them. I have changed my site since writing this code. I havent tried much to be honest, i've been staring at my code wondering where and how to do the if statement and wanted to make sure if i was on the right lines. Now i know on im the right lines i can concentrate a bit more. Thanks for your first example, i can now have a go. @litebearer: Thanks, i already have this list in a popup div using jquery, but when it gets even bigger i will look at pagination.
  2. here is my code so far: <?php include_once("includes.php"); doConnect(); //gather the motherboards $get_mobo_sql = "SELECT * FROM mobo WHERE mobo_brand='Asus' ORDER BY mobo_model ASC"; $get_mobo_res = mysqli_query($mysqli, $get_mobo_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($get_mobo_res) < 1) { //if there are no motherboards $asus = "<p><em>Sorry, there are currently no motherboards.</em></p>"; } else { //create the display string $asus = "<b><u>Asus</u></b><br/>"; while ($mobo_info = mysqli_fetch_array($get_mobo_res)) { $mobo_id = $mobo_info['mobo_id']; $mobo_brand = stripslashes($mobo_info['mobo_brand']); $mobo_model = stripslashes($mobo_info['mobo_model']); $mobo_formfactor = stripslashes($mobo_info['mobo_formfactor']); $mobo_cpu = stripslashes($mobo_info['mobo_cpu']); $mobo_chipset = stripslashes($mobo_info['mobo_chipset']); $mobo_sysbus = stripslashes($mobo_info['mobo_sysbus']); $mobo_memory = stripslashes($mobo_info['mobo_memory']); $mobo_vga = stripslashes($mobo_info['mobo_vga']); $mobo_exp = stripslashes($mobo_info['mobo_exp']); $mobo_storage = stripslashes($mobo_info['mobo_storage']); $mobo_lan = stripslashes($mobo_info['mobo_lan']); $mobo_audio = stripslashes($mobo_info['mobo_audio']); $mobo_firewire = stripslashes($mobo_info['mobo_firewire']); $mobo_backpanel = stripslashes($mobo_info['mobo_backpanel']); $mobo_internal = stripslashes($mobo_info['mobo_internal']); $mobo_bios = stripslashes($mobo_info['mobo_bios']); $mobo_accessories = stripslashes($mobo_info['mobo_accessories']); $mobo_other = stripslashes($mobo_info['mobo_other']); //add to display $asus .= " <a href=\"motherboards.php?mobo_id=".stripslashes($mobo_id)."\"><strong>".$mobo_model."</strong></a><br/>"; } //free results mysqli_free_result($get_mobo_res); } echo $asus; ?> This code is placed inside a div. As you can see i just have a <br/> tag to put the next item on a new line. Im still confused where to put the code to count the number of rows etc. Thanks, Alex
  3. Hi, This has been baffling me for a couple hours now and i cant seem to figure it out. I have some code which creates an array and gets info from a mysql database and then displays in a list. This works great but after adding more and more rows to my database the list is now becoming quite large and doesnt look great on my site. Is it possible to split the list into multiple columns of about 25 and if possible once 3 or 4 columns have been created start another column underneath. To help explain i would be looking at a layout as follows: line 1 line 1 line 1 line 2 line 2 line 2 ... ... ... line 25 line 25 line 25 line 1 line 1 line 1 line 2 line 2 line 2 ... ... ... line 25 line 25 line 25 Im guessing there should be some sort of if statement to check how many items are being displayed and to create a new column if necessary. Is this correct? Thanks, Alex
  4. Thanks very much, my silly mistake! All seems to work great now
  5. Hi, Im trying to retrieve HTML from a mysql database but nothing i've tried seems to work. The HTML im trying to retrieve is an iframe with a link and styles (code from amazon associates). Im trying to display links to specific products on amazon from the product page on my site. All data about the product is retrieved from the database so i have code to select the amazon link row in my database table but i cant get it to display. It says the html isnt a string so i cant echo it, fair enough. I have tried using the following code: $get_buylink_sql = "SELECT mobo_buylink FROM mobo WHERE mobo_id = $mobo_id"; $get_buylink_res = mysqli_query($mysqli, $get_buylink_sql) or die(mysqli_error($mysqli)); while ($buylink = mysqli_fetch_array($get_buylink_res)) { echo"<iframe src=\"".$buylink."\" style=\"width:120px;height:240px;\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\"></iframe>"; } mysqli_free_result($get_buylink_res); mysqli_close($mysqli); I have also tried putting the whole iframe code in the database which didnt work either. The mobo_id variable works fine for retrieving the rest of the data and i need to get the amazon link from the same record. I hope i've put this in a way you can understand, but if not i'll try and explain better and give you a link to my site if needed. Thanks, Alex
  6. Thank you. I had tried something similar before. I found my underlying problem was that i had the PHP code in a HTML file, i have now changed the urban.html to urban.php and everything works. Thanks for your help
  7. I have a url as the source as i have an image watermark script. Before i had: <img src="urbanimage.php?Ref=image.jpg" alt="image"> which worked as i wanted, now instead of having to write each imagename in the codei want to have it get the name of each image from the database (or somehow get the names from a specific folder). My image upload script loads the image using the line: $im = imagecreatefromjpeg ('photos/urban/'.$_GET['Ref']); and then the watermark is added so unless i change the way of doing this i need to keep the urbanimage.php?Ref=image.jpg.
  8. Hi, What im trying to do may be a complicated way so if anyone can point me in the direction of a simpler way please advise. I have an image upload script which works fine, but i'd like the images to appear on a webpage without manually adding the img src to the webpage code. I have code which will add the filename to a database but i cannot seem to retrieve the filename from the database. My code is: <?php include("includes.php"); doConnect(); $get_image = "SELECT image FROM images"; $result= mysqli_query($mysqli, $get_image) or die(mysqli_error($mysqli)); while ($row = mysqli_fetch_array($result)) { echo "<img src=urbanimage.php?Ref=".$row['image'].">"; } ?> What im getting at the moment is "; } ?> as the output with an image placeholder before it. The url of the image is urbanimage.php?Ref=%22.$row['image'].%22 The image name is meant to be after the Ref= so the displayed image url should be urbanimage.php?Ref=imagename.jpg I have tried numerous things with no luck. I have made sure the database login details are correct. Thanks, Alex
  9. I've figured it out now. Thanks for all the help
  10. Thanks, However after not playing with PHP for a while im having a complete mental block. How do i get the image names? Sorry, just cant seem to think of what to do! Thanks
  11. Oh ok, thanks very much. That works. Eventually I would like to watermark each image in a certain folder (the photos im putting on the site) so i dont really want lots of PHP files if neccessary. Also to do that i'd like to know how to use this code (or something similar) to use this code to put a watermark on each image instead of just stating each filename. Im guessing i would need something like <img src="image.php?imagename"> or something like that once i have the code to get all images. Thanks
  12. Hi, I have some code to put a text watermark on an image (using imagettftext). The code i have works in a php file on its own but when i add it to my existing page i get problems. Firstly i had a problem with the "headers already sent..." problem but that was because i had header('Content-type: image/jpg'); with the rest of my code. Now i have moved "header('Content-type: image/jpg');" to the beginning of my html file and the rest of the PHP code where i want the image on my page. Now i dont get any image displayed. The code im using is: <?php //load image $im = imagecreatefromjpeg('C11ABX.jpg'); //figure out where to put the text $imagesize = getimagesize('C11ABX.jpg'); $x_offset = 50; $y_offset = $imagesize[1] - 20; //text color $textcolor = imagecolorallocate($im, 0xFF, 0xFF, 0xFF); //set font $font = 'detaranto.ttf'; //set size $size = '20'; //set angle $angle = '45'; //set text $text = 'SAMPLE'; imagettftext ($im ,$size ,$angle ,$x_offset ,$y_offset ,$textcolor ,$font ,$text ); //output watermarked image imagejpeg($im); ?> Any help would be great. Thanks
  13. Hi, I've done a search and cant find anything related to my problem. I have a newsfeed on my site and i want it to display with the latest news at the top. I have this code: $get_news = "SELECT title, text, DATE_FORMAT(datetime, '%e %b %Y at %T') AS datetime FROM newsfeed ORDER BY datetime DESC"; This works fine on one of my sites but on another i've just hit a problem. It seems to sort only by the day, not the rest of the date. I made a news post today with date and time of "27 Mar 2011 at 12:54:02" but a post from "28 Jan 2011 at 19:59:52" is above it. Any ideas why this is happening? Thanks, Alex
  14. Right, spent ages trying to get raknjak's way to work with my menu but couldnt do it. i couldnt get the product sub menu to work properly, was displaying strangely (which i believe was due to the display: inline), so for now i have gone with your way cssfreakie. bit of a bodge job but it seems to work until i re-write my navbar code which is looking like a good thing to do! Thanks for all your help everyone
  15. Thanks for the suggestions cssfreakie, but sadly they did not work. I did not get as far as trying on my laptop because it messed up for windows (desktop pc). Using min-width: 500px; pushed everything to the left so it was not centred (my reason for using a fixed width div. Making the width 300px squeezes "about us" and "contact us" onto a new line. Is there a way to centre the navbar without having to use a fixed width?
  16. Hi, Here is a screenshot taken on my laptop. http://i53.tinypic.com/30a8bhf.png This is using Firefox 3.6.13 - Firefox for Ubuntu Canonical - 1.0. I havent tried any other browser yet.
  17. Thanks for checking for me. My laptop screen res is 1280x800. Think it must be just my laptop then, just tried changing it to 1024x768 and it still does it! Oh well, its not a problem if its just me! Thanks
  18. Hi, I have a site working and looking as i want on a 4:3 monitor (1024x768 resolution) but when viewing on my laptop my menu is displayed wrong. I have read many sites and tried many things and i cant seem to fix it. my site is www.drunkengoldfish.com so you can view a live example. Here is my HTML to make the list for the nav bar: <div id="navbar"><ul> <li class="leftborder"><a href="index.html">Home</a></li> <li><a href="">Products</a><ul> <li class="topborder"><a href="tshirts.html">T-Shirts</a></li> <li><a href="hoodies.html">Hoodies</a></li> <li><a href="bags.html">Bags</a></li></ul> </li> <li><a href="shop.html">Shop</a></li> <li><a href="about.html">About Us</a></li> <li><a href="contactus.html">Contact Us</a></li> </ul> </div> and here is my css for the navbar: #navbar { float: left; width: 794px; margin: 0 0 1em 0; padding: 0; list-style: none; background-color: #000; border-bottom: 3px solid #FFF; border-top: 3px solid #FFF; border-left: 3px solid #FFF; border-right: 3px solid #FFF; } #navbar ul { list-style: none; width: 500px; text-align: center; margin: 0 auto; padding: 0; } #navbar li { float: left; list-style-type:none; } #navbar li a { display: block; padding: 8px 15px; text-decoration: none; font-weight: bold; font-size: 20px; color: #FFF; border-right: 3px solid #FFF; } .leftborder { border-left: 3px solid #FFF;} .topborder { border-top: 3px solid #FFF; } #navbar li a:hover { color: #000; background-color: #FF9C00; } #navbar li ul { display: none; width: 10em; background-color: #000; } #navbar li:hover ul { display: block; position: absolute; margin: 0; padding: 0; } #navbar li:hover li { float: none; } #navbar li:hover li a { background-color: #FF9C00; border-left: 3px solid #fff; border-bottom: 3px solid #fff; color: #000; } #navbar li li a:hover { background-color: #FFD74C; } If worst comes to worst and my code is crap then with some help im willing to re-write it, but i'd rather not do that if i can fix what i have. I hope i've provided enough info. Thanks, Alex
  19. Thank you, i got it working now. Thanks for helping me understand GET and POST
  20. I've tried reading through some of the threads but couldnt understand some of them. I've made a newsfeed script which works how i want it to. Now i want to add the function to delete a row from the database from an "admin panel" on the website. So far i have this: <?php include("includes.php"); doConnect(); $get_news = "SELECT id, title, text, DATE_FORMAT(datetime, '%e %b %Y at %T') AS datetime FROM newsfeed ORDER BY datetime DESC"; $result= mysqli_query($mysqli, $get_news) or die(mysqli_error($mysqli)); while ($row = mysqli_fetch_array($result)) { echo '<strong><font size="3">'. $row['title'] .' </font></strong><br/><font size="3">'. $row['text'] .'</font><br/><font size="2">'. $row['datetime'] .'</font><br/><br/><a href="delnews.php?del_id=' .$row['id']. '"> <strong>DELETE</strong></a>';} ?> then my delnews.php is: <?php include("includes.php"); doConnect(); $query = "DELETE FROM newsfeed WHERE id = "$_POST['id']""; $result = mysql_query($query); echo "The data has been deleted."; ?> I believe the problem is $_POST['id']. i've tried different things in there but none work. It displays the echo line but doesnt actually delete anything. I am new to php so this may be a stupid mistake, but try and play nice! Thanks
  21. Thanks for all your help guys. Much appreciated. Got my host to move me to a different server and now all is well and i have a site functioning as i want....for now! I may well be back soon asking more questions, but will definately stick around reading other topics etc to gain more knowledge.
  22. Thanks very much. will try those, but for now my host has decided to break!
  23. Wow quick reply. Thanks. Sorry forgot to mention this is in a .html file. I've included PHP in a HTML file before but could this be the reason? That would be the only thing thats changed from my local setup. That didnt cross my mind! changing to .php appears to work. thanks very much
  24. I am creating a news updates thing for my website and i have managed to get it working on my home PC (im using XAMPP) but when i upload to my webhost it doesnt appear to work. I am wondering if it is just my host or whether i have done something wrong and by chance it works on my home PC. Here is my code: <?php include("includes.php"); doConnect(); $get_news = "SELECT title, text, DATE_FORMAT(datetime, '%e %b %Y at %T') AS datetime FROM newsfeed ORDER BY datetime DESC"; $result= mysqli_query($mysqli, $get_news) or die(mysqli_error($mysqli)); while ($row = mysqli_fetch_array($result)) { echo '<strong>'. $row['title'] .' </strong><br>'. $row['text'] .'<br>'. $row['datetime'] .'<br><br>';} ?> My includes file is: <?php function doConnect() { global $mysqli; //connect to server and select database $mysqli = mysqli_connect("localhost", "user", "password", "dbname"); //if connection fails, stop script execution if (mysqli_connect_errno()) { printf("Connection failed: %s\n", mysqli_connect_error()); exit(); } } ?> I think im right in saying it connects properly because i do not see an error. what i get is: '. $row['title'] .' '. $row['text'] .' '. $row['datetime'] .' ';} ?> Im new to PHP (incase you hadnt guessed!) so not really sure whats happening. On my home PC i have PHP Version 5.3.1 and on my webhost its 5.2.14. Home PC mySQL version 5.1.41 and on webhost its 5.0.91-community. Could this be the reason? Thanks
×
×
  • 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.