-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Make the first option in each select <option value=''> Choose</option> If no other is "selected" then the first is shown by default
-
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.
-
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.
-
If short tags are disabled then <? must be <?php <?= must be <?php echo (<?= is allowed in 5.4 even with short tags disabled)
-
What version of PHP are you using? Do you have "short tags" enabled?
-
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
-
Since you are using mysqli, you need to use it consistently Note the mysqli versions also need the $con parameter (in the first position)
-
mysqli_query($UpdateQuery, $con); you have the parameters in wrong order - RTFM mysqli_query
-
Just give it the new name when you copy it.
-
Also if ($numrows=0) should be if ($numrows==0)
-
I could have used foreach ($xml->Output as $k => $op) but as $k would be unused it wasn't worth the huge extra effort
-
Store the file on the server if it always stays the same then copy it (renaming at same time) when form is submitted
-
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' ";
-
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>
-
Then why are you checking $WHSTATUS for 0 or 1 and setting $Status to a string value??
-
$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
-
PHP Newbie Upload Link Scripting/Folder Question
Barand replied to graphxsman's topic in PHP Coding Help
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")) -
If you alias the tables you need to reference their column using that alias returns.id should be t1.id
-
$UpdateQuery = "UPDATE tbl_contactinfo SET Name='$name', Address='address' WHERE Name='$hidden'"; Name='address' should be Name='$address'
-
How do you selectively BOLD output array elements from three arrays?
Barand replied to geomc's topic in PHP Coding Help
$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 -
you need to call session_start() at top of each page that uses $_SESSION
-
There's nought so rare as common sense! (Old Northern proverb)
-
If you have "Query was empty" error then $sql above has no value set.