How to create an html link to another page from "<?=$objResult["id"];?>" - php

I'm working on a php/mysql application and need to make the output of one column, one row an html link to another html page. Have not been able to find any relavant information. The "" needs to be the link. Thanks for any help.
<table id="display" style="width:800px;">
<tr>
<th width="40">ID</th>
<th width="70">Last</th>
<th width="70">First</th>
<th width="10">Middle</th>
<th width="70">Birth</th>
<th width="70">Death</th>
<th width="170">Notes</th>
<th width="100">Cemetery</th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td style='text-align:center;'><?=$objResult["id"];?></td>
<td style='text-align:center;'><?=$objResult["last"];?></td>
<td style='text-align:center;'><?=$objResult["first"];?></td>
<td style='text-align:center;'><?=$objResult["middle"];?></td>
<td style='text-align:center;'><?=$objResult["birth"];?></td>
<td style='text-align:center;'><?=$objResult["death"];?></td>
<td><?=$objResult["notes"];?></td>
<td style='text-align:center;'><?=$objResult["cemetery"];?></td>
</tr>
<?
}
?>
</table>

Related

Display Values of a row after delete

I have a delete button in my site that deletes a row in a table.
After the row is deleted, the user is redirect to another page.
Is it possible to display the deleted row values in the redirected page?
thank you!
<table class="table table-striped b-t b-light">
<thead>
<tr>
<th style="text-align: center">User Name</th>
<th style="text-align: center">User Last Name</th>
<th style="text-align: center">Email</th>
<th style="text-align: center">Password</th>
<th style="text-align: center">User Type</th>
<th style="text-align: center">Edit</th>
<th style="text-align: center">Delete</th>
</tr>
</thead>
<?php foreach ($ulistq as $urule) : ?>
<tbody>
<th style="text-align: center"><?= $urule['u_name'] ?></th>
<th style="text-align: center"><?= $urule['u_lastname'] ?></th>
<th style="text-align: center"><?= $urule['u_email'] ?></th>
<th style="text-align: center"><?= $urule['u_password'] ?></th>
<th style="text-align: center"><?= $urule['u_rule'] ?></th>
<td style="text-align: center"> Edit </td>
<td style="text-align: center"> Delete </td>
</tbody>
<?php endforeach; ?>
</table>
You can consider the option of adding the values to the redirect URL and extract them in the redirected page.
So instead of this redirect:
redirect to www.example.com/afterdelete
You can do
redirect to www.example.com/afterdelete?value1=1&value2=2
This option can be done both in the server side, as well as the client side.
You will need your afterDelete page to extract these values and to display them

Why datagrid_data1.json data can not appear

In my project, i use easyui-datagrid.
Here is my html code:
<tr>
<td style="width:10%" colspan="2">attachment</td>
<td style="width:90%" colspan="18">
<table class="easyui-datagrid" data-options="url:'datagrid_data1.json',method:'get'" title="" style="width:100%">
<thead>
<tr>
<th data-options="field:'ck',checkbox:true"></th>
<th data-options="field:'name',align:'center'">filename</th>
</tr>
</thead>
</table>
</td>
</tr>
The code of datagrid_data1.json:
{"total":2,"rows":[
{"name":"1.jpg"},
{"name":"123.jpg"}
]}
But unfortunately, I works fail. Two names of 1.jpg and 123.jpg can not appear. Who can help me?

How to find and update the contents of a table?

I am currently helping out a friend with his website, I am doing so through a SVN, I have been updating information for him, however I have encountered a list of dates where I cannot find the source information for so I cannot update it.
Below is the code which I believe is pointing to the code I want to update $item.ClassHours how do I find where the source information is?
<table class="stripe-table" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<th>Class Choice</th>
<th class="clear-bg">Schedule</th>
<th>Class Hours</th>
<th class="clear-bg">Level</th>
</tr>
<volist name="article.content_complex.part_time" id="item">
<notempty name="item.Schedule">
<tr>
<notempty name="item.ClassChoice">
<th <notempty name="item.ClassChoice_rowspan">rowspan="{$item.ClassChoice_rowspan}"</notempty> >{$item.ClassChoice}</th>
</notempty>
<td>{$item.Schedule}</td>
<notempty name="item.ClassHours">
<th <notempty name="item.ClassHours_rowspan">rowspan="{$item.ClassHours_rowspan}"</notempty> >{$item.ClassHours}</th>
</notempty>
<notempty name="item.Level">
<td <notempty name="item.Level_rowspan">rowspan="{$item.Level_rowspan}"</notempty> >{$item.Level}</td>
</notempty>
</tr>
</notempty>
</volist>
</tbody>
</table>

Running to Selects and grouping results with PHP

I am trying to display a row of data from my main table (parents details) and then under each of those rows display the children's names from another table. I have had a go using the following code:
$sql="select distinct members_main.first_name as main_firstname,
members_main.first_name as main_firstname,
members_main.last_name as main_lastname,
members_main.address_1 as main_address_1,
members_main.address_2 as main_address_2,
members_main.address_3 as main_address_3,
members_main.address_4 as main_address_4,
members_main.post_code as main_post_code,
members_main.home_tel as main_home_tel,
members_main.mobile as main_mobile,
members_main.home_email as main_home_email
from members_main, members_family where members_main.contact_id=members_family.contact_id";
$sql2="select members_family.first_name as fam_firstname,
members_family.last_name as fam_lastname
from members_family, members_main
where members_main.contact_id=members_family.contact_id";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
echo '<table width="100%" cellpadding="3" cellspacing="0">
<tr>
<th align="left" valign="top">First Name</th>
<th align="left" valign="top">Last Name</th>
<th align="left" valign="top">Address 1</th>
<th align="left" valign="top">Address 2</th>
<th align="left" valign="top">Address 3</th>
<th align="left" valign="top">Address 4</th>
<th align="left" valign="top">Post Code</th>
<th align="left" valign="top">Home Tel</th>
<th align="left" valign="top">Mobile</th>
<th align="left" valign="top">Email</th>
</tr>';
echo '<tr>
<td valign="top">'.$rows['main_firstname'].'</td>
<td valign="top">'.$rows['main_lastname'].'</td>
<td valign="top">'.$rows['main_address_1'].'</td>
<td valign="top">'.$rows['main_address_2'].'</td>
<td valign="top">'.$rows['main_address_3'].'</td>
<td valign="top">'.$rows['main_address_4'].'</td>
<td valign="top">'.$rows['main_post_code'].'</td>
<td valign="top">'.$rows['main_home_tel'].'</td>
<td valign="top">'.$rows['main_mobile'].'</td>
<td valign="top">'.$rows['main_home_email'].'</td>
</tr>';
$result2=mysql_query($sql2);
echo '<table width="100%" cellpadding="3" cellspacing="0">
<tr>
<th align="left" valign="top">First Name</th>
<th align="left" valign="top">Last Name</th>
</tr>';
while($rows=mysql_fetch_array($result2)){
echo '<tr>
<td valign="top">'.$rows['fam_firstname'].'</td>
<td valign="top">'.$rows['fam_lastname'].'</td>
</tr>';
}
}
echo "</table>";
I am getting all rows from the members_family table per each record from the members_main. There can be more than one record in the members_family which will be associated to one record in the members_main. Bascially, members_main (parent) can have multiple children in the members_main.
I think you just need to retrieve your members_main.contact_id from first table to use later in second while loop. Then you will have to move your second query inside first query while loop so the code will look like that:
$sql="select distinct
members_main.contact_id as ID,
members_main.first_name as main_firstname,
members_main.first_name as main_firstname,
members_main.last_name as main_lastname,
members_main.address_1 as main_address_1,
members_main.address_2 as main_address_2,
members_main.address_3 as main_address_3,
members_main.address_4 as main_address_4,
members_main.post_code as main_post_code,
members_main.home_tel as main_home_tel,
members_main.mobile as main_mobile,
members_main.home_email as main_home_email
from members_main, members_family where members_main.contact_id=members_family.contact_id";
$result = mysql_query($sql);
while($rows=mysql_fetch_array($result)) {
//script goes on with table printing untill
<td valign="top">'.$rows['main_home_email'].'</td>
</tr>';
Now it's time for the query
$sql2="select members_family.first_name as fam_firstname,
members_family.last_name as fam_lastname
from members_family, members_main
where members_main.contact_id=members_family.contact_id and members_main.contact_id = '".$rows['ID']."'";
As you see i added in WHERE condition to limit result for specified ID wich i retrieved from first query. Now you can print the rest of the table. Oh and by the way you closing table should look like that
echo "</table></td></tr></table>";
This is because you opened two tables.
Then I would like you to remember that mysql_* functions are deprecated so i would advise you to switch to mysqli or PDO
I feel some confusion with your second query. I am thinking that you have to construct your second query with the contact_id which is coming from first query(members_main). I assumes in that way and i have coded below. May be it will help you
<?php
$sql = "select distinct members_main.first_name as main_firstname,
members_main.first_name as main_firstname,
members_main.last_name as main_lastname,
members_main.address_1 as main_address_1,
members_main.address_2 as main_address_2,
members_main.address_3 as main_address_3,
members_main.address_4 as main_address_4,
members_main.post_code as main_post_code,
members_main.home_tel as main_home_tel,
members_main.mobile as main_mobile,
members_main.home_email as main_home_email
from members_main, members_family where members_main.contact_id=members_family.contact_id";
$result = mysql_query($sql);
?>
<table width="100%" cellpadding="3" cellspacing="0">
<tr>
<th align="left" valign="top">First Name</th>
<th align="left" valign="top">Last Name</th>
<th align="left" valign="top">Address 1</th>
<th align="left" valign="top">Address 2</th>
<th align="left" valign="top">Address 3</th>
<th align="left" valign="top">Address 4</th>
<th align="left" valign="top">Post Code</th>
<th align="left" valign="top">Home Tel</th>
<th align="left" valign="top">Mobile</th>
<th align="left" valign="top">Email</th>
</tr>
<?php
while ($rows = mysql_fetch_array($result))
{
$conId = $rows['contact_id']; //Which is comming from first Query
$sql2 = "select members_family.first_name as fam_firstname,
members_family.last_name as fam_lastname
from members_family, members_main
where members_family.contact_id=$conId";
$result2 = mysql_query($sql2);
?>
<tr>
<td valign="top"><?= $rows['main_firstname']; ?></td>
<td valign="top"><?= $rows['main_lastname']; ?></td>
<td valign="top"><?= $rows['main_address_1']; ?></td>
<td valign="top"><?= $rows['main_address_2']; ?></td>
<td valign="top"><?= $rows['main_address_3']; ?></td>
<td valign="top"><?= $rows['main_address_4']; ?></td>
<td valign="top"><?= $rows['main_post_code']; ?></td>
<td valign="top"><?= $rows['main_home_tel']; ?></td>
<td valign="top"><?= $rows['main_mobile']; ?></td>
<td valign="top"><?= $rows['main_home_email']; ?></td>
</tr>
<tr>
<td colspan="10">
<table width="100%" cellpadding="3" cellspacing="0">
<tr>
<th align="left" valign="top">First Name</th>
<th align="left" valign="top">Last Name</th>
</tr>
<?php
while ($rowsFamily = mysql_fetch_array($result2))
{
?>
<tr>
<td valign="top"><?= $rowsFamily['fam_firstname']; ?></td>
<td valign="top"><?= $rowsFamily['fam_lastname']; ?></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<?php
}
?>
</table>

Data in table not displaying the way I want it to

I have a spinner and what happens is that whatever number is in the spinner, when the form is submitted, it should display the word "quest" as many times as the number in the spinner.. E.g if number in spinner is 3, then it will display "quest" 3 times in the table.
The problem is displaying it in the table.
At the moment with my current code it is displaying it like this:
quest
quest
quest
Question Id, Option Type, Duration .... These are table headings
It is displaying the words quest outside the table
Instead I want the word "quest" to be displayed in the Question Id column like this:
Question Id, Option Type, Duration...
quest
quest
quest
How can I get it to display it like the example above?
Below is code
<table border=1 id="qandatbl" align="center">
<tr>
<th class="col1">Question No</th>
<th class="col2">Option Type</th>
<th class="col1">Duration</th>
<th class="col2">Weight(%)</th>
<th class="col1">Answer</th>
<th class="col2">Video</th>
<th class="col1">Audio</th>
<th class="col2">Image</th>
</tr>
<?php
$spinnerCount = $_POST['txtQuestion'];
if($spinnerCount > 0) {
for($i = 1; $i <= $spinnerCount; $i++) {
echo "<tr>quest";
}
}
?>
<td class='qid'></td>
<td class="options"></td>
<td class="duration"></td>
<td class="weight"></td>
<td class="answer"></td>
<td class="video"></td>
<td class="audio"></td>
<td class="image"></td>
</tr>
</table>
I did try echo "<td class='qid'></td>"; but this completely failed as well
Try this:
<table border=1 id="qandatbl" align="center">
<tr>
<th class="col1">Question No</th>
<th class="col2">Option Type</th>
<th class="col1">Duration</th>
<th class="col2">Weight(%)</th>
<th class="col1">Answer</th>
<th class="col2">Video</th>
<th class="col1">Audio</th>
<th class="col2">Image</th>
</tr>
<?php
$spinnerCount = $_POST['txtQuestion'];
if($spinnerCount > 0) {
for($i = 1; $i <= $spinnerCount; $i++) {
?>
<tr>
<td class='qid'><?php echo $quest; ?></td>
<td class="options"></td>
<td class="duration"></td>
<td class="weight"></td>
<td class="answer"></td>
<td class="video"></td>
<td class="audio"></td>
<td class="image"></td>
</tr>
<?php
} // For
} // If
?>
</table>
Is this what you want to do? Display "quest" in the first column?
<table border=1 id="qandatbl" align="center">
<tr>
<th class="col1">Question No</th>
<th class="col2">Option Type</th>
<th class="col1">Duration</th>
<th class="col2">Weight(%)</th>
<th class="col1">Answer</th>
<th class="col2">Video</th>
<th class="col1">Audio</th>
<th class="col2">Image</th>
</tr>
<?php
$spinnerCount = $_POST['txtQuestion'];
if($spinnerCount > 0) {
for($i = 1; $i <= $spinnerCount; $i++) { ?>
<tr>
<td class='qid'>quest</td>
<td class="options"></td>
<td class="duration"></td>
<td class="weight"></td>
<td class="answer"></td>
<td class="video"></td>
<td class="audio"></td>
<td class="image"></td>
</tr>
<?php
}
}
?></table>
?>

Categories