-
Posts
1,008 -
Joined
-
Last visited
Posts posted by spiderwell
-
-
its the top debugging tip for SQL not working, i always do it
-
not quite
$pic2 .="ORDER by thumbnailID DESC LIMIT $Page_Start , $Per_Page" ; echo $pic2 ; $pic1 = mysql_query($pic2);
then run the script and see what it says
-
have you considered using nested lists and using either suckerfish css menus, or a jquery accordian menu?
that way you have all the menus listed in once go, and the css or javascript makes it all operational. it would not account for pushing the current choice to the top of the list though
-
i would like 2 help wid d images, but i canz not udderstand youz
-
try echoing out the sql statement just before you execute it, so you can see what it says exactly, and if need copy it into phpmyadmin
-
the file view.php, at no point in that file do you attempt to put a value into the variable $file, so it is empty
a value for this is being passed via a query string in the other script here:
<?php echo "<img src=\"view.php?file={$row["id"]}\">";?></td>
so in view.php you need to grab that value being passed to it
so put this line at the top of view.php
<?php include 'db.inc'; $file = $_GET['file']; $file = clean($file, 4);
-
<?php $objConnect = mysql_connect("localhost","","root") or die(mysql_error()); $objDB = mysql_select_db("sdf"); $pic2 = "SELECT * FROM images"; if (!isset($_GET['Page'])) $_GET['Page']='0'; $pic1 = mysql_query($pic2); $Num_Rows = mysql_num_rows($pic1); $Per_Page = 16; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) {$Page=1;} $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) {$Num_Pages =1;} else if(($Num_Rows % $Per_Page)==0) {$Num_Pages =($Num_Rows/$Per_Page) ;} else {$Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages;} $pic2 .=" order by thumbnailID ASC LIMIT $Page_Start , $Per_Page"; $pic1 = mysql_query($pic2); $cell = 0; echo ' <div id="tablediv"> <table border="0" cellpadding="17" cellspacing="0" class="table"> <tr>'; while($pic = mysql_fetch_array($pic1)) { if($cell % 4 == 0) { echo '</tr><tr>'; } if($cell == 2) { echo ' <td> fillerspace </td>'; } elseif ($cell == 3) { echo ' <td> Fillerspace2 </td>'; } else { echo ' <td> <a href="/' . $pic["link"] . '.php"> <div class="image"> <img src="https://s3.amazonaws.com/image/' . $pic["pic"] . '.png" alt="' . $pic["alt"] . '" height="200" width="200" /> </div> </a> </td>'; } $cell++; } echo '</tr></table></div>'; ?>
-
the first thing i spotted is you are listed by ASC, so you want to change it to DESC, this will put the new image at the top.
there seems to be an awful lot of extra code that you dont really need.
why is $pic2 and $link1 and $alt1 all the same SQL command? (well you add ordering and paging to $pic2 but this is the only recordset you need)
give me a moment and Ill post a stripped out version for you
-
it can't be because you ask this
This code works when theres no predefined value however I'm trying to modify it in case there IS a value from the DB which is from the " . $row2['content'] . " data.
but it doesn't appear in any of the code you have posted!?!
EDIT:: glad you fixed it , as I had no clue
-
hang on, I'll just get my crystal ball
post the relevant code please
-
i cant even see " . $row2['content'] . " in your code,
its very hard to second guess your code if we can't see it.
I am guessing its within the $row3 loop that you want 'selected' echoed into the <option>, but you haven't given us anything to work with
-
when you say $row['mycount'] does not exist do you mean its value is NULL?
-
i cant even see " . $row2['content'] . " in your code,
what exactly are you trying to do, preselect an option if it is matching in $row2['content'] ?
-
if you dont need it, dont use it.
-
the statement isnt quite formed correctly
<?php if ($new==0) { echo "new";} else { echo "old "; } ?>
also theres a difference with "0" and 0, "0" is a string whereas 0 is a number, or false
-
the first example will throw an error saying name is undefined if it wasnt found in the $_POST array, that is Null
isset is a way of being sure something exists before retreiving its value
i usually retreive all my form values like this
if (isset($_POST['name'])) $name = $_POST['name'];
-
is view.php missing $file = $_GET['file'] ?
-
ryan you are doing what miko said not to do with the SQL, just use one SQL statement and order by region.
<?php $currentregion = false; $result = "SELECT * FROM regions ORDER BY region ASC;"; while ($row=mysql_fetch_assoc($result)) { if (!$currentregion) //first call { echo "<h3>" . $row['region'] . "</h3>"; $currentregion = $row['region']; echo "<div><p>" ; } elseif($currentregion != $row['region']) // region has changed { echo "</p></div>"; //close last region div echo "<h3>" . $row['region'] . "</h3>"; $currentregion = $row['region']; echo "<div><p>" ; } echo "<a href=\"delete.php?region=".$row['region']."&country=".$row['country']."\" onclick=\"return confirm('Are you sure you want to delete?')\"><img src=\"http://www.veryicon.com/icon/png/System/Float/Delete.png\" height=\"20\"/></a>"; echo $row['country'] . "<br>"; }// end DB loop echo "</p></div>"; //close last div
p.s. i havent checked above code for typo errors.
-
and i found a better accordian script now for a site I have, so I might nick that for myself too!
-
yeh sorry mikosiko, i didnt realise you had replied, i thought it was ryandward.
the 2 solutions do give different results. mine puts all countries into 1 div tag, whereas yours puts each country into its own div tag, not sure which is correct for ryan
-
is it working how you want it too?
-
then you need to group by region or order by region.
then you need to make a check to see if region has changed as you loop through and close off the div and start a new one for the new region, when the region does change.
something roughly like
$currentregion = false; while ($row=mysql_fetch_assoc($result)) { if (!$currentregion) //first call { echo "<h3>" . $row['region'] . "</h3>"; $currentregion = $row['region']; echo "<div>" ; } elseif($currentregion != $row['region']) // region has changed { echo "</div>"; //close last region div echo "<h3>" . $row['region'] . "</h3>"; $currentregion = $row['region']; echo "<div>" ; } echo $row['country']; }// end DB loop echo "</div>"; //close last div
-
What are you trying to say?
I suggested a way to solve your issue did I not?
-
then you need to get this moved to the javascript section
Display data that has been written to the database on the same page load
in PHP Coding Help
Posted
why not just echo out $page_views instead