|
-
March 19th, 2009, 02:59 AM
#1
Help! Php sql
im using PHP MySQL
i have this code
PHP Code:
<? $query1 = mysql_query("SELECT so_trouble_reported.tr, trouble_reported.code as trcode
FROM so_trouble_reported
JOIN trouble_reported ON so_trouble_reported.tr_id = trouble_reported.tr_id
WHERE so_trouble_reported.so_no = $so_no");
$query2 = mysql_query("SELECT so_findings.findings, findings.code as fcode
FROM so_findings
JOIN findings ON so_findings.findings_id = findings.findings_id
WHERE so_findings.so_no = $so_no");
$query3 = mysql_query("SELECT so_service_performed.sp, service_performed.code as spcode
FROM so_service_performed
JOIN service_performed ON so_service_performed.sp_id = service_performed.svc_per_id
WHERE so_service_performed.so_no = $so_no");
for($ctr=0;$ctr<=3;$ctr++)
{
?>
<tr>
<td align="center" class="txtformat1"><? echo mysql_result($query1,$ctr,'trcode')?>; <? echo mysql_result($query1,$ctr,'tr')?></td>
<td align="center" class="txtformat1"><? echo mysql_result($query2,$ctr,'fcode')?>; <? echo mysql_result($query2,$ctr,'findings')?> </td>
<td align="center" class="txtformat1"><? echo mysql_result($query3,$ctr,'spcode')?>; <? echo mysql_result($query3,$ctr,'sp')?></td>
</tr><? } ?>
as u can see i have 3 queries and print its value using a mysql_result function.
i made a $ctr to print it until 4 values. if theres is a value fetched from the $query the printing is OK. but if the $query dont get values. the printing says:
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 5 in C:\xampp\htdocs\SOMS\view_service_order.php on line 261
now what i want to do is when the $query dont retrieved any values it will print a "SPACE"
i want to put a condition were if no values retrieved it will change variables to "SPACE"
else if values retrieved print values.
HELP!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|