problem with search results

i developed php website connected to mysql database , when the client make a new search the results show in a table like this

look at the colume total time in hr the result appears at the first row i want it to be in the last row for that lawyer like this

i hope any one can help me . and i will include the code i used :


$mysql_query1 = (“SELECT * FROM invoice ORDER BY lawname ASC, date ASC”);
$result = mysql_query($mysql_query1) or die(mysql_error());
$lawname = stripslashes($row[‘lawyername’]);


<?php echo $lawname ;?>
<? } $sum1= mysql_query(" SELECT SUM(timeinhr)as totalhr FROM `invoice`"); $my_sum1=mysql_fetch_array($sum1); ?> <?php if($tempsumName!="$my_sum1[totalhr]") { $tempsumName="$my_sum1[totalhr]";?>
<?php echo ""; ?>
<? } ?> [/code]

if posible, normalize ur database.

use u lopes insde eachother
SELECT SUM(timeinhr), lawername FROM invoice GROUP BY lawername;

and then use the second one to get all data of one lawer
then u may use a rowspan for timeinhr and lawername, and a valign=“bottom” for timeinhr

hope this helps

i think rowspan is not a good idea as it will give costant value eg: 4
and may be the first lawyer have 5 entries and the second one have just 2 entries and the third one have 7 entries how can i solve this problem.
and i have another problem with valign although it’s = bottom . but the txt seems to be in left rather than bottom .

if u use
SELECT SUM(timeinhr) as time, COUNT(timeinhr) as rows, lawername FROM invoice GROUP BY lawername;
… then u have the number of rows with the first query

so u’ll get no probs with the rowspan, and as soon as u use rowspan valign=“bottom” will do its job. btw: left or right is set in align not in valign

now i got the idea but ur code doesn’t work with me ,cos my new database differ somehow from the code i wrote , so the code that i want should count how many rows for that lawyer name for eg : Jim has 3 entries and Magy has 7 entries so the code give me 3 then 7 in array so that when i apply it on rowspan=$rowno it gives me right value.
sorry about my english :smiley:

somehow i solve the prob by this code


$amount = mysql_query("SELECT count(lawname) as amount FROM invoice where lawname=’$lawnamee’ GROUP by lawname ");
while($row = mysql_fetch_array($amount)){


<?php echo $totalhre ; ?>
<? } ?>[/code]

but this code keep giving me repeated value because of first while ( not appear in the above code ) which gets all data from the database , so it repeates the above code accourding to no. of rows in data base .
Can i have any help in this prob .

Sponsor our Newsletter | Privacy Policy | Terms of Service