PHP - Im Stumped Rofl
Code: [Select]
$color = ' class="pin"'; $pin++; echo $pin; long story short, let's just say, this is inside a while loop echoing out my forum Topics. $pin echo's out 1 2 3, because they're 3 stickied Topics. I only want class="pin" to display on the very last <tr> tag. (which would be number 3, how?) Code: [Select] <tr<?php echo $color ?>> OK i do Code: [Select] if ($pin == 4){ $color = ' class="pin"'; }works if I have 4 Topics, stickied, but how would i change 4 to be dynamic? what if only 2 topics stickied? I tried Code: [Select] if ($pin == $pin){ $color = ' class="pin"'; } not work.. wouldn't $pin = 4? bcz $pin++ ? my help topics seem so noob, but i just cant comprehend lol Similar TutorialsCode: [Select] $DB->query("SELECT g_title from ibf_groups where g_title NOT IN ('Validating','Guests') order by g_title"); while($group = $DB->fetch_row()){ $data[] = $group['g_title']; } echo $data[0]; var_dump($data); var dump Code: [Select] 'TITLE' => string 'Validating' (length=10) 'ICON' => null 0 => string 'Admin' (length=5) 1 => string 'Donor' (length=5) 2 => string 'Loser' (length=5) 3 => string 'Members' (length=7) 4 => string 'Members+' (length=8) 5 => string 'Moderator' (length=9) 6 => string 'Senior Moderator' (length=16) how do I get rid of Validating? and ICON? I can't get this darn thing to update correctly. Probly a stupid (.) outa place. HELP! Code: [Select] <?php include 'connection.php'; if(!isset($_POST['submit'])) { $query = "SELECT * FROM news WHERE id = $_GET[id]"; $result = mysql_query($query); $news = mysql_fetch_array($result); $title = $_POST['title']; $body = $_POST['body']; } ?> <h1>Edit Article</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Title:<input type="text" name="title" value="<?php echo $news['title']; ?>" /><br /> Article:<textarea cols="35" rows="6" name="body"><?php echo $news['body']; ?></textarea> <br /> <input type="hidden" name="id" value="<?php echo $_GET['id']; ?>" /> <input type="image" src="/images/news/modify.png" name="submit" /> </form> <a href="admin.php"><img src="/images/news/cancel.png" border="0" /></a> <?php if(isset($_POST['submit'])) { $update = "UPDATE news SET `title`='$_POST[title]',`body`='$_POST[body]' WHERE id='$_POST[id]'" or die(mysql_error()); mysql_query($update) or die(mysql_error()); echo "The news article has been Modified!"; header('Location: /News/admin.php'); } ?> Hi guys, I have a simple INSERT code. It does not throw any errors and all seems ok but the data is just not appearing in the DB. I've spent ages looking over it but perhaps a 2nd set of eyes could help? Thanks! Code: [Select] $con = mysql_connect("localhost","posturep",""); $tablename = 'product'; if (!$con) { die('Could not connect: ' . mysql_error()); } //Form data sent $product_name = $_POST['product_name']; $product_active = $_POST['product_active']; $product_cat = $_POST['product_cat']; $product_desc = $_POST['product_desc']; $prod_inoutdoor = $_POST['prod_inoutdoor']; $prod_stackable = $_POST['prod_stackable']; $prod_discounted = $_POST['prod_discounted']; echo $product_name; $sql = "INSERT INTO $tablename (name) VALUES ($product_name)"; mysql_query($sql); echo "<p>Product Saved!</p>"; echo $sql; mysql_close($con); OK, I am officially stumped. I am trying to match a '[]' at the end of a string. Using $ to anchor doesn't work, nor does \z. $name = "cities[]"; if (preg_match("/\[\]\z/", $name)) { // why do I net get in here?? } Thanks. If I have code that looks something like this: <?php $t = array('one','two','three','_four','_five','_six'); $u = 'five'; foreach ($t as $v) { if (substr($v,0,1) != '_') { // if begins with an underscore, remove it, unless it is equal to _$u echo $v.'<br />'; } } ?> I am trying to take out all array items that begin with an underscore except the one that is equal to this.. _five something like $v == '_'.$u So what should be echoed is this: one two three _five Is there any way to do this with only an if, and not an if/else?? Thanks.. |