Jump to content

adam_bray

Members
  • Posts

    101
  • Joined

  • Last visited

  • Days Won

    1

adam_bray last won the day on April 18 2014

adam_bray had the most liked content!

Profile Information

  • Gender
    Not Telling

adam_bray's Achievements

Newbie

Newbie (1/5)

6

Reputation

  1. A form isn't your typical layout element and isn't really used for styling like you are. From what you've said.. your problem is that the form is display: block; change it to display: inline-block; and it should be sorted, but personally I'd wrap it in a div and style that.
  2. You're using $active wrong - $active = $query->fetch_array(); // $active is now an array if($active == 1) // $active is an array, it will never == 1 $active_update = "UPDATE $tbl_name SET $active=0"; // use $active as a string What are you trying to update at the end? For your current error you need to change - echo $query; // change to (in the same place) print_r($active); You're also going to get warnings about the $_GETs because they may not be defined - $user = (isset($_GET['user']))? $_GET['user'] : 'invalid'; $user_id = (isset($_GET['id']))? $_GET['id'] : 0; if($user == 'invalid'] || $user_id == 0) { // error code }
  3. It sounds like you're overthinking it. What's stopping you undoing the shadow in the mobile class? EG - /*Normal site*/ .example { font-weight: bold; } /*Mobile site*/ .example { font-weight: normal; }
  4. If you're changing the password hashing for your whole site then have a look at this - http://www.sitepoint.com/hashing-passwords-php-5-5-password-hashing-api/
  5. You want a fixed footer but you're using position: absolute; .. that's your issue.
  6. $id = "1"; $query = "SELECT * FROM table WHERE id = '$id'; $result = mysqli_query($query); while($data = mysql_fetch_assoc($result)) { echo $data['title']; echo $data['content']; echo $data['author']; } You need to be careful following this code as it's not very secure. The code Strider posted is better as it uses prepared statements. Assuming you go down the same route most beginners go with, you'll next want to show individual posts on each page, meaning you'll end up with this - $id = $_GET['id']; // Here's the problem $query = "SELECT * FROM table WHERE id = '$id'; $result = mysqli_query($query); while($data = mysql_fetch_assoc($result)) { echo $data['title']; echo $data['content']; echo $data['author']; } This will leave your code open to SQL injections which isn't a good idea. The idea being that if the user passed the following string to your code where you're searching for the ID, you could lose a lot of data. ' or 1=1 UNION DROP TABLE table; Strider's code uses prepared statements which is a much safer way of passing variables to your query.This: $sql="INSERT INTO article (title, content, author) VALUES ('$title', '$content', '$author')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } Becomes this: /* Set the SQL Statement */ $sql = "INSERT INTO article (title, content, author) VALUES ( ?, ?, ?)"; /* Prepare an SQL statement for execution */ $stmt = mysqli_prepare($con, $sql); /* Binds variables to a prepared statement as parameters */ mysqli_stmt_bind_param($stmt, "sss", $title, $content, $author); Have a look at the following, try typing in the functions you don't understand into PHP.net and you'll find good examples of what's happening. <?php // Connect to MySQL DB $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } // Look for the post ID $id = $_GET['id']; // Create a prepared statement if($stmt = $mysqli->prepare("SELECT title, content, author, date FROM table WHERE id=?")) { // Bind parameters for markers $stmt->bind_param("s", $id); // Run query $stmt->execute(); // Loop through the results while ($obj = $stmt->fetch_object()) { $results = '<h1>'.$obj->title.'</h1> <p>'.$obj->content.'</p> <p><em>Posted by '.$obj->author.'</em> on '.date("d F Y",$obj->date).'</p>'; } // Close statement $stmt->close(); } // Close connection $mysqli->close(); ?> <!doctype html> <html> <head> <meta charset="UTF-8"> <title>Untitled Document</title> </head> <body> <?php if( count($results) > 0 ) { echo $results; } else { echo '<p>There are no posts to display</p>'; } ?> </body> </html>
  7. Where is your select query and where do you define $title, etc.. for use on index.php ?
  8. All you've done is change the MySQL connect function but still used the other mysql_* functions - that's inconsistent and doesn't work. Have a read through this http://codular.com/php-mysqli to get a better understanding of what Ch0cu3r said; or even better, look at the PDO post - http://codular.com/php-pdo-how-to.
  9. Have you looked at in_array and array_key_exists?
  10. You should also tidy up your HTML, using line breaks like you have is pointless. '<h1> Welcome To The Site! </h1> <p>This site will let you post your ideas!</p>'; Use CSS to specify margins and padding between elements, not line breaks.
  11. Post where you get stuck and I'm sure someone can point you in the right direction. You need to at least try something before asking for help.
  12. It's similar to above, use a foreach loop and add arrays inside arrays - $warehouses = array(); foreach($array as $product => $warehouse) { $warehouses[$warehouse] = $product; } print_r($warehouses);
  13. I see you've added a single wrapper to your page, the way I'd do it would be to add 2 or 3. <div id="topbar-navigation" class="clearfix"> <div class="wrapper"> <div id="logo"> <!--FLOAT LEFT--> <!--LOGO HERE--> </div> <nav> <!--FLOAT RIGHT--> <ul> <!--NO FLOAT--> <li>...</li> </ul> </nav> </div> </div> <div id="main-container" class="wrapper clearfix"> <!--CONTENT HERE--> </div>
  14. Looking through your CSS, I'd change a couple of things. You've set a height on your main container, I presume that's because the background disappears without it. If so, look at using a clearfix You should create a wrapper class that sets a standard width across everything (header, content, footer) - div.wrapper { margin: 0 auto; width: 1000px; } continued... with the wrapper in place, set the <ul> to float: right;
  15. Absolute positioning most probably isn't the answer as it doesn't allow much flexibility at all. Do you have a link to where you're doing this? You don't need to specify margins and padding over 4 rules, you can combine them into 1 rule. There also shouldn't be a space around the - This margin - left: auto; margin - right: auto; margin - top: 20px; Should be margin-left: auto; margin-right: auto; margin-top: 20px; But this works better (read up on the web developers compass) margin: 20px auto 0;
×
×
  • 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.