I have the following code:
{
echo "<tr>";
echo "<td>" . $row1['supervisiondate'] . "</td>";
echo "<td>" . $row1['level'] . "</td>";
echo "<td>" . $row1['division'] . "</td>";
echo "<td>" . $row1['supervisor'] . "</td>";
echo "<td>" . $row1['totalscore'] . "</td>";
echo "<form action='refereesupervision.php' method='post'>";
echo "<td>
<input name='refereeID' value='" . $row['refereeID'] . "'/>
<input name='supervisionID' value='" . $row1['supervisionID'] . "'/>
<input type='submit' value='View'/>";
echo "</form></td>";
echo "</tr>";
} </br>
When refereesupervision.php receives the data using post for each of the two variables, only the refereeID is received. It should be noted that there are two separate queries of two separate tables that produce $row and $row1.
Looking for some guidance or references to help me understand.
Cheers
according to comment change input name from ID to supervisionID
<input name='ID' value='" . $row1['supervisionID'] . "'/>
<input name='supervisionID' value='" . $row1['supervisionID'] . "'/>
According to comments and editing original question. Answer is
$refereeID is not the same as $refereeid
Related
this is my table in html php, i get the names of employees from DB
i need to insert in the database the content of input type=time
this is my php code
<?php
$nom='';
$prénom='';
$output='';
$connect = mysqli_connect("localhost", "root", "ntr-ktb123", "absence");
$sql="SELECT * FROM employés;";
$result = mysqli_query($connect, $sql);
echo "<table>
<tr>
<th>nom</th>
<th>prénom</th>
<th>Entrée matin</th>
<th>Sortie matin</th>
<th>Entrée soir</th>
<th>Sortie soir</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['NomEmp'] . "</td>";
echo "<td>" . $row['PrénomEmp'] . "</td>";
echo "<td>" . "<input type='time' " . "</td>";
echo "<td>" . "<input type='time' " . "</td>";
echo "<td>" . "<input type='time' " . "</td>";
echo "<td>" . "<input type='time' " . "</td>";
echo "</tr>";
}
$output="</table>";
echo $output;
?>
i have no idea how to insert the content of input type='time' in mysql DB
neither with type varchar or time.
can someone help me please?
Depending on the type of your field in your database. Assuming it's a DATETIME, you could format it with a date().
echo "<td>" . "<input type='time' value='" . date("H:i", strtotime($row['entree_matin'])) . "' /></td>";
insert your time inside the 'value' parameter in the time tag
exemple :''
<input id="time" type="time" value="12:13">
but first you have to insert the right format : hh:mm
Hello guys I have a code that selects out of my database and puts it into the textbox. Yet it only shows 1 word instead of the whole sentence.
this is my code:
while($row = mysql_fetch_array($myData)){
echo '<form action="details.php?ID='.$row['ID'].'" method="post">';
echo "<tr>";
echo '<input type="hidden" name="ID" value="'.$row['ID'].'">';
echo "<td>" . $row['ID'] . "</td>";
echo "<td>" . "<input type=text name=title value=" . $row['Title'] . " </td>";
echo "<td>" . "<input type=text size=45 name=detail value=" . $row['Detail'] . " </td>";
echo "<td>" . $row['eventDate'] . "</td>";
echo "<td>" . $row['dateAdded'] . "</td>";
echo "<td>" . "<input type=submit name=update value=update" . " </td>";
echo "<td>" . "<input type=submit name=delete value=delete" . " </td>";
I hope someone knows the answer because i've been stuck for like 1 hour and can't seem to find the answer. Thanks everyone!
you forget to close input all inputs should be closed properly.
echo '<td>' . '<input type="text" name="title" value="' . $row['Title'] . '">'.'</td>';
Also
echo '<td>' . $row['ID'] . '</td>';
echo '<td>' . '<input type="text" size="45" name="detail" value="'.$row['Detail'].'"></td>';
echo '<td>' . $row['eventDate'] . '</td>';
echo '<td>' . $row['dateAdded'] . '</td>';
echo '<td>' . '<input type="submit" name="update" value="update"> ' . '</td>';
echo '<td>' . '<input type="submit" name="delete" value="delete"> ' . '</td>';
I currently have two dropdown menus that a user will select the course and a golfer which will load a scorecard.
What I am trying to do now is when a user enters a value into the "Score" field I want the "points" to be automatically shown ("Points" is a read only input field). To do this I am assuming that I will have to give each table row for score and points a specific ID.
echo "<div class='scorecardTable'>
<table 'id=scorecardTable'>
<tr>
<th>HoleNumber</th>
<th>Par</th>
<th>Stroke Index</th>
<th>Score</th>
<th>Points</th>
</tr>'";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['holeNumber'] . "</td>";
echo "<td>" . $row['par'] . "</td>";
echo "<td>" . $row['strokeIndex'] . "</td>";
echo "<td> <input type='text' maxlength='2' id='score' /></td>";
echo "<td> <input type='text' id='points' readonly></td>";
echo "</tr>";
}
echo "</table>";
From the above code I am using PHP to print the information from my database but I was just wondering if anyone would know how to assign a unique ID to each of the score and points input fields so I can apply the calculation to each user input.
You could use a variable to count the rows and set the id.
$rowIndex = 0;
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['holeNumber'] . "</td>";
echo "<td>" . $row['par'] . "</td>";
echo "<td>" . $row['strokeIndex'] . "</td>";
echo "<td> <input type='text' maxlength='2' id='score$rowIndex' /></td>";
echo "<td> <input type='text' id='points$rowIndex' readonly></td>";
echo "</tr>";
$rowIndex++;
}
You may also use
id='score[$rowIndex]'
Here is code I use to update data of one row of form table. This is the code I wanna change.
The change should allows me update not only one row of the shown table but every line:
if(isset($_POST['update'])){
$UpraveneQuery = "UPDATE uctovnictvo SET meno='$_POST[meno]', datum='$_POST[datum]', obchod='$_POST[obchod]', druh='$_POST[druh]', cena='$_POST[cena]', Poznamka='$_POST[poznamka]' WHERE uct_id='$_POST[hidden]' "; //--------------
mysql_query($UpraveneQuery, $con);
};
here are data with which I work for this particular case:
$sql = "SELECT * FROM uctovnictvo WHERE meno IN ('" . implode('\', \'', $option_meno) . "') AND obchod IN ('" . implode('\', \'', $option_obchod) . "') AND druh IN ('" . implode('\', \'', $option_druh) . "') AND datum BETWEEN '$date_start' AND '$date_end' ORDER BY $order";
$mojeData = mysql_query($sql,$con) or die($sql."<br/><br/> Chyba 1 je:".mysql_error());//run query a ulozit to premennej
here is code which generates form table which allows me to change content of it. Every row of the table has its own button for deleting or updating the row.
NOW
When I clik on ulozit zmenu (update) on certain row it allows me to post values of that one row and update variables of the row (query).
PLAN
I dont want to have button ulozit zmenu (update) next to every row of the table but only one butto which will post values of every shown row of the table.
while($zaznam = mysql_fetch_array($mojeData))
{
echo "<form action=index-5.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=text name='meno[]' value='" . $zaznam['meno'] . "'>" . "</td>";
echo "<td>" . "<input type=date name='datum[]' value='" . $zaznam['datum'] . "'>" . "</td>";
echo "<td>" . "<input type=text name='obchod[]' value='" . $zaznam['obchod'] . "'>" . "</td>";
echo "<td>" . "<input type=text name='druh[]' value='" . $zaznam['druh'] . "'>" . "</td>";
echo "<td>" . "<input step=any type='number[]' name=cena value='" . $zaznam['cena'] . "'>" . "</td>";
echo "<td>" . "<input type=text name='poznamka[]' value='" . $zaznam['poznamka'] . "'>" . "</td>";
echo "<td>" . "<input type=submit name='update[]' value='ulozit zmenu'" . ">" . "</td>";[]
echo "<td>" . "<input type=submit name='zmazat[]' value='zmazat'" . ">" . "</td>";
echo "</tr>";
}
I am trying to update a record in my database which is a blob type, I can insert using this method really easily but when using UPDATE it doesn't seem to work, only for text. Would someone be able to point me in the right direction?
Here is my code:
<?php
$conn=mysqli_connect("localhost","root","root","plantidentify");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$ufamid = mysqli_real_escape_string($conn, $_POST['ufamilyid']);
$ucommonname = mysqli_real_escape_string($conn, $_POST['ucomname']);
$usynname = mysqli_real_escape_string($conn, $_POST['usynonyms']);
$uspecies = mysqli_real_escape_string($conn, $_POST['uspecies']);
$uprop = mysqli_real_escape_string($conn, $_POST['upropagation']);
$uimageData = mysqli_real_escape_string($conn, (file_get_contents($_FILES['uimage']['tmp_name'])));
$uheight = mysqli_real_escape_string($conn, $_POST['uheight']);
$utreeclass = mysqli_real_escape_string($conn, $_POST['utreeclass']);
$ulifecycle = mysqli_real_escape_string($conn, $_POST['ulifecycle']);
$UpdateQuery = "UPDATE plant
SET FamilyID='$ufamid', CommonName='$ucommonname',
SynonymNames='$usynname', Species='$uspecies',
Propagation='$uprop', Image='$uimageData',
Height='$uheight', TreeClass='$utreeclass',
Lifecycle='$ulifecycle'
WHERE PlantID='$_POST[uplantid]'";
if (!mysqli_query($conn,$UpdateQuery)) {
die('Error: ' . mysqli_error($conn));
}
header("Location: plantedit.php");
mysqli_close($conn);
?>
$uimageData is the variable in which contains the uploaded file from my form in another file. The column in my database where I am trying to update the blob is called "Image".
This might help, here is the form code that is in another .php which the update plant.php gets fired from:
<?php //display databse values
while($plant=mysql_fetch_array($retval)) {
echo"<form action=updateplant.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=number name=ufamilyid value='" .$plant['FamilyID']."' ></td>";
echo "<td>" . "<input type=text name=ucomname value='" .$plant['CommonName']."' ></td>";
echo "<td>" . "<input type=text name=usynname value='" .$plant['SynonymNames']."' ></td>";
echo "<td>" . "<input type=text name=uspecies value='" .$plant['Species']."' ></td>";
echo "<td>" . "<input type=text name=uprop value='" .$plant['Propagation']."' ></td>";
echo "<td>" . "<input type=file name=uimage></td>";
echo "<td>" . '<img class="crop2" src="data:image/jpeg;base64,'. base64_encode( $plant['Image'] ).'"/>'." </td>";
echo "<td>" . "<input type=number name=uheight value='" .$plant['Height']."' ></td>";
echo "<td>" . "<input type=text name=utreeclass value='" .$plant['TreeClass']."' ></td>";
echo "<td>" . "<input type=text name=ulifecycle value='" .$plant['Lifecycle']."' ></td>";
echo "<td>" . "<input type=hidden name=uplantid value='" .$plant['PlantID']."' ></td>";
echo "<td>" . "<input type=submit name=update value=Update" . " ></td>";
echo "</tr>";
echo "</form>";
}//end while
mysql_close($conn);
?>
to upload a file you should mention enctype='multipart/form-data' in form . Hope this will fix your problem.
<?php
//display databse values
while($plant=mysql_fetch_array($retval)) {
echo"<form action='updateplant.php' method='post' enctype='multipart/form-data' >";
echo "<tr>";
echo "<td>" . "<input type=number name=ufamilyid value='" .$plant['FamilyID']."' ></td>";
echo "<td>" . "<input type=text name=ucomname value='" .$plant['CommonName']."' ></td>";
echo "<td>" . "<input type=text name=usynname value='" .$plant['SynonymNames']."' ></td>";
echo "<td>" . "<input type=text name=uspecies value='" .$plant['Species']."' ></td>";
echo "<td>" . "<input type=text name=uprop value='" .$plant['Propagation']."' ></td>";
echo "<td>" . "<input type=file name=uimage></td>";
echo "<td>" . '<img class="crop2" src="data:image/jpeg;base64,'. base64_encode( $plant['Image'] ).'"/>'." </td>";
echo "<td>" . "<input type=number name=uheight value='" .$plant['Height']."' ></td>";
echo "<td>" . "<input type=text name=utreeclass value='" .$plant['TreeClass']."' ></td>";
echo "<td>" . "<input type=text name=ulifecycle value='" .$plant['Lifecycle']."' ></td>";
echo "<td>" . "<input type=hidden name=uplantid value='" .$plant['PlantID']."' ></td>";
echo "<td>" . "<input type=submit name=update value=Update" . " ></td>";
echo "</tr>";
echo "</form>";
}//end while
mysql_close($conn);
?>
Looks like you have a typo in the WHERE statement, $_POST[uplantid] should be ". $_POST['uplantid'] ."