How to save two textboxes values into one table coulmn in php - php

I need to save firstName and lastName for the fullName. I wrote some code. But, This is not working properly. Please, can anyone help me?
$student['FULL_NAME'] = $student['FIRST_NAME'] . ' ' . $student['MIDDLE_NAME'];
echo '<tr><td>Full Name</td><td>:</td><td>' . TextInput( $student['FULL_NAME'] , 'students[FULL_NAME]', '', 'size=150 class=cell_medium') . '</td></tr>';

Related

PHP ECHO table with dynamic dropdown as one column using FOR EACH

I am a bit stuck I am attempting to build out a table with HTML and PHP. Ok got that done. Now I want to add a dynamic dropdown as one of the column options but cant seem to figure out how to mix the PHP, the HTML and the needed FOR EACH loop.
I know its currently wrong but am posting a variable of what I have been trying below.
echo '<td>' . "<select>". "<option value =" . $sf_name . ' '. $sl_name . ">" . $sf_name . ' '. $sl_name . "</option>" .
foreach($Staff_On_Duty as $person){
"<option value =" . $sf_name_option=$person->Staff_First_Name . ' '. $sl_name_option=$person->Staff_Last_Name . ">" . $sf_name_option . ' '. $sl_name_option . "</option>"
}
. "</select>" .'</td>';
I need to have the currently selected individual at the top of the dropdown with the option to change that person out. the first .sf_name comes from higher in the code and gives me the name of the individual currently selected. The foreach runs from the $Staff_On_Duty query to give me everyone working right now. What is the right way to do this?
This is how I would do it, essentially only fill the dropdown and mark the option that should have been selected (other stuff is a matter of preference):
echo("<td><select>");
foreach($Staff_On_Duty as $person){
$sf_name_option=$person->Staff_First_Name; // separated for clarity, you could also use $person->Staff_First_Name everywhere
$sl_name_option=$person->Staff_Last_Name;
echo("<option value = $sf_name_option $sl_name_option");
if (($sf_name_option == $sf_name) && ($sl_name_option == $sl_name)) echo (" selected"); // this is the relevant part, but make sure variable values match!
echo(">$sf_name_option $sl_name_option</option>");
}
echo("</select></td>");
Note that I did not put any quotation marks cause I have no idea what your variables entail, but it would need them if you don't have them in yet, i.e.:
... value=\"$sf_name_option $sl_name_option\" ...

Trying to load/execute two table values at the same time

I'm trying to create a page that displays content from database when specific title is selected, and all the comments added to it (only comments for the selected title should be visible) by other users. I want make the id and review_id to work together on the same line. I cant create two separate echo's as it creates two separate titles.
I've tried to link the values together but cant make it work.
echo '<li>' . $comment['name'] . ' - ' . $comment['date'] . '</li>';
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
echo '<li>' . $comment['name'] . ' - ' . $comment['date'] . '</li>';
Is there a way to make "id" and "review_id" work at the same line ?

How to format mass data pulled from a database?

I am using a PHP script to pull large amounts of entries from a database, it looks like this:
foreach($events as $e){ //sets each set of data as a value of $e
$vidID = $e["Test Video YouTube ID"]; //stores each video ID as this variable, so that it can be called when embedding the video
echo "<br>" . '<iframe width="250" height="140" src="http://www.youtube.com/embed/' . $vidID . '?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>' . "<br>"
. '<strong> DOC: </strong>' . $e["Axial Cut"] . " " . '<strong> IPM: </strong>' . $e["Inches Per Minute"] . "<br>" .
'<strong> WOC: </strong>' . $e["Radial Cut"] . " " . '<strong> FPT: </strong>' . $e["Inch per Tooth"] . "<br>" .
'<strong> SFM: </strong>' . round($e["Surface Feet per Minute"]) . "<br>"; //each value here is displayed. use the form '$e["Column to be dislplayed"].'
This displays each field for the entry I need, then goes to the next entry and does the same, displaying every entry in the database.
My issue is that it only displays them in a vertical line, so what is the best way to format the output in such a way that it displays in a grid, with a set amount of columns?
*EDIT - To clarify, I don't want to use something like a CSS table for this. It limits me in that the data cannot automatically fill into columns, instead each entry would either appear in a single column or I would have to update each field every time the database had a new entry which would be quite tedious. So what is the best way to have data automatically flow into these columns and rows?

QRcode after scan redirect to custom link

I'm working with QRcode at the moment so far it's so good i can scan it and get a result back from the database.
Im getting the data as follow :
$qrcode = QRcode::png('
number:' . $number. '
Name: ' . $name. '
Lastdate : ' . $lastdate . '
check: ' . $check. '');
My question is how can i scan the QRcode and redirect it to an custom link and display it on the website
Thanks,
Kevin
Recently i have made one application like your requirement only. what you need to do is, what ever data displaying through QR code that data insert into database then you will get one record id and using that record id you can make custom URL with creating new php page.
your code:
$qrcode = QRcode::png('
number:' . $number. '
Name: ' . $name. '
Lastdate : ' . $lastdate . '
check: ' . $check. '');
my suggested code:
array('number' => $number,
'Name '=>$name,
'Lastdate '=> $lastdate,
'check '=> $check);
Insert this array into your database
grab inserted recored id.
$custome_URL = "www.yourwebsitename.com/qrcode_scanneddata.php?id=$record_id";
$qrcode = QRcode::png("$custome_URL");
when ever you scan the URL automatically it will open in web browser.
You can redirect by code like this
header('Location: '.$qrcode->url);

Most efficient way to get last initial?

I'm working on a custom forum. It will use an email and password to log in, and the forum will display your first name and last initial. The database stores their first name and full last name.
What would be the easiest way to make it abbreviate the last name to an initial?
It currently uses this to display full name:
$name = $row['user_firstname'] . " " . $row['user_lastname'];
Thanks!
$name = $row['user_firstname'] . " " . $row['user_lastname'][0];
Just add [0] to the end to get the first character.
And to make it prettier:
$name = ucfirst(strtolower($row['user_firstname'] )). " " . ucfirst($row['user_lastname'][0]);
so MYFIRSTNAMe lastName still shows as MyfirstnameL

Categories