Jump to content

solon

Members
  • Posts

    214
  • Joined

  • Last visited

    Never

About solon

  • Birthday 12/15/1985

Contact Methods

  • Website URL
    http://www.mkwebcy.com

Profile Information

  • Gender
    Male
  • Location
    Cyprus, Nicosia

solon's Achievements

Member

Member (2/5)

0

Reputation

  1. Try bspace's approach. remove the "OR" from your queries and implode it later. But one thing you should do is: echo $query; to see exactly what your query looks like and find the error.
  2. you have to try and use something like the following: $query = "SELECT * FROM database WHERE "; if($city != "") { $query .= "city LIKE '%$city%' OR"; } if($name != "") { $query .= " name LIKE '%$name%' OR"; } and so on... to complete the query in that way, for the variables that have values in them. And then execute the query command. Because when the value is empty it show all results if you use "LIKE".
  3. The error "Undefined index id" is referring to the $_GET['id'] variable. since you don't sent anything using the GET method it comes up us undefined. You can edit that and line and use the following: <span class="date"><?php include"header.php"; if(isset($_GET['id']) //CHECK IF GET ID IS SET ELSE GET IT FROM HIDDEN FIELD IN THE FORM { $topicid=$_GET['id']; } else { $topicid=$_POST['id']; } $sql="SELECT*FROM topics WHERE topicsID=$topicid"; $result=mysql_query($sql) or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"{$row['topics_date']}"; } ?></span> </p> </div> <h3>Comments:</h3> <table> <tr class="row-a"> <td class="first"></td> <td> <?php include"header.php"; if(isset($_POST['submit'])) { $comment=mysql_real_escape_string(trim($_POST['comment'])); $name=mysql_real_escape_string(trim($_POST['name'])); if($comment!=='' && $name!=='') { $ins="INSERT INTO post(post_content,post_by)VALUES('$comment','$name')"; mysql_query($ins) or die(mysql_error()); $sql="SELECT post_content,post_by FROM post ORDER BY topicsID"; $result=mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"<strong>{$row['post_by']}</strong>: {$row['post_content']}"."</br>"; } } } ?></td> </tr> </table> <h3>Post your comments here</h3> <form action='<?php $_SERVER['PHP_SELF'];?>' method='post'> <textarea name="comment" id="content" style="width:400px;height:50px;background-color:#D0F18F;color:#000000;font:15px/20px cursive;scrollbar-base-color:#638E0D;"></textarea> <br /> Name:<input type="text"name="name"/> <input class="button" type="submit"name="submit"value="submit" /> <input type="hidden" name="id" value="<?php echo $topicid; ?>" /> //THIS LINE IS A HIDDEN FIELD SAVING THE TOPIC ID FOR USE AFTER THE FORM IS SUBMITED </p> </form> <br />
  4. Try it now (there was a syntax error in the query): <h3>Comments:</h3> <table> <tr class="row-a"> <td class="first"></td> <td> <?php include"header.php"; if($_POST['submit']) { $post = $_POST["comment"]; $by = $_POST["name"]; $add = "INSERT INTO `post` values(`post_content`,`post_by`) ('$post','$by')"; $add_values = mysql_query($add) or die(mysql_error()); } $sql="SELECT post_content,post_by FROM post ORDER BY topicsID"; $result=mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"<strong>{$row['post_by']}</strong>: {$row['post_content']}"."</br>"; } ?> </td> </tr> </table> <h3>Post your comments here</h3> <form action='<?php $_SERVER['PHP_SELF']; ?>' method='post'> <textarea name="comment" id="content" style="width:400px;height:50px;background-color:#D0F18F;color:#000000;font:15px/20px cursive;scrollbar-base-color:#638E0D;"></textarea> <br /> Name:<input type="text"name="name"/> <input class="button" type="submit"name="submit"value="submit" /> </p> </form> It should work now
  5. Try the following (change the query to match your table and values <h3>Comments:</h3> <table> <tr class="row-a"> <td class="first"></td> <td> <?php include"header.php"; if($_POST['submit']) { $post = $_POST["comment"]; $by = $_POST["name"]; $add = "INSERT INTO `post` values(`post_content`,`post_by`,) ('$post','$by')"; $add_values = mysql_query($add) or die(mysql_error()); } $sql="SELECT post_content,post_by FROM post ORDER BY topicsID"; $result=mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"<strong>{$row['post_by']}</strong>: {$row['post_content']}"."</br>"; } ?> </td> </tr> </table> <h3>Post your comments here</h3> <form action='<?php $_SERVER['PHP_SELF']; ?>' method='post'> <textarea name="comment" id="content" style="width:400px;height:50px;background-color:#D0F18F;color:#000000;font:15px/20px cursive;scrollbar-base-color:#638E0D;"></textarea> <br /> Name:<input type="text"name="name"/> <input class="button" type="submit"name="submit"value="submit" /> </p> </form> I hope this helps
  6. Excellent!! Thank you very much cssfreakie .
  7. Great, i did not know that could be done without positioning. Although now that you mention it , it's logical. I'll have to use margins and paddings for spacing between elements though right?
  8. Thanks cssfreakie, i will try that.
  9. Hey guys i have a problem with one of my designs. I have this page designed using html/css with only div's and at the bottom of the page it show a large empty space. I read somewhere that the problem has to do with using position:relative; but i couldn't resolve the problem. Any one has any ideas as to why this is happening? By the way the code has passed the validation of w3c. (http://validator.w3.org/check?uri=http%3A%2F%2Fmkwebcy.com%2Falboro%2F) This is the link to the test page so you can see the problem as well as the code: http://mkwebcy.com/alboro/ Thanks in advance Solon
  10. Just do the following: When echoing a onclick() event in your code you dont need to do anything different than what you do when echoing lets say 'name' pr any other attribute name of a tag. echo "<tr><td>WrkComp</td><td><input type='checkbox' onClick='show()' name='WrkComp[]' value='DEP' '.$checked.' '.$Disabled.'/></td>";
  11. In that case i believe you should use sessions. When a user logs in (after the username and password are correct based on your db) you should have something like: session_start(); $_SESSION['user'] = 1; //or $_SESSION['user'] = $user_id; //which you get from your db table now if you do that in the login process page then you can have this in your homepage: session_start(); if(isset($_SESSION['user'])) { //show Logout link and user info } else { //show your login form }
  12. You could use session variables to store the values along the way. for example: page 1 form will POST the info of the completed fields to page 2 and to store them in a session variable you do the following: session_start(); $_SESSION['name'] = $_POST['name']; //... //... //etc... And for page 2 you do the same thing in page 3
  13. Try this: unset($eyeColorArray); $eyeColorArray = array('Black','Blue','Brown','Green','Grey','Hazel','Other'); echo "<select>"; //you missed the select tags foreach($eyeColorArray as $ectemp) { echo('<option value="' . $ectemp . '"> ' . $ectemp . ' </option>'); } echo "</select>"; //closing tags
  14. Hey djscoop, could you provide us with some more database information? how does you script store the votes in the db? if possible show us the structure of your database tables to see if there is another way of extracting the information you want with a mysql query!
×
×
  • 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.