help for php code and mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
morris2000
Forum Newbie
Posts: 1
Joined: Mon Nov 03, 2008 7:32 am

help for php code and mysql

Post by morris2000 »

HI,
i have a pahe in php that take info from a DB Mysql and shows the content by echo command.
The problem is that in my db I have an exception. Some fields contains messages (text) that are splitted when the text is more than 120 charaters.
I'd like to concatenate this messages by the progressive number in the column near (see the jpg).
How can i do?

Code: Select all

<html>
<head>
<style type="text/css">
<meta name="description" content=gateway." />
<meta name="keywords" content="opensource gateway software" />
 
 
body {background-color: #CCCCFF}
h1 {background-color: #FF8000}
h1 {color: #000066}
body
{
background-image:
url('logo.gif');
background-repeat:
no-repeat;
background-position:
right;
}
</style>
</head>
<body>
<h1>PROVA</h1>
 
 
 
<a href="#" onclick="window.open('index.html', '', 'width=500,height=400,toolbar=0,statusbar=0,location=0');">Invia Nuovo Messaggio</a>
 
<form ACTION=ricerca.php method="POST">
Ricerca testo: <input type="text" name="term" id="term" />
<input type="submit" name="search" id="search" SUBMIT value="Search" /> <br/><br/>
</form>
 
 
 
 
 
<FORM ACTION=filtro.php method="post2">
Filtra per data di Oggi:
<td width=10% align=center bgcolor=#E4E4E4><INPUT TYPE=SUBMIT VALUE="APPLICA"><br/><br/>
</FORM>
 
 
<?//script
//error_reporting(E_ALL);
 
 
echo "<br>";
echo "<b>Data di oggi:</b> "; $oggi = print date('d-m-Y');
// ORIGNALE CHE NON FUNZIONAVA
function mysql_timestamp_to_human($dt)
{
$yr=strval(substr($dt,0,4)); //year
$mo=strval(substr($dt,4,2)); //month
$da=strval(substr($dt,6,2)); //day
$hr=strval(substr($dt,8,2)); //hour
$mi=strval(substr($dt,10,2)); //minute
//$se=strval(substr($dt,12,2)); //sec
 
return date("d M Y H:i", mktime ($hr,$mi,0,$mo,$da,$yr)).""; //format of displayed date and time
}
 
 
 
 
mysql_connect("localhost", "root", "********") or die(mysql_error()); //connect to mysql
mysql_select_db("nomedb") or die(mysql_error()); //select database
if ($Char!="") //check if char was inserted
$If = "WHERE TextDecoded LIKE '".AddSlashes($Char)."%'"; //if yes, change variable
else
$If = ""; //or do nothing
 
 
 
$result = mysql_query("SELECT * FROM inbox $If ORDER BY ReceivingDateTime desc"); //select data with variable and order it by time and date of the reception
 
while($row = mysql_fetch_array( $result )) { //create variable row
// Print out the contents of each row into a table
 
echo "<table border=1 bordercolor=#000046 cellpadding=5 cellspacing=0 style=border-collapse: collapse; font-family: Verdana width=96%>";
echo "<tr width=5% valign=middle bgcolor=#E4E4E4>";
 
 
echo "</tr>";
echo "<tr>";
echo "<td width=0% align=center bgcolor=#E4E4E4><font size=1 face=Verdana, Arial, Helvetica, sans-serif color=#000046>Data Ricezione </font>";
echo "</td>";
echo "<td width=3% align=center bgcolor=#E4E4E4><font size=1 face=Verdana, Arial, Helvetica, sans-serif color=#000046>Id</font>";
echo "</td>";
echo "<td width=10% align=center bgcolor=#E4E4E4><font size=1 face=Verdana, Arial, Helvetica, sans-serif color=#000046>Numero</font>";
echo "</td>";
 
echo "<td width=65% align=left bgcolor=#E4E4E4><font size=2 face=Verdana, Arial, Helvetica, sans-serif color=#000046><b>Testo </b> </font>";
echo "</td>";
 
echo "<td width=5% align=center bgcolor=#E4E4E4><font size=1 face=Verdana, Arial, Helvetica, sans-serif color=#000046>Parte </font>";
echo "</td>";
 
echo "<td width=10% align=center bgcolor=#E4E4E4><font size=1 face=Verdana, Arial, Helvetica, sans-serif color=#000046>ELIMINA </font>";
echo "</td>";
 
echo "<td width=5% align=center bgcolor=#E4E4E4><font size=1 face=Verdana, Arial, Helvetica, sans-serif color=#000046>Check </font>";
echo "</td>";
echo "</tr>";
 
echo "<form action=valuta.php method=post>";
 
 
echo "<tr onMouseOver=this.style.backgroundColor='39C' onMouseOut=this.style.backgroundColor=''><td width=15% align=center ><font size=1 face=Verdana, Arial, Helvetica, sans-serif color=#000046>$row[1]</font></td>";
$d= $row['ReceivingDateTime']; //create variable for function at begin
 
echo "</td><br><td>";// end and begin of cell
echo $row['ID'];
echo "</td><td>";
echo $row['SenderNumber'] ; //show number
echo "</td><td>"; //end and begin of cell
echo $row['TextDecoded']; //show text of the message
echo "</td><td>";
if (strlen($row['UDH'])>0) {
print "<b> P. </b>";
echo substr($row['UDH'],strlen($row['UDH'])-2,strlen($row['UDH']));
}
 
echo "<td width=10% align=center><font size=1 face=Verdana, Arial, Helvetica, sans-serif color=#000046><input id=bottone type=submit name=item value=elimina onclick=conferma()></font></td>";
 
 
echo"<td width=5% align=center> <font size=1 face=Verdana, Arial, Helvetica, sans-serif color=#000046> <input type=\"checkbox\" name=\"item[]\" value=\"$row[ID]\"></td>";
 
echo "</table>"; //end of table
 
..............................
 
?>
Attachments
image.JPG
image.JPG (79.77 KiB) Viewed 129 times
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Re: help for php code and mysql

Post by infolock »

What do the fields mean in the JPG? Which fields do you want to concat? What is your overall goal (what would you like it to look like)?
Post Reply