Jump to content

alexsmith2709

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

alexsmith2709's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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?
×
×
  • 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.