I have a account page on my website where it shows all information about a user but it does not show the username.
Database Name: df
Table to get info from: members
Column that stores all the usernames: user
Screenshot:
So I tried this code but it did not work. You may wonder how I came up with that code: I copied the other code that shows when user is registered.
echo '<tr>';
echo '<td align="left" class="padding_td" width="'.$td_width.'">';
echo 'Registrerad:';
echo '</td>';
echo '<td align="left" class="padding_td">';
echo members($user['user']);
echo '</td>';
echo '</tr>';
When I try this code on my site I get this error:
Fatal error: Call to undefined function members() in
C:\xampp\htdocs\account.php on line 328
Here's the code to show when user is registered (may or may not be helpful):
echo '<tr>';
echo '<td align="left" class="padding_td" width="'.$td_width.'">';
echo 'Registrerad:';
echo '</td>';
echo '<td align="left" class="padding_td">';
echo date_detailed($user['date_registred']);
echo '</td>';
echo '</tr>';
Try this:
echo '<tr>';
echo '<td align="left" class="padding_td" width="'.$td_width.'">';
echo 'Registrerad:';
echo '</td>';
echo '<td align="left" class="padding_td">';
echo $user['user'];
echo '</td>';
echo '</tr>';
Related
I want to update the value in a certain row. But it seems impossible since this table (from database) doesn't have the primary key. It only have two foreign key in its column. What should I do ? please, any help ?
here is my code :
<table align= "center" border="1" cellspacing="0" cellpadding="2">
<?php
$strgettable="select tblUsrGrp.UsrGrpNama, tblmenu.MenuNama, tblmenuakses.MenuAkses
FROM tblUsrGrp
inner join tblMenuAkses
on tblUsrGrp.UsrGrpID = tblMenuAkses.usrgrpid
inner join tblMenu
on tblMenu.menuid = tblMenuAkses.menuid";
$varRecCount=0;
$rs=odbc_exec($dbconnVOT, $strgettable);
if($rs)
{
echo '<tr><td style=width:10%;>';
echo '<center><b> No. </b></center>';
echo '</td>';
echo '<td style=width:30%;>';
echo '<center><b> User Group </b></center>';
echo '</td>';
echo '<td style=width:20%;>';
echo '<center><b> Menu Name </b></center>';
echo '</td>';
echo '<td style=width:20%;>';
echo '<center><b> Menu Akses </b></center>';
echo '</td>';
echo '<td style=width:20%;>';
echo '<center><b> Update </b></center>';
echo '</td></tr>';
while (odbc_fetch_row($rs))
{
$varRecCount++;
echo '<tr><td>';
echo '<center> '.$varRecCount.'</center>';
echo '</td>';
echo '<td>';
echo '<center> '.odbc_result($rs,"UsrGrpNama").'</center>';
echo '</td>';
echo '<td>';
echo '<center> '.odbc_result($rs,"MenuNama").'</center>';
echo '</td>';
echo '<td>';
echo '<center> '.odbc_result($rs,"MenuAkses").'</center>';
echo '</td>';
echo '<td>';
echo '</td>';
echo '</td></tr>';
}
}
?>
</table>
<div style="text-align:center;">
<input type="button" name="btnUpdate" id="btnUpdate" onClick="javascript:sendData('updatedata');" value = "Update">
</div>
any help would be much appreciated . TQ
Is it possible to put PHP-code surrounded by HTML which is surrounded by PHP?
Here is a little code-snippet. All of that is in PHP-brackets. The browser displays the table but not the PHP values.
echo "<tr>";
echo '<td class="tg-031e"><?php echo $Auftragsnummer;?></td>';
echo '<td class="tg-031e"><?php echo $Modellbezeichnung;?></td>';
echo '<td class="tg-031e"><?php echo $Untersuchungsart;?></td>';
echo '<td class="tg-031e"><?php echo $TUEV_Stelle;?></td>';
echo '<td class="tg-031e"><?php echo $TUEV_Termin;?></td>';
echo "</tr>";
Regards
Bluefox
Concatenation
echo '<td class="tg-031e">' . $Auftragsnummer . '</td>';
But if you have a lot of HTML it's better to close your php tag
<?php your code ?>
<tr>
<td class="yourClass"> <?php echo $yourVar; ?> </td>
<tr>
Look at Concatenation.
You can put a string in an echo command like so:
$string = 'hello world';
echo 'I wanted to say '.$string.'!'; //outputs "I wanted to say hello world!"
so your code should look like:
echo '<tr>';
echo '<td class="tg-031e">'.$Auftragsnummer.'</td>';
echo '<td class="tg-031e">'.$Modellbezeichnung.'</td>';
echo '<td class="tg-031e">'.$Untersuchungsart.'</td>';
echo '<td class="tg-031e">'.$TUEV_Stelle.'</td>';
echo '<td class="tg-031e">'.$TUEV_Termin'.</td>';
echo '</tr>';
you do not need to close the php bracket
do more like this
echo '<td class="tg-031e">' .$Auftragsnummer. '</td>';
You can go for HEREDOC :
$html = <<<HTML
<tr>
<td class="tg-031e">{$Auftragsnummer}</td>
<td class="tg-031e">{$Modellbezeichnung}</td>
<td class="tg-031e">{$Untersuchungsart}</td>
<td class="tg-031e">{$TUEV_Stelle}</td>
<td class="tg-031e">{$TUEV_Termin}</td>
</tr>
HTML
;
echo $html;
echo is PHP. So you should just do something like this :
echo '<td class="tg-031e">'.$Auftragsnummer.'</td>';
Using sprintf().
<?php
echo sprintf('<td class="tg-031e">%s</td>', $Auftragsnummer);
Or, as a loop/array construct:
foreach(array(
$Auftragsnummer,
$Modellbezeichnung,
$Untersuchungsart,
$TUEV_Stelle,
$TUEV_Termin) as $item) {
echo sprintf('<td class="tg-031e">%s</td>', $item);
}
I have this code which prints a table taken from a search query and I want to enumerate them using PHP. I'm trying a for loop but unsuccessfully. Can anyone please help me?
<table id="students">
<?php
$iterator = new CDataProviderIterator($dataProvider);
//echo count($iterator);
echo '<thead>';
echo '<tr>';
echo '<th>'.Yii::t('default', 'Last Name').'</th>';
echo '<th>'.Yii::t('default', 'First Name').'</th>';
echo '<th>'.Yii::t('default', 'Description').'</th>';
echo '<th>'.Yii::t('default', 'Debit').'</th>';
echo '<th>'.Yii::t('default', 'Credit').'</th>';
echo '<th>'.Yii::t('default', 'Date').'</th>';
echo '<th>'.Yii::t('default', 'Trans number').'</th>';
echo '</tr>' ;
echo '</thead>';
echo '<tfoot>';
echo '<tr>';
echo '<td>'.Yii::t('default', 'Page Total').'</td>';
echo '<td>'."".'</td>';
echo '<td>'."".'</td>';
echo '<td>'."".'</td>';
echo '<td>'."".'</td>';
echo '<td>'."".'</td>';
echo '<td>'."".'</td>';
echo '</tr>';
echo '</tfoot>';
$sumdebit=0;
$sumcredit=0;
foreach($iterator as $rec) {
$sumdebit+=$rec['debit'];
$sumcredit+=$rec['credit'];
echo '<tbody>';
echo '<tr>';
$count=0;
for ($i=0;$i<=40;$i++){
$count+=$i;
echo '<td>'.$count; '</td>';
echo '<td>'.$rec['student']['lastname']; '</td>';
echo '<td>'.$rec['student']['firstname'];'</td>';
echo '<td>'.$rec['transtype']['description']; '</td>';
echo '<td align="right">'.$rec['debit']; '</td>';
echo '<td align="right">'.$rec['credit']; '</td>';
echo '<td>'.$rec['transdate']; '</td>';
echo '<td>'.$rec['transnumber']; '</td>';
}
echo '</tr>';
echo '</tbody>';
}
echo '<tr>';
echo '<td>'.Yii::t('default', 'Total').'</td>';
echo '<td>'."".'</td>';
echo '<td>'."".'</td>';
echo '<td align="right">'.$sumdebit;'</td>';
echo '<td align="right">'.$sumcredit;'</td>';
echo '<td>'."".'</td>';
echo '<td>'."".'</td>';
echo '</tr>';
?>
</table>
My problem is that I want to enumerate the table rows, also I'm not very familiar with the syntax and all of this. I'm trying to make it work in Yii. which I'm not very familiar also. So the problem is I want to put numbers in front of every row. For example I have 20 table rows and I want to start counting and enumerate them. e.g. 1. George Cat 2. Tom Dog 3. John Bird etc..
Your question is unclear, you do not state what your actual problem is.
Therefore we can only guess...
[...]
echo '<tbody>';
echo '<tr>';
for ($i=0;$i<=40;$i++) {
echo '<td>'.$i.'</td>';
[...]
You probably received a syntax error which you apparently either didn't see (look into the error log files!) or simply ignored. At least you did not post it here though it probably exactly points out what the issue is...
I want to retrieve XML data from soundcloud using a simple search engine, that retrieves results in a simple results table array
$tracks = "https://api.soundcloud.com/tracks?q=".$var."&client_id=bbba84be29098bdaad6a5de1c048e3e9&limit=10";
$mysongs = simplexml_load_file($tracks);
echo "<table>";
echo '<table cellpadding="0" cellspacing="0">';
echo '<tbody>';
echo '<tr>';
echo '<th>State</th> <th>Name</th><th>Song</th><th>artist</th><th>user</th> <th>user</th>';
echo '</tr>';
echo '</tbody>';
foreach ($mysongs->track->user as $track) {
echo '<tbody>';
echo '<tr>';
echo '<td>';
echo $user->kind;
echo '</td>';
echo " ";
echo '<td>';
echo $user->kind;
echo " ";
echo '</td>';
echo '<td>';
echo $user->kind;
echo " ";
echo '</td>';
echo '<td>';
echo $user->kind;
echo " ";
echo '</td>';
echo '<td>';
echo $user->kind;
echo '</td>';
echo '<td>';
echo $user->kind;
echo '</td>';
echo '</tr>';
echo '</tbody>';
}
this is my code but nothing seems to display as a result, i have tested the same format of code on another api (yelp) and it does work in xml, so what am i missing here? i dont want to use json, i need it to be xml ( the user -> kind ) is just for testing the code right now.
the variable $user doesn't exist. the variable you want is $track. so where you have
echo $user->kind
replace that with
echo $track->kind
you can see the format of the returned object (and it's hierarchy by running the code in the cli and
print_r($mysongs)
I have this block of PHP and HTML:
<table width="57%" border="0" class="tabela_master" id="aps-cat">
<tr>
<?php
while ($row = $db->sql_fetchrow($result_1))
{
echo '<td width="33%" rowspan="12" align="center"><img src="../images/' . $row['picture'] . '" /></td>';
echo '<td width="20%" align="right" class="tabela_master" style="font-weight: bold">Emri / Mbiemri:</td>';
echo '<td width="1%"> </td>';
echo '<td width="46%" class="tabela_master">' . $row['firstname'] . " " . $row['lastname'] . '</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" class="tabela_master" style="font-weight: bold">Gjinia:</td>';
echo '<td> </td>';
echo '<td class="tabela_master">' . $row['gender'] . '</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" class="tabela_master" style="font-weight: bold">Datelindja:</td>';
echo '<td> </td>';
echo '<td class="tabela_master">' . $row['birthday'] . '</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" class="tabela_master" style="font-weight: bold">Adresa / Lokacioni:</td>';
echo '<td> </td>';
echo '<td class="tabela_master">' . $row['location'] . '</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" class="tabela_master" style="font-weight: bold">Telefoni:</td>';
echo '<td> </td>';
echo '<td class="tabela_master">' . $row['telephone'] . '</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" class="tabela_master" style="font-weight: bold">Email adresa:</td>';
echo '<td> </td>';
echo '<td class="tabela_master">' . $row['email'] . '</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" class="tabela_master" style="font-weight: bold">Interesi:</td>';
echo '<td> </td>';
echo '<td class="tabela_master">' . $row['occupation'] . '</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" class="tabela_master" style="font-weight: bold"> </td>';
echo '<td> </td>';
echo '<td class="tabela_master"> </td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" class="tabela_master" style="font-weight: bold"> </td>';
echo '<td> </td>';
echo '<td class="tabela_master"> </td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" class="tabela_master" style="font-weight: bold"> </td>';
echo '<td> </td>';
echo '<td class="tabela_master"> </td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" class="tabela_master" style="font-weight: bold"> </td>';
echo '<td> </td>';
echo '<td class="tabela_master"> </td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" class="tabela_master" style="font-weight: bold"> </td>';
echo '<td> </td>';
echo '<td class="tabela_master"> </td>';
}
//$db->sql_freeresult($result_1);
?>
</tr>
</table>
Now what I want is multiple records shown in the page. The web currently looks like this:
And what I want would look like this:
So my table would provide all my results from my MySQL query which looks like this:
$sql_1 = 'SELECT id, firstname, lastname, birthday, location, occupation, gender, telephone, email, picture
FROM pinkmoon_users ORDER BY `id` DESC LIMIT 1';
$result_1 = $db->sql_query($sql_1) or die($db->sql_error());
Remove the LIMIT 1 in your SQL statement
$sql_1 = 'SELECT id, firstname, lastname, birthday, location, occupation, gender, telephone, email, picture
FROM pinkmoon_users ORDER BY `id` DESC ';
$result_1 = $db->sql_query($sql_1) or die($db->sql_error());
Your query retrieves only the last record from the database. If you want more, you should change the LIMIT 1 to (for example) LIMIT 10 or remove the limit contraint entirely.