DS928
asked on
Making a line break, MySQL and PHP
I am running a query in MySQL and PHP. THe query worrked until I needed to put Name and Address on two different lines, can't seem to find out how it works. Here is the code.
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"RestName<br/>Address");
$f2=mysql_result($result,$i,"Phone");
$f3=mysql_result($result,$i,"Price");
$f4=mysql_result($result,$i,"Rating");
Also if it matters address is the result of a CONCAT.
ASKER
Thank you. This is the query.
$query="SELECT tblLocations.CityID, tblLocations.AreaID, tblLocations.CuisineID, tblRestaurants.RestName,
CONCAT(tblLocations.StreetNumber,' ', tblLocations.Street) Address,
tblLocations.Phone, tblDetails.Price,tblDetails.Ratings
FROM tblRestaurants
INNER JOIN tblLocations ON tblRestaurants.RestID = tblLocations.RestID
INNER JOIN tblDetails ON tblLocations.RestID = tblDetails.RestID AND tblLocations.LocationID = tblDetails.LocationID
WHERE tblLocations.CityID='$Doggie'
AND tblLocations.AreaID='$Kitty'
AND tblLocations.CuisineID='$Pig'
ORDER BY tblRestaurants.RestName ASC";
Ok, so in this section it should look something like this:
And then you should handle showing $f1 and $f2 on separate lines in your output code (if you show me your output echo statements I can give you some idea there too).
Also, if this address query is working then you can ignore this but I normally see this line of your query like this:
(note the AS)
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"RestName");
$f2=mysql_result($result,$i,"Address");
$f3=mysql_result($result,$i,"Phone");
$f4=mysql_result($result,$i,"Price");
$f5=mysql_result($result,$i,"Rating");
And then you should handle showing $f1 and $f2 on separate lines in your output code (if you show me your output echo statements I can give you some idea there too).
Also, if this address query is working then you can ignore this but I normally see this line of your query like this:
CONCAT(tblLocations.StreetNumber,' ', tblLocations.Street) AS Address
(note the AS)
ASKER
Here is the output.
Its should print like this.
Name
Address
Not like this..
Name Address
<tr>
<td bgcolor="#FFDAA6"> </td>
<td width="325"><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<td width="150"><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>
<td width="100"><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td width="100"><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
</tr>
Its should print like this.
Name
Address
Not like this..
Name Address
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, thank you. the errors are finally gone, but I am not receiving an output anymore.
HOK I rem out the output line for Name Address and I get these two errors.....I assume the second is because of the first.
Warning: mysql_result() [function.mysql-result]: RestName<br/>Address not found in MySQL result index 3 in /home/content/d/s/t/dstr3/ html/MENUH EAD/Steele rs/result_ city.php on line 173
Warning: mysql_result() [function.mysql-result]: Rating not found in MySQL result index 3 in /home/content/d/s/t/dstr3/ html/MENUH EAD/Steele rs/result_ city.php on line 176
<td width="325"><font face="Arial, Helvetica, sans-serif"><?php echo $f1 . "<br />" . $f2; ?></font></td>
HOK I rem out the output line for Name Address and I get these two errors.....I assume the second is because of the first.
Warning: mysql_result() [function.mysql-result]: RestName<br/>Address not found in MySQL result index 3 in /home/content/d/s/t/dstr3/
Warning: mysql_result() [function.mysql-result]: Rating not found in MySQL result index 3 in /home/content/d/s/t/dstr3/
ASKER
Murphy's Law. It's working! Thank you for your help!
ASKER
Helped me out of that tricky syntax!
If you show the code above this section that does your query I can give some more specifics.