-
Posts
1,008 -
Joined
-
Last visited
Everything posted by spiderwell
-
My code works fine. Once I add a WHERE sql function, it doesn't
spiderwell replied to asmith6's topic in PHP Coding Help
its the top debugging tip for SQL not working, i always do it -
My code works fine. Once I add a WHERE sql function, it doesn't
spiderwell replied to asmith6's topic in PHP Coding Help
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 -
Left Navigation coding - more depth to navigation bar
spiderwell replied to Matt B's topic in PHP Coding Help
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 want to display imageid along wid image in a table format
spiderwell replied to madhmad's topic in PHP Coding Help
i would like 2 help wid d images, but i canz not udderstand youz -
My code works fine. Once I add a WHERE sql function, it doesn't
spiderwell replied to asmith6's topic in PHP Coding Help
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 but it doesn't appear in any of the code you have posted!?! EDIT:: glad you fixed it , as I had no clue
-
date format works on one page not the other?
spiderwell replied to mullberrymae's topic in PHP Coding Help
hang on, I'll just get my crystal ball post the relevant code please -
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
-
How do I write a 0 count if a row doesn't exist?
spiderwell replied to Jeffro's topic in PHP Coding Help
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.
-
I'm having trouble with my code, any help would be appreciated.
spiderwell replied to vet911's topic in PHP Coding Help
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.
-
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
-
how to check entered text before submitting
spiderwell replied to f.ismayil's topic in PHP Coding Help
then you need to get this moved to the javascript section -
how to check entered text before submitting
spiderwell replied to f.ismayil's topic in PHP Coding Help
do you want clientside or server side validation, serverside validation will mean the form will be posted. you can use javascript to check if a form input has text in it simply enough. validation using both would make it more robust, as javascript validation can be hacked fairly easily