Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Make the first option in each select <option value=''> Choose</option> If no other is "selected" then the first is shown by default
  2. That should work but I'd recommend using explicit JOIN...ON rather than just listing the tables and using the WHERE clause to define the relations. eg SELECT u.first_name, u.last_name, p.projektName FROM project p LEFT JOIN isProjectAssigne pa ON p.projectId = pa.projectId LEFT JOIN users u ON u.user_Id = pa.userId You can only do INNER JOINS (default) using that method. The explicit JOIN ON format separates the structure of the query from the selection criteria in the WHERE clause. I also prefer to use short table aliases as IMHO using full table names makes the query cluttered and harder to read I have used LEFT JOINS for the users so that projects with no one assigned are also listed. With an INNER JOIN you would only see projects with assigned users.
  3. If you have that isAssigned table then the assigneId in the project table becomes redundant (however I left it in) SELECT p.name as ProjectName , p.statusId , p.creatorId , u1.name as CreatorName , u1.surname as CreatorSurname , p.assigneId , u2.name as AssigneName , u2.surname as AssignSurname , GROUP_CONCAT(CONCAT(u3.name, ' ', u3.surname) SEPARATOR ', ') as Assignees FROM project p INNER JOIN Users u1 ON p.creatorId = u1.userId INNER JOIN Users u2 ON p.assigneId = u2.userId LEFT JOIN isAssigned a ON p.projectId = a.projectId LEFT JOIN Users u3 ON a.userId = u3.userId WHERE p.projectId = 5 GROUP BY p.projectId The other way is to take out the grouping and create a row for each assignee with project info repeated in each row. I used LEFT JOIN for the cases where no-one has been assigned yet.
  4. With radio buttons and check boxes only those selected are posted. So, it none are selected then $_POST['tskills'] and $_POST['gender'] do not exist, and hence your error messages. Check they exist with something like if (!isset($_POST['tskills'])) { // flag error or set default value }
  5. If short tags are disabled then <? must be <?php <?= must be <?php echo (<?= is allowed in 5.4 even with short tags disabled)
  6. What version of PHP are you using? Do you have "short tags" enabled?
  7. Connect twice to the User table with different table aliases SELECT p.name as ProjectName , p.statusId , p.creatorId , u1.name as CreatorName , u1.surname as CreatorSurname , p.assigneId , u2.name as AssigneName , u2.surname as AssignSurname FROM project p INNER JOIN Users u1 ON p.creatorId = u1.userId INNER JOIN Users u2 ON p.assigneId = u2.userId
  8. Since you are using mysqli, you need to use it consistently Note the mysqli versions also need the $con parameter (in the first position)
  9. mysqli_query($UpdateQuery, $con); you have the parameters in wrong order - RTFM mysqli_query
  10. Just give it the new name when you copy it.
  11. Also if ($numrows=0) should be if ($numrows==0)
  12. I could have used foreach ($xml->Output as $k => $op) but as $k would be unused it wasn't worth the huge extra effort
  13. Store the file on the server if it always stays the same then copy it (renaming at same time) when form is submitted
  14. Make sure the date range limits are in the format 'yyyy-mm-dd'. To compare just the date portion of the date/time use DATE() function. eg $a = '2013-10-20'; $b = '2013-10-23' $sql = "SELECT something FROM mytable WHERE DATE(mydate) BETWEEN '$a' AND '$b' ";
  15. You also need to define the path for the images on the first line define('IMAGEPATH', '/images/HomePageRibbon/images/');
  16. The link location goes in your HTML outside the image therefore that code can have no control over the link. You could do something simple like <?php define('IMAGEPATH', './images/'); $images = array ( array ( 'name' => 'im1.png', 'link' => 'http://www.google.com' ), array ( 'name' => 'im2.png', 'link' => 'http://www.msn.com' ) ); function getImage(&$images) { $upper = count($images)-1; $choice = rand(0, $upper); return sprintf('<a href="%s"><img src="%s" alt="advert" /></a>', $images[$choice]['link'], IMAGEPATH.$images[$choice]['name']); } ?> <html> <body> <?php echo getImage($images)?> </body> </html>
  17. Then why are you checking $WHSTATUS for 0 or 1 and setting $Status to a string value??
  18. $picker = 'October 9th, 2013'; $dt = DateTime::createFromFormat('F jS, Y', $picker); $dbDate = $dt->format('Y-m-d'); echo $dbDate; That will show $dbDate to contain "2013-10-09" which is the format you should be using to write dates to a database table
  19. I don't see the type of that uploaded file [type] => application/vnd.openxmlformats-officedocument.wordprocessingml.template in your list of acceptable types: if ((($_FILES["file"]["type"] == "text/doc") || ($_FILES["file"]["type"] == "text/pdf") || ($_FILES["file"]["type"] == "text/dotx") || ($_FILES["file"]["type"] == "text/rtf") || ($_FILES["file"]["type"] == "text/txt"))
  20. If you alias the tables you need to reference their column using that alias returns.id should be t1.id
  21. $UpdateQuery = "UPDATE tbl_contactinfo SET Name='$name', Address='address' WHERE Name='$hidden'"; Name='address' should be Name='$address'
  22. $text = "I bought a NOUN and a NOUN"; $text = str_replace("NOUN", "<span style='font-weight:700'>NOUN</span>", $text); // now replace NOUNs with cat and dog and similar for VERB and ADJ
  23. you need to call session_start() at top of each page that uses $_SESSION
  24. There's nought so rare as common sense! (Old Northern proverb)
  25. If you have "Query was empty" error then $sql above has no value set.
×
×
  • 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.