maliary
-
Posts
223 -
Joined
-
Last visited
Never
Posts posted by maliary
-
-
Thanks,
Sorry i didn't update that code. I've changed it but the display is still the same.
Here is the updated code
<?php echo "<table width=250 align=center cellspacing=0 cellpadding=0>\n"; // Set initial group values $lastgroup = ''; // Query database $sql = "SELECT $dbtable.serial_value,$dbtable.type,$dbtable.test_time,$dbtable.group_id,$table.name,$table.nr,$table.normals,$table.msr_unit FROM $dbtable INNER JOIN $table ON ($table.group_id = $dbtable.group_id) WHERE $dbtable.job_id = '$batch_nr' ORDER BY group_id ASC"; $res = mysql_query($sql) or die(mysql_error()); while ($rows = mysql_fetch_assoc($res)){ // Print Group header if ($rows['group_id'] != $lastgroup) { // Print Group Name echo "<tr> <td colspan=2 align=left><strong>Group: ".$rows['name']."</strong></td> </tr>\n"; } // Print Database Details echo "<tr> <td width=50> </td> <td width=200 align=center>".$rows['parameters']."</td> </tr>\n"; // Reset group values $lastgroup = $rows['group_id]; } echo "</table>\n"; ?>
Should I give you a dump of the two tables?
-
The code below works fantastic with that simple SQL query, I've made some changes to the query to thus :-
$depts = $db->Execute("SELECT $dbtable.serial_value,$dbtable.type,$dbtable.test_time,$dbtable.group_id,$table.name,$table.nr,$table.normals,$table.msr_unit FROM $dbtable
INNER JOIN
$table ON ($table.group_id = $dbtable.group_id) WHERE $dbtable.job_id = '$batch_nr' ORDER BY group_id ASC");
It now gives diffrent out put as
Group: C
Piccadilly
Piccadilly
Group: C
Group: E
Group: C
Group: E
Group: C
Group: E
Group: C
Group: E
Ashton
Oldham
Instead of :
Group: C
Piccadilly
Piccadilly
Group: E
Ashton
Oldham
What do I have to change here to make it work like it should?
<?php echo "<table width=250 align=center cellspacing=0 cellpadding=0>\n"; // Set initial group values $lastgroup = ''; // Query database $sql = "SELECT * FROM table ORDER BY name ASC "; $res = mysql_query($sql) or die(mysql_error()); while ($rows = mysql_fetch_assoc($res)){ // Print Group header if ($rows['name'] != $lastgroup) { // Print Group Name echo "<tr> <td colspan=2 align=left><strong>Group: ".$rows['name']."</strong></td> </tr>\n"; } // Print Database Details echo "<tr> <td width=50> </td> <td width=200 align=center>".$rows['parameters']."</td> </tr>\n"; // Reset group values $lastgroup = $rows['name']; } echo "</table>\n"; ?>
-
Hi Sasa,
At the parts with numbers instead of dashes (-) It prints out this way
226-2119--
128-2129--
It doesn't break at these parts.
Could we use the array instead of the string? Just asking..
-
Thanks guys,
But its not the split thats the problem, its after i split.
for instance this is the string - &=119=-&=128=2&=129=3&=130=-&=132=-&=141=-&=152=-&=153=-&=154=-&=155=-&=186=-&=195=-&=198=-&=223=-&=226=2&=119=-&=128=-&=129=-&=130=-&=132=-&=141=-&=152
I want to display it like
119 - -
128 - 2
129 - 3
that way.
-
I am working a database retrival code and I can only obtain partial data from a string.
$rows['serial_value'] is a string made of a combination of two distinct values separeted by = and & symbols.
How would I obtain the two values and out put them separetly?
This is the query:
$depts = $db->Execute("SELECT $dbtable.serial_value,$dbtable.type,$dbtable.group_id,$table.name,$table.nr,$table.normals,$table.msr_unit FROM $dbtable,$table WHERE ($table.group_id = $dbtable.group_id) AND $dbtable.job_id = '$batch_nr' ORDER BY group_id ASC"); while($rows= $depts->FetchRow()){ $h = $rows['serial_value']; // This is a string $keywords = preg_split ("/[\=,\&]+/", "$h"); // Remove the = and & symbols in the string }
-
Well guys,
This sorts that problem out
$depts = $db->Execute("SELECT $dbtable.serial_value,$dbtable.type,$dbtable.group_id,$table.name,$table.nr,$table.normals,$table.msr_unit FROM $dbtable,$table WHERE ($table.group_id = $dbtable.group_id) AND $dbtable.job_id = '$batch_nr' ORDER BY group_id ASC");
But there is another problem:
serial_value is a string that I am retriving from the database. So where I have 2 group_id's matching say with the man woman groups above, I expect two rows of data however I can only retrive for one row only for the serial value field. why is this?
while($rows= $depts->FetchRow()) { echo $rows['serial_value']; }
-
It should be like
Man
AMOEBIC HAEMOGUTINATION
BRUCELLA TEST
Woman
BLOOD GROUP & RHESUS
CD4/CD8
-
Yes,
It's an int.
the display is not good.
Man
AMOEBIC HAEMOGUTINATION
Woman
BLOOD GROUP & RHESUS
Man
BRUCELLA TEST
Woman
CD4/CD8
Woman
this is the display code
$echo '<tr >'; $echo '<td> '.$rows['group_id'].' </td>'."\n"; $echo '</tr>'; $echo '<tr >'; $echo '<td> '.$rows['name'].' </td>'."\n"; $echo '<td width="149" valign="top"> '.$rows['normals'].' </td>'."\n"; $echo '<td> '.$rows['msr_unit'].'</td>'."\n"; $echo "<td width=149 valign=top> $rval[$counterup] </td>"; $echo '</tr>';
-
Let me include the unique field,
1.table A - fields(batch,groupname,name)
2.table B - fields(batch,groupname,values,result)
I need to display data from the tables in the following way
groupname
name values
result
groupname
name values
result
The field batch is unique.
The variable $batch is passed through a $_GET to out put the data from the select statement.
For every group name i have the name, values and result underneath.
How can I do this?
-
SELECT <column_name> FROM <Table1>, <Table2> WHERE (Table1.column = Table2.column)
ie
SELECT tableB.groupname,tableB.values,tableB.result FROM tableA, tableB WHERE (tableA.groupname= tableB.groupname)
the groupname value is being passed from a form. How can you change this query to include that?
-
Hi,
I've got 2 tables with the following fields.
1.table A - fields(groupname,name)
2.table B - fields(groupname,values,result)
I need to display data from the tables in the following way
groupname
name values
result
groupname
name values
result
For every group name i have the name, values and result underneath.
How can I do this?
-
How do I function stop?
-
I've used it,It still only gets the first value.
It's also a bit buggy, (sorry i should have mentioned this in the first post) It prints out man twice.
this is the out put -
man man
-
Hi,
I am trying to pass an array into a function but it keeps giving me errors.
this is the array
$group = array("man","woman");
This is where i pass it from
$tparams=&$lab_obj->TestParamsShow($group )
This is the function
function TestParamsShow($group_id=''){ global $db; while (list($key, $val) = each($group_id)) { echo "$val"; $this->sql="SELECT * FROM $this->tb_test_param WHERE group_id ='$val' AND status NOT IN ($this->dead_stat) ORDER BY torder ASC"; if($this->tparams=$db->Execute($this->sql)){ if($this->rec_count=$this->tparams->RecordCount()) { return $this->tparams; } else {return FALSE;} }else {return FALSE;} } }
The echo "$val"; only outputs the first value in the array - man. Why?
-
This worked. Thanks.
If it's ok in a text area then
echo nl2br($notes);
-
1. Yes, I want to break up the out put that way as in:
1.One
2.Two
3.Three
I've realised that, If I out put the data from the database in a text area, if formats itself fine,Without using any functions. What's wrong with the <td></td> tags then?
-
You mean preg_replace() ?
-
Thanks,
But the output is still jumbled up.
How can I display the beginning and end of a sentence? To distinguish diffrent sentences?
-
Ok,
The notes field in the database is of datatype text.
$depts = $db->Execute("SELECT * FROM test_find WHERE job_id='$batch_nr'");
while($row= $depts->FetchRow()){
$notes = $row['notes'];
}
<td><?php echo $notes; ?></td>
This gives the following out put :
1.The little fox jumped over a green hedge.2.The hare ate fish.3.The little fox jumped over a green hedge
4.Alligator jumped a green hedge.5.The little fox jumped over a green hedge
-
Fruitless - no action, nothing happening.
Thanks, It works.
-
Hi guys,
I've the following information that I retrive from the database :
1.The little fox jumped over a green hedge.2.The hare ate fish.3.The little fox jumped over a green hedge
4.Alligator jumped a green hedge.5.The little fox jumped over a green hedge
How would I display it thus :
1.The little fox jumped over a green hedge
2.The hare ate fish
3.The little fox jumped over a green hedge
4.Alligator jumped a green hedge.
5.The little fox jumped over a green hedge
-
Is it possible to use SELECT,ORDER BY AND WHEREcommands in mysql and get results? I've tried it in the query below but it's fruitless. Where am I going wrong?
$sql = "SELECT * FROM $dbtable WHERE branch = $brn ORDER BY group_id ASC , name ASC LIMIT 40,43 ";
-
I changed the first value of the array $rval to 2 ,previously it was -. Then I changed the if statement to
if ($rval != 2) and it worked fine.
Is there a problem of if statements and strings?
-
Hi guys,
It seems array issues just never end.
I have this while loop below which displays data from a table. These are elements with this array
$tp['name']
Inside the while loop is a counter variable which increments at every loop. This is used to display the elements from the $rval array.
$rval array values have this '-' (hyphen). There is an if statement to remove these array elements, which it does apart from the very first array value $rval [0]. It never get removed. Why???
$tests = $db->Execute("SELECT * FROM care_test_param WHERE group_id ='$param_gp'"); while($tp = $tests->FetchRow()){ if ($rval[$counterup] != '-') { <tr class='; if($toggle) { $cache .= '"wardlistrow1"';}else { $cache .= '"wardlistrow2"';} > <td> echo '.$tp['name'].' </td>'."\n" <td> echo '.$tp['msr_unit'].' </td>'."\n" <td> echo '.$tp['lo_bound'].'</td>'."\n" <td> echo '.$rval[$counterup].' </td>'."\n" </tr> $toggle=!$toggle; } $counterup++; }
Grouped display
in PHP Coding Help
Posted
Sorry about that,
That's the way it should be.