Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Not so simple if else problem...
Old 06-14-2005, 10:15 PM Not so simple if else problem...
waller's Avatar
Skilled Talker

Posts: 59
Location: North Borneo.
Trades: 0
let say i have a table 'tasks' where:-

uemail-varchar(50)PKey
name-varchar(50)
task_date-DATE

PHP Code:
<?php
//This is a recordset named taskset:

30 $task_date="2005/06/10";
31 $xuemail="abc@asd.com";

33 mysql_select_db($database_myodbc$myodbc);
34 $query_taskset "SELECT * FROM tasks WHERE task_date='$task_date' AND uemail='$xuemail'";
35 $taskset mysql_query($query_taskset$myodbc) or die(mysql_error());
36 $row_taskset mysql_fetch_assoc($taskset);
37 $totalRows_taskset mysql_num_rows($taskset);

39 if($totalRows_taskset){ //if recordset taskset's row is not empty
40 ?>
41        <li><? echo $row_taskset['name']; ?></li><br>
42 <?
43 
}
44 }while($row_taskset mysql_fetch_assoc($taskset));
45 ?>
I use this code to display the "$row_taskset['name']"
for certain date. For example, in the table,
date="2005/06/10" I have name="joe".
for date="2005/06/09" I have name="mike".
Suppose it only display "joe", but instead it
displays..

joe
mike

.I'm not quite sure about line 39 and 44.
__________________
$id ="waxxer";
$id = str_replace('x', 'l', $id);
echo $id;
echo " and Marj";
waller is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-14-2005, 10:47 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Is that the whole code? What you have there shouldn't even parse. You either need a do { somewhere to match the } while (), or you need to change to another type of loop structure. Are there going to be multiple names for a given date, or always only one?

I'd probably rewrite it like this:
PHP Code:
<?php
//This is a recordset named taskset:

$task_date="2005/06/10";
$xuemail="abc@asd.com";

mysql_select_db($database_myodbc$myodbc);

$taskset mysql_query("SELECT * FROM tasks WHERE task_date='$task_date' AND uemail='$xuemail'"$myodbc) or die(mysql_error());
while(
$row_taskset mysql_fetch_assoc($taskset)) { 
echo 
"<li>".$row_taskset['name']."</li><br>";
}
?>
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 06-15-2005, 02:06 AM
waller's Avatar
Skilled Talker

Posts: 59
Location: North Borneo.
Trades: 0
Sorry...its not the entire code. But i'll try yours and see what happen. Thanks.
__________________
$id ="waxxer";
$id = str_replace('x', 'l', $id);
echo $id;
echo " and Marj";
waller is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Not so simple if else problem...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11691 seconds with 12 queries