Jump to content

laurenetherington

New Members
  • Posts

    3
  • Joined

  • Last visited

laurenetherington's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello guys! I'm currently writing a bit of an image gallery code which is working pretty well however there seems to be a few issues with the sytling and layout of the gallery. (It's nothing flash just displays the images and caption in category order) Now I am not sure how to go about doing this but is there any way to wrap each category in a div? I have the whole while loop wrapped in a div at present but I would like each category wrapped so I can style it a bit easier. Can someone please point me in the right direction. Currently my code looks like this: function Gallery(){ ini_set('display_errors',1); error_reporting(E_ALL); $conn = mysqli_connect("Why","Hello","There","Friends") or die('Cannot Connect to the database'); $q ="SELECT * FROM gallery_category AS c JOIN gallery_photos AS p ON p.categoryname = c.categoryname ORDER BY c.categoryid"; $result = mysqli_query($conn, $q) or trigger_error("Query Failed! SQL: $conn - Error: ".mysqli_error(), E_USER_ERROR); echo"<div class='gallery'>"; $categoryname=''; while($rows = mysqli_fetch_assoc($result)){ if ($categoryname != $rows['categoryname']) { $categoryname = $rows['categoryname']; echo"<div class='h'><h2>".$rows['categoryname']."</h2></div>"; } echo" <div class='gall'> <div class='gl-img'><img src='pathway/to/gallery/".$rows['photoname']."' alt='".$rows['categoryname']."'/></div> <div class='gl-cap'>".$rows['photocaption']."</div> </div>"; } echo"</div>"; $conn-> close(); } I don't know how to go about updating it so that it is this section that is wrapped whilst the "gall" class repeats (if that makes sense) echo"<div class='h'><h2>".$rows['categoryname']."</h2></div>"; } echo" <div class='gall'> <div class='gl-img'><img src='pathway/to/gallery/".$rows['photoname']."' alt='".$rows['categoryname']."'/></div> <div class='gl-cap'>".$rows['photocaption']."</div> </div>"; So that it looks like this: <div class="category"> <div class="h"><h2>Category Title</h2></div> <div class="gall"> <div class="gl-img"><img src="pathway/to/gallery/polarbear2.jpg"></div> <div class="gl-cap">Polar Bear</div> </div> <div class="gall"> <div class="gl-img"><img src="pathway/to/gallery/polarbear2.jpg"></div> <div class="gl-cap">Polar Bear</div> </div> <div class="gall"> <div class="gl-img"><img src="pathway/to/polarbear2.jpg"></div> <div class="gl-cap">Polar Bear</div> </div> <div class="gall"> <div class="gl-img"><img src="pathway/to/gallery/polarbear2.jpg"></div> <div class="gl-cap">Polar Bear</div> </div> </div> Any and all help on how to achieve this would be appreciated!! thank you
  2. I have realised my mistake. There is a comma missing from the query: $naquery = "UPDATE news SET newstitle='$t',newssnip='$sn',newsarticle='$s',newsimage='$finame' newscaption='$c',newsstatus='$st' WHERE newsid=$i"; Should be $naquery = "UPDATE news SET newstitle='$t',newssnip='$sn',newsarticle='$s',newsimage='$finame', newscaption='$c',newsstatus='$st' WHERE newsid=$i";
  3. Hello Happy Campers. Wonder if someone can point me in the right direction if it's not too much trouble. I have a script that allows an EU to edit a database entry. The users edits the information and hits submit which then edits the content and it all works spiffingly. My problem however arises when I go to upload a new image. The "Add" function uploads images to a directory and the location is saved in the database. When editing the image however, it unlinks it but it does not allow me to upload a new image. The code is as follows: ini_set('display_errors',1); error_reporting(E_ALL); $conn = mysqli_connect("HOST","DB","PWRD","DBTBL") or die('Cannot Connect to the database'); $i = mysqli_real_escape_string($conn,$_POST['newsid']); $t = mysqli_real_escape_string($conn,$_POST['title']); $st = mysqli_real_escape_string($conn,$_POST['stat']); $sn = mysqli_real_escape_string($conn,$_POST['snip']); $s = mysqli_real_escape_string($conn,$_POST['stry']); $c = mysqli_real_escape_string($conn,$_POST['cap']); $f = $_POST['oldim']; $s = nl2br($s); if(!is_uploaded_file($_FILES['file']['tmp_name'])) { $naquery = "UPDATE news SET newstitle='$t',newssnip='$sn',newsarticle='$s',newsstatus='$st' WHERE newsid=$i"; } else { if ($_FILES['file']['type'] != "image/gif" && $_FILES['file']['type'] != "image/jpeg" && $_FILES['file']['type'] != "image/jpg" && $_FILES['file']['type'] != "image/x-png" && $_FILES['file']['type'] != "image/png") { $naquery = "UPDATE news SET newstitle='$t',newssnip='$sn',newsarticle='$s',newsstatus='$st' WHERE newsid=$i"; } else { $finame = $_FILES["file"]["name"]; $result = move_uploaded_file($_FILES['file']['tmp_name'], "../news/$finame"); if ($result == 1) { $naquery = "UPDATE news SET newstitle='$t',newssnip='$sn',newsarticle='$s',newsimage='$finame' newscaption='$c',newsstatus='$st' WHERE newsid=$i"; $d = "../news/"; unlink("$d$f"); } else { $naquery = "UPDATE news SET newstitle='$t',newssnip='$sn',newsarticle='$s',newsstatus='$st' WHERE newsid=$i"; } } } $result = mysqli_query($conn, $naquery); if($result){ header('Location: ../news.php'); } else { echo "Oh No! Something has gone wrong and the data could not be uploaded"; echo "<br />"; echo "click <a href='Link'>here</a> to return to News"; } mysqli_close($conn); I am not getting an error message from PHP, I am just getting the generic "Something has gone wrong" that I have coded in myself. Is there anyone who can point me in the right direction please? Cheers
×
×
  • 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.