Jump to content

Ron916

Members
  • Posts

    12
  • Joined

  • Last visited

Ron916's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You probably want to research "wordpress child themes" and then make a child theme of the Twenty-Eleven theme and modify it to your liking
  2. Consider just formatting the string on the server side, less mess? $name = "lowercase"; echo ucfirst($name); //output: Lowercase $name = "siLlYnAme'; echo ucfirst(strtolower($name)); //output: Sillyname
  3. How about this? str_replace('.smile.', '<img src="/path/to/smiley.jpg" alt=":)">', $html);
  4. I think this is what you're after: $x = 1; echo $x++; // 1 $x = 1; echo ++$x; // 2
  5. woooooooooooot!! I had to put double quotes on: $form2 .= '<option value='$counter'>$counter</option>'; But its perfect nonetheless! Thank you!
  6. Mornin', I've created phpforms.php and am using that for quick access to forms. Inserting html and php data into a variable. Not even sure if this is a good idea... works ok until I put a while statement in, too many quotes?? This code works to populate a drop down list with the last 120 years: <html> <body> <form action='./createuser.php' method='POST'> <select name='year'> <?php $counter = date('Y'); while($counter > date('Y')-120) { echo "<option value='$counter'>$counter</option>"; $counter = $counter - 1; } </select> </form> </body> </html> But I'd like to insert this code into a variable as such: <?php $form2 = " <form action='./createuser.php' method='POST'> <select name='year'> <?php $counter = date('Y'); while($counter > date('Y')-120) { echo '<option value='$counter'>$counter</option>'; $counter = $counter - 1; } ?> </select> </form> "; ?> <html> <body> <?php echo $form2; ?> </body> </html> The above code gives me a drop down box full of nottthiiinnngggggg, the only difference is that the whole thing is within double quotes now o.O I'm not sure if/how I can replace the double quotes in the echo statement... or if there's a better way? As always any and all comments are smexy and welcome!
  7. amg awesome, I knew there were better ways, thank you all I got a lot of good info from comparing my code, and even ended up with a lesson in concatenating(??)... !
  8. Groovy. I got it working. Ty. If anyone would like to make comments on the final code please feel free, I'd love the input. index.php (lots of random html stuff I left out) <html> <body> <?php $dbhost = 'localhost'; $dbuser = 'fakeuser'; $dbpass = 'fakepass'; $con = mysql_connect($dbhost,$dbuser,$dbpass); $set = mysql_query('SHOW DATABASES',$con); $dbs = array(); while($db = mysql_fetch_row($set)) $dbs[] = $db[0]; echo "<form name=\"form1\"action=\"deletedb.php\" method=\"post\">"; foreach($dbs as $db) { echo "<br><tr><td><input type='radio' name={$db} value={$db}>{$db}</td></tr>\n"; } echo "<br><br><input type=submit value=DeleteDB>"; echo "</form>"; ?> </body> </html> deletedb.php <html> <body> $stuff = array_values($_POST); $dbname=$stuff[0]; $dbhost = 'localhost'; $dbuser = 'fakeuser'; $dbpass = 'fakepass'; $con = mysql_connect($dbhost,$dbuser,$dbpass); echo "Deleting database: " . $dbname . "<br><br>"; if (mysql_query("DROP DATABASE $dbname",$con)) { echo "Database dropped, ur data's gone!" . "<br>"; } else { echo "Error deleting database: " . mysql_error() . "<br>"; } ?> </body> </html>
  9. Hi again, I used the foreach() loop thusly: foreach($dbs as $db) { echo "<br><tr><td><input type='radio' name='{$db}' value='{$db}'>'{$db}'</td></tr>\n"; } Hitting submit takes me to the 2nd php page which then runs a print_r($_POST): Array ( [asdf] => asdf [submit] => Submit Query ) asdf is the data I need, how to I cut out the rest O.O edit: attempting to add code tags
  10. <3 ! Thanks folks, sorry for my frankenstein code! I'm giving the foreach() loop a try.
  11. Hello ya'll, first post. Please be gentle Learning by creating myphpAdmin type page functions, still have a long way to go. Lots of cut/paste and modifications so far. Here I retrieve a list of databases, then add radio buttons, can anyone tell me where I'm going wrong? Am I doing it all wrong? <?php $con = mysql_connect($dbhost,$dbuser,$dbpass); $set = mysql_query('SHOW DATABASES',$con); $dbs = array(); while($db = mysql_fetch_row($set)) $dbs[] = $db[0]; echo '<form action="deletedb.php" method="post">'; echo '<input name=$db type=radio value=$db>'; echo implode('<tr><td><input type="radio" name="<?php echo $dbs; ?>" value="<?php echo $dbs; ?>"</td></tr>' , $dbs) . "<br>"; echo '<input type="submit">'; echo '</form>'; ?> It does retrive the DB list. And it does put the radio buttons next to each one, in a horizontal line, I'd prefer a verticle list but that's not so important right now. I can't seem to get $_POST['xxx'] to work in deletedb.php (using echo to test with), I've tried name and value but it's not sending anything over, I copied the $set, $dbs, while and echo implode lines from the web and messed around til I had something resembling a table with radio buttons. ANY comments on this code, what's wrong or what could be better are encouraged and greatly appreciated! Thanks!
×
×
  • 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.