Jump to content

petewall

New Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by petewall

  1. I actually solved it with for ($j = 1; $j <= 20; $j++) { if(!empty($row['j'.$j]) && is_numeric($row['k'.$j])) { echo $row['z'.$j]." "; echo $row['k'.$j]." "; echo $row['j'.$j]; echo "<br />"; } }
  2. hey, i have a little problem, i'm fetching data from a table with 20x3 columns. i've namned them j1 -> j20, k1 -> k20, z1 -> z20. i need to check wether j1 -> j20 is empty and that k1 -> k20 is numeric. and if both these criteria are not met, none of j, k or z should be outputted. i've tried with if(!empty($row['j1']) && is_numeric($row['k1'])) { echo $row['z1']." "; echo $row['k1']." "; echo $row['j1']; echo "<br />"; } if(!empty($row['j2']) && is_numeric($row['k2'])) { echo $row['z2']." "; echo $row['k2']." "; echo $row['j2']; echo "<br />"; } it works, but theres just ALOT of code for something small and i'm wondering if there's another way to do this, maybe with a for-loop or something? i tried with: for ($j = 1; $j <= 20; $j++) { if(!empty($row['j1$j'])) { echo $row['z$j']." "; echo $row['k$j']." "; echo $row['j$j']; echo "<br />"; } } But i'm guessing you can't have the $j inside the $row['']. Anyone got any ideas? on how to make this piece of code more simple?
  3. alright, but anyone got any suggestions on easy scripts that's good to start with for a beginner like me? greatly appreciated
  4. alright, does it work the same if i declare it outside the function? like $myclass = $(".myclass"); and then $("#mydiv").click(function() { if ($myclass.is(":hidden")) { $myclass.slideDown("slow"); } else { $myclass.slideUp("slow"); } }); or does it have to be within the function?
  5. Hi, i've recently read a bit about jQuery, and started to write some code today, this is what i came up with so far: $("#mydiv").click(function() { if($(".myclass").is(":hidden")) { $(".myclass").slideDown("slow"); } else { $(".myclass").slideUp("slow"); } }); superbasic stuff that slides down a <div> on click. well, i'd love some tips on what to do next, something not to advanced and maybe even some pointers on what to look at to get the script done.
  6. Hey, i'm having some troubles figuring out how you make something like this to work index.php?p=page&i=otherpage. On a site i'm currently creating i have an index-file that with the $_GET includes the requested page for example index.php?p=band but when you go to the "band" page, a few sublinks will appear, and when you click on them i want them to still be there (i tried doing just "index.php?p=subpage" but then the sublinks dissappears since you're no longer on the band-page. Here's the php-code that i've come up with so far: <?php foreach($links as $menuItem) { $menuItemList = ucwords($menuItem); $menuItemLink = str_replace(" ", "", $menuItem); //Om sida ej är defined, p=index if (!isset($_GET['p'])) { $_GET['p'] = 'index'; } //Checkar om p är satt if (isset($_GET['p'])) { $page = $_GET['p']; } //Kirrar länkarna, om menuItemLink != page outputtas detta if ($menuItemLink != $page) { echo "<li id='nav'><a href='?p=$menuItemLink'>$menuItemList</a></li>"; } //är menuItemLink == page outputtas detta elseif ($menuItemLink == $page) { echo "<li id='current'><a href='?p=$menuItemLink'>$menuItemList</a></li>"; } else { echo "<li id='nav'><a href='?p=$menuItemLink'>$menuItemList</a></li>"; } } ?> </div> </div> <div id="subnav"> <div id="subnavlinks"> <?php if ($page == 'band') { include_once 'navigation/band_nav.php'; } elseif ($page == 'music') { include_once 'navigation/music_nav.php'; } elseif ($page == 'events') { include_once 'navigation/events_nav.php'; } elseif ($page == 'fittanihoransomfan') { include_once 'navigation/fittanihoransomfan_nav.php'; } else (include_once 'navigation/index_nav.php'); ?> I hope it makes any sense and that someone can help me cause i'm really quite new to php. and please ignore the comments that are in swedish
  7. Alright, thanks for the answer! I tried the header code, but when i try to submit a form all i get is "page cannot be found" when it tries to find the page "add_dates.php" :/
  8. So i have a little script for my bands site, you're supposed to log in and submit a form that inserts the data into mysql and then displays it on the "tour" page. the problem i'm having is that everytime i hit F5 the latest entry gets duplicated. is there anyone who can help me? i'm pretty new to .php and mysql and this problem has been bugging me for quite some time now. well, here's the code: add_dates.php: <?php require_once 'db.php'; $database = mysql_connect($dbhost, $dbuser, $dbpass); if (!$database) die("Unable to connect to mysql: " . mysql_error()); mysql_select_db($dbname); if (isset($_POST['date']) && isset($_POST['location']) && isset($_POST['time']) && isset($_POST['cost'])) { $date = ($_POST['date']); $location = ($_POST['location']); $time = ($_POST['time']); $cost = ($_POST['cost']); $query = mysql_query("INSERT INTO tourdates (date, location, time, cost) VALUES ('$date', '$location', '$time', '$cost')",$database); } $query = "SELECT date, location, time, cost FROM tourdates WHERE date >= NOW() ORDER BY date ASC"; $result = mysql_query($query); echo "<table border='1' cellpadding='5'>"; echo '<td colspan="4"><center><b>Upcoming Gigs:</b></td><br /></center>'; echo "<tr> <th>Date</th> <th>Location</th> <th>Time</th> <th>Cost</th> </tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo $row['date']; echo "</td><td>"; echo $row['location']; echo "</td><td>"; echo $row['time']; echo "</td><td>"; echo $row['cost']; echo "</td></tr>"; } echo "</table>"; $query = "SELECT date, location, time, cost FROM tourdates WHERE date < NOW() ORDER BY date DESC"; $result = mysql_query($query); echo "<table border='1' cellpadding='5'>"; echo '<td colspan="4"><center><b>Past Gigs:</b></td><br /></center>'; echo "<tr> <th>Date</th> <th>Location</th> <th>Time</th> <th>Cost</th> </tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo $row['date']; echo "</td><td>"; echo $row['location']; echo "</td><td>"; echo $row['time']; echo "</td><td>"; echo $row['cost']; echo "</td></tr>"; } echo "</table>"; ?> dates_form.php <form method="post" action="add_dates.php"> datum: <input type="text" name="date"> plats: <input type="text" name="location"> tid: <input type="text" name="time"> kostnad: <input type="text" name="cost"> <input type="submit" name="submit" value="lägg till"> </form>
×
×
  • 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.