-
Posts
2,527 -
Joined
-
Last visited
Posts posted by DeanWhitehouse
-
-
it echos 1, but there are 3 entries in there
-
i am only doing this , as no one helped on my pagination problem but the step by step tutorial i am following , doesn't seem to work.
-
i am using this code
$totalCount = "SELECT image_id, COUNT(image_id) FROM hayleyimages GROUP BY image_id "; $rsCOUNT = mysql_query($totalCount, $conn) or die(mysql_error()); $rowCount = mysql_fetch_object($rsCOUNT); echo "$rowCount";
and the echo is the word
Object
anyone no why??
also this is the code i was told to use
"SELECT COUNT (*) as 'Total' FROM mysql.helpkeyword";
mysql is there database name
and
helpkeyword is there table name
this didn't work when i tryed it . is it outdated?
-
i found this code,
<?php $max = 2; //amount of articles per page. change to what to want $p = $_GET['p']; if(empty($p)) { $p = 1; } $limits = ($p - 1) * $max; //view the news article! if(isset($_GET['act']) && $_GET['act'] == "view") { $id = $_GET['id']; $sql = mysql_query("SELECT * FROM hayleyimages WHERE image_id = '$id'"); while($r = mysql_fetch_array($sql)) { $title = $r['image_name']; $story = $r['image_caption']; $author = $r['image_link']; echo "<div><p>$title</p><p>$author</p><p>$story</p></div>"; } }else{ //view all the news articles in rows $sql = mysql_query("SELECT * FROM hayleyimages LIMIT ".$limits.",$max") or die(mysql_error()); //the total rows in the table $totalres = mysql_result(mysql_query("SELECT COUNT(image_id) AS tot FROM hayleyimages"),0); //the total number of pages (calculated result), math stuff... $totalpages = ceil($totalres / $max); //the table echo "<table><tr><td>Title</td><td>Author</td></tr><tr>"; while($r = mysql_fetch_array($sql)) { $id = $r['id']; $title = $r['title']; $author = $r['author']; echo "<td><a href='news.php?act=view&id=$id'>$title</a></td><td>$author</td>"; } //close up the table echo "</tr></table>"; for($i = 1; $i <= $totalpages; $i++){ //this is the pagination link echo "<a href='news.php?p=$i'>$i</a>|"; } } ?>
now can some explain how to intergrate it into this code,
<?php require_once 'nav_bar.php'; if (isset($_GET['image_id'])) { if ((int) $_GET['image_id'] > 0) { $imageid = $_GET['image_id']; $sql = "SELECT * FROM hayleyimages WHERE image_id=$imageid"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $imageprofname = $row['image_name']; $imageprofcaption = $row['image_caption']; $imageproflink = $row['image_link']; if(mysql_num_rows($result) > 0) { ?> <div id="prof_img"> <table id="portfolio_image"> <tr><th><?php echo "$imageprofname"; ?></th></tr><tr><td><?php echo '<a href="'.$row['image_link'].'" rel="lightbox" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="200px" /></a>'; ?></td><td width="200px"><?php echo 'Image ID :'.$row['image_id'].''; ?></td></tr><tr><td><?php echo ' '.$row['image_caption']. ' </a>'; ?></td></tr><tr><td><a href="portfolio.php">Return To Gallery</a></td></tr></table></div> <?php } if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } exit(); } else { echo "Unknown Image ID! <br />"; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT image_id, image_name, image_link, image_caption FROM `hayleyimages`"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { ?> <table class="welcome_port"><tr><td>Welcome this is my portfolio.</td></tr></table> <table id="portfolio"> <?php $loop = 3; $loop1 = 3; while($row=mysql_fetch_array($result)){ // Start looping table row if ($loop == 3) { echo "<tr>"; } $toecho1 .= '<td><a href="?image_id='.$row['image_id'].'">Details</a></td><td> </td>'; $toecho .= '<td><a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="150px" /></a></td><td> </td>'; if ($loop == 3) { echo "</tr>"; $loop=0; } } if (substr($toecho, -5) != "</tr>") { $toecho .= "</tr>"; } echo $toecho; echo $toecho1; } ?> </table> <?php if (mysql_num_rows($result) < 1) { echo "No Images To Display"; } mysql_close(); ?> </div> </body> </html>
this bit in particular
<?php $loop = 3; $loop1 = 3; while($row=mysql_fetch_array($result)){ // Start looping table row if ($loop == 3) { echo "<tr>"; } $toecho1 .= '<td><a href="?image_id='.$row['image_id'].'">Details</a></td><td> </td>'; $toecho .= '<td><a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="150px" /></a></td><td> </td>'; if ($loop == 3) { echo "</tr>"; $loop=0; } } if (substr($toecho, -5) != "</tr>") { $toecho .= "</tr>"; } echo $toecho; echo $toecho1; } ?>
-
any other recomendations?
-
does that not have to be used with
SmartyPaginate: a class/plugin for data set pagination within the Smarty
template environment.
-
how can i paginate this
require_once 'nav_bar.php'; if (isset($_GET['image_id'])) { if ((int) $_GET['image_id'] > 0) { $imageid = $_GET['image_id']; $sql = "SELECT * FROM hayleyimages WHERE image_id=$imageid"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $imageprofname = $row['image_name']; $imageprofcaption = $row['image_caption']; $imageproflink = $row['image_link']; if(mysql_num_rows($result) > 0) { ?> <table id="portfolio_image"> <tr><th><?php echo "$imageprofname"; ?></th><td><?php echo '<a href="'.$row['image_link'].'" rel="lightbox" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="200px" /></a>'; ?></td><td width="200px"><?php echo 'Image ID :'.$row['image_id'].''; ?></td></tr><tr><td><?php echo ' '.$row['image_caption']. ' </a>'; ?></td></tr></table> <?php } if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } exit(); } else { echo "Unknown Image ID! <br />"; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT image_id, image_name, image_link, image_caption FROM `hayleyimages`"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { ?> <table class="welcome_port"><tr><td>Welcome this is my portfolio.</td></tr></table> <table id="portfolio"> <?php $loop = 3; $loop1 = 3; while($row=mysql_fetch_array($result)){ // Start looping table row if ($loop == 3) { echo "<tr>"; } $toecho1 .= '<td><a href="?image_id='.$row['image_id'].'">Details</a></td><td> </td>'; $toecho .= '<td><a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="150px" /></a></td><td> </td>'; if ($loop == 3) { echo "</tr>"; $loop=0; } } if (substr($toecho, -5) != "</tr>") { $toecho .= "</tr>"; } echo $toecho; echo $toecho1; } ?> </table> <?php if (mysql_num_rows($result) < 1) { echo "No Images To Display"; } mysql_close(); ?> </div> </body> </html>
this is the exact piece that needs paginating
<?php $loop = 3; $loop1 = 3; while($row=mysql_fetch_array($result)){ // Start looping table row if ($loop == 3) { echo "<tr>"; } $toecho1 .= '<td><a href="?image_id='.$row['image_id'].'">Details</a></td><td> </td>'; $toecho .= '<td><a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="150px" /></a></td><td> </td>'; if ($loop == 3) { echo "</tr>"; $loop=0; } } if (substr($toecho, -5) != "</tr>") { $toecho .= "</tr>"; } echo $toecho; echo $toecho1; } ?>
i have tried pagination tutorials, but i can't ever get it to work
-
post a questions, or don't post
-
figure what out?
beat me to it
-
thanks, had to change some things, but it works
-
ok, thanks, can you give me an example of how to use this, as i am not very good with loops
-
how can i start a new line after every three database entry's ?
here is my code
<div id="body"> <?php if (isset($_GET['image_id'])) { if ((int) $_GET['image_id'] > 0) { $imageid = $_GET['image_id']; $sql = "SELECT * FROM hayleyimages WHERE image_id=$imageid"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $imageprofname = $row['image_name']; $imageprofcaption = $row['image_caption']; $imageproflink = $row['image_link']; if(mysql_num_rows($result) > 0) { ?> <table align="center" border="1"><th><?php echo "$imageprofname"; ?></th> <tr><td><?php echo '<a href="'.$row['image_link'].'" rel="lightbox" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="200px" /></a>'; ?></td><td width="200px"><?php echo 'Image ID :'.$row['image_id'].''; ?></td></tr><tr><td><?php echo ' '.$row['image_caption']. ' </a>'; ?></td></tr></table> <?php } if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } exit(); } else { echo "Unknown Image ID! <br />"; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT image_id, image_name, image_link, image_caption FROM `hayleyimages`"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { ?> <table border="1"><th>Images</th> <?php while($row=mysql_fetch_array($result)){ // Start looping table row ?> <tr><td><?php echo ' <a href="?image_id='.$row['image_id'].'">'.$row['image_name']. ' Details</a>'; ?></td><td><?php echo ' <a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" >'.$row['image_name']. ' </a>'; ?></td><td><?php echo ' <img src="'.$row['image_link'].'"width="150px" /></a>'; ?></td></tr> <?php } ?> </table> <?php if (mysql_num_rows($result) < 1) { echo "No Images To Display"; } } mysql_close(); ?> </div> </body> </html>
-
BUMP
anyone?
-
ok, soz, i am still learning.
Is it just the content not loading?
-
they shouldn't affect it , are they closed?
-
what are the HTML tags in the database?
also try this
?> <div class="editor" style="text-align: center"> <p class="editortitle" style="font-size: 175%; padding: 4px 0px 4px 0px; margin: 0px;">Welcome Letter</p> <textarea cols="80" rows="25" name="welcome"><?php echo"" . $row['welcome'] . ""; ?></textarea> </div> <?php
-
with this code i need to have pagination for it, and i need it so only 3 images a row on the page.
so like ,
|image1|image2|image3|
instead of
image1
image2
image3
this is my code
<!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=iso-8859-1" /> <title>Hayley - Home</title> <script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="js/lightbox.js"></script> <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" /> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> </head> <body> <div id="body"> <?php if (isset($_GET['image_id'])) { if ((int) $_GET['image_id'] > 0) { $imageid = $_GET['image_id']; $sql = "SELECT * FROM hayleyimages WHERE image_id=$imageid"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $imageprofname = $row['image_name']; $imageprofcaption = $row['image_caption']; $imageproflink = $row['image_link']; if(mysql_num_rows($result) > 0) { ?> <table align="center" border="1"><th><?php echo "$imageprofname"; ?></th> <tr><td><?php echo '<a href="'.$row['image_link'].'" rel="lightbox" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="200px" /></a>'; ?></td><td width="200px"><?php echo 'Image ID :'.$row['image_id'].''; ?></td></tr><tr><td><?php echo ' '.$row['image_caption']. ' </a>'; ?></td></tr></table> <?php } if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } exit(); } else { echo "Unknown Image ID! <br />"; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT image_id, image_name, image_link, image_caption FROM `hayleyimages`"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { while($row=mysql_fetch_array($result)){ // Start looping table row ?> <table border="1"><th>Images</th> <tr><td><?php echo ' <a href="?image_id='.$row['image_id'].'">'.$row['image_name']. ' Details</a>'; ?></td><td><?php echo ' <a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" >'.$row['image_name']. ' </a>'; ?></td><td><?php echo ' <img src="'.$row['image_link'].'"width="200px" /></a>'; ?><br /></td></tr> </table> <?php } if (mysql_num_rows($result) < 1) { echo "No Images To Display"; } } mysql_close(); ?> </div> </body> </html>
-
-
i found this on the net.
<? if(isset($HTTP_COOKIE_VARS["users_resolution"])) $screen_res = $HTTP_COOKIE_VARS["users_resolution"]; else //means cookie is not found set it using Javascript { ?> <script language="javascript"> <!-- writeCookie(); function writeCookie() { var today = new Date(); var the_date = new Date("December 31, 2023"); var the_cookie_date = the_date.toGMTString(); var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height; var the_cookie = the_cookie + ";expires=" + the_cookie_date; document.cookie=the_cookie location = 'get_resolution.php'; } //--> </script> <? } ?>
or this
Put this on the page: <script language="javascript"> window.location.href = "screen.php?width=" + screen.width + "&height=" + screen.height; </script> Then create a file called screen.php and use this: <?php $width = $_GET['width']; $height = $_GET['height']; echo "You are using a $width x $height screen resolution"; ?>
-
just changed some of the variables, therefore fixed.
Thanks for tidying up the code a bit.
-
this is my code
<?php if (isset($_GET['image_id'])) { if ((int) $_GET['image_id'] > 0) { $imageid = $_GET['image_id']; $sql = "SELECT * FROM `hayleyimages` WHERE `image_id`='{$imageid}' LIMIT 0,1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $imageprofname = $row['image_name']; $imageprofcaption = $row['image_caption']; $imageproflink = $row['image_link']; echo "$imageprofname<br>$imageprofcaption<br>"; ?> <table align="center" border="1"><th>Image<?php echo "$imageprofname"; ?></th> <tr><td><?php echo ' <img src="'.$rows['image_link'].'"width="200px" /></a>'; ?></td><td><?php echo 'ID'.$rows['image_id'].''; ?></td></tr><td><?php echo ' <a href="'.$rows['image_link'].'" rel="lightbox" title="'.$rows['image_caption']. '" >'.$rows['image_name']. ' </a>'; ?></td><td><br /></td></tr> </table> <?php if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } exit(); } else { echo "Unknown Image ID! <br />"; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT image_id, image_name, image_link, image_caption FROM `hayleyimages`"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { while($rows=mysql_fetch_array($result)){ // Start looping table row ?> <table align="center" border="1"><th>Images</th> <tr><td><?php echo ' <a href="?image_id'.$rows['image_id'].'">'.$rows['image_name']. ' Details</a>'; ?></td><td><?php echo ' <a href="'.$rows['image_link'].'" rel="lightbox" title="'.$rows['image_caption']. '" >'.$rows['image_name']. ' </a>'; ?></td><td><?php echo ' <img src="'.$rows['image_link'].'"width="200px" /></a>'; ?><br /></td></tr> </table> <?php } if (mysql_num_rows($result) < 1) { echo "No Images To Display"; } } mysql_close(); ?>
But this is not working, the page has a table with a dynamic link in it, this links address is http://hayley.awardspace.com?image_id(then the image id number)
but when you click on the link it has the same content, it shouldn't.
the URL changes in the address bar, but the page remains unchanged .
any ideas?
-
how can i get the name of an uploaded file,
this is my code
<?php if(isset($_POST['upload'])) { $target = "images/"; $image = $_POST['uploaded']; $imagename = $_POST['imagename']; $imagecaption = $_POST['imagecaption']; $user_check = mysql_num_rows(mysql_query("SELECT * FROM `hayleyimages` WHERE image_name = 1 ")); $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } if($user_check >= 1) { echo "$imagename already exists, please rename it."; } //If everything is ok we try to upload it else { //if($image && $imagename && $imagecaption) //{ mysql_query("INSERT INTO `hayleyimages` (image_link, image_name, image_caption, image_id) VALUES ( '$image','$imagename','$imagecaption', '')") or die('Error ' . mysql_error()); if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } //} //else //{ //echo "<br>Please make sure all fields are filled in."; //} } } ?> <form enctype="multipart/form-data" action="<?php $_SERVER['PHP_SELF'] ?>" method="POST">Image Name: <input type="text" name="imagename" /><br />Image Caption: <input type="text" name="imagecaption" /><br /> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Submit" name="upload" /> </form>
this
"The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
only echos
The file has been uploaded
-
how can i get the name of the uploaded file (and the extension e.g. jpg)?
-
ok, i solved that part
now for this problem
<?php if(isset($_POST['upload'])) { $target = "images/"; $image = basename( $_FILES['uploadedfile']['name']); $imagename = $_POST['imagename']; $imagecaption = $_POST['imagecaption']; $image_thumb = '<img src='.$image.' width="200px"/>'; $image_link = '<a href='.$image.' rel="lightbox" title='.$imagecaption.'>'.$imagename.'</a>'; $user_check = mysql_num_rows(mysql_query("SELECT * FROM `hayleyimages` WHERE image_name=1 ")); $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } if($user_check >= 1) { echo "$imagename already exists, please rename it."; } //If everything is ok we try to upload it else { //if($image && $imagename && $imagecaption) //{ mysql_query("INSERT INTO `hayleyimages` (image_link, image_name, image_caption, image_id, image_thumb) VALUES ('$image_link','$imagename','$imagecaption', '', '$image_thumb')") or die('Error ' . mysql_error()); if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } //} //else //{ //echo "<br>Please make sure all fields are filled in."; //} } } ?> <form enctype="multipart/form-data" action="<?php $_SERVER['PHP_SELF'] ?>" method="POST">Image Name: <input type="text" name="imagename" /><br />Image Caption: <input type="text" name="imagecaption" /><br /> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Submit" name="upload" /> </form> </body> </html>
these two bits
$image_thumb = '<img src='.$image.' width="200px"/>'; $image_link = '<a href='.$image.' rel="lightbox" title='.$imagecaption.'>'.$imagename.'</a>';
are being inserted to the database as
<a href= rel="lightbox" title=test>test</a> <img src= width="200px"/>
without links , and title=test should be title="test"
does anyone know how to fix this
[SOLVED] wierd mysql count result.
in PHP Coding Help
Posted
NOT SOLVED BUT CLOSED