sw0o0sh Posted August 3, 2006 Share Posted August 3, 2006 Hi, Im working on a miniature forum using my own stupid techniques, and I have a table called "chaoworld_chat". To make this simple, I have two rows im going to share, one called id, and the other topic .Ive been messing around with code to try and LIST the topic names while its being ordered with the ID number.[code]$result = mysql_query("SELECT * FROM chaoworld_chat ORDER BY id");while($r=mysql_fetch_array($result)){ $name=$r["topic"]; echo "$name<br>";}[/code]I know I'm doing something wrong here.. can anyone help me fix my error..Pretend theres 3 topics,topic name : hi ; Id = 3topic name: hello; Id = 1topic name: bye; id = 2I need this code fixed so it gives me ..hellobyehiOn a page when called from the mysql table.. thanks. Link to comment https://forums.phpfreaks.com/topic/16409-problem-ascending-information-from-mysql/ Share on other sites More sharing options...
.josh Posted August 3, 2006 Share Posted August 3, 2006 any error messages? not showing expected results? can you be more specific? Link to comment https://forums.phpfreaks.com/topic/16409-problem-ascending-information-from-mysql/#findComment-68315 Share on other sites More sharing options...
sw0o0sh Posted August 3, 2006 Author Share Posted August 3, 2006 I want the mysql query to list my topic names by order of ID number on a php page. Link to comment https://forums.phpfreaks.com/topic/16409-problem-ascending-information-from-mysql/#findComment-68317 Share on other sites More sharing options...
sw0o0sh Posted August 3, 2006 Author Share Posted August 3, 2006 [quote author=redarrow link=topic=102819.msg408629#msg408629 date=1154579427]Does this help.<?php$query="SELECT * FROM chaoworld_chat ORDER BY id DESC";$result = mysql_query($query);while( list($key,$val)=each($result) ) { echo"$key;$val";}?>ps what error?[/quote]Warning: Variable passed to each() is not an array or object in E:\Internet Information Services\Webs\FTP\com.davessonicsite.www\chaoworld\main.php on line 15No it does help. All I want to do is list the topic name in order by the id on a php page in an array.. Link to comment https://forums.phpfreaks.com/topic/16409-problem-ascending-information-from-mysql/#findComment-68320 Share on other sites More sharing options...
redarrow Posted August 3, 2006 Share Posted August 3, 2006 [code]<?php$query="SELECT * FROM chaoworld_chat ORDER BY id DESC";$result = mysql_query($query);while($record=mysql_fetch_assoc($result)){ $record['name']; }?>[/code] Link to comment https://forums.phpfreaks.com/topic/16409-problem-ascending-information-from-mysql/#findComment-68321 Share on other sites More sharing options...
sw0o0sh Posted August 3, 2006 Author Share Posted August 3, 2006 Fatal error: Call to undefined function: () in E:\Internet Information Services\Webs\FTP\com.davessonicsite.www\chaoworld\main.php on line 19 Link to comment https://forums.phpfreaks.com/topic/16409-problem-ascending-information-from-mysql/#findComment-68322 Share on other sites More sharing options...
redarrow Posted August 3, 2006 Share Posted August 3, 2006 add the database post your code please cheers Link to comment https://forums.phpfreaks.com/topic/16409-problem-ascending-information-from-mysql/#findComment-68323 Share on other sites More sharing options...
sw0o0sh Posted August 3, 2006 Author Share Posted August 3, 2006 [img]http://img486.imageshack.us/img486/268/databasehx7.png[/img][code]<?if (!$link = mysql_connect('localhost', 'davessonicsite', 'mmhmm')) { echo 'Could not connect to mysql'; exit;}if (!mysql_select_db('davessonicsite', $link)) { echo 'Could not select database'; exit;}$query="SELECT * FROM chaoworld_chat ORDER BY id DESC";$result = mysql_query($query);while($record_fetch_assoc($result)){ $record['topic']; }?>[/code].. all i want is the topic names displayed on a PHP page ordered by the id numbers.. Link to comment https://forums.phpfreaks.com/topic/16409-problem-ascending-information-from-mysql/#findComment-68325 Share on other sites More sharing options...
redarrow Posted August 3, 2006 Share Posted August 3, 2006 [code]<?php$db = mysql_connect("localhost" , "davessonicsite", "mmhmm");mysql_select_db("databasename",$db)OR DIE("Error database problam");$query="SELECT * FROM chaoworld_chat ORDER BY id DESC";$result = mysql_query($query);while($record=mysql_fetch_assoc($result)){echo"<br>$record['id'] : $record['topic'] : $record['message']<br>";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/16409-problem-ascending-information-from-mysql/#findComment-68328 Share on other sites More sharing options...
ryanlwh Posted August 3, 2006 Share Posted August 3, 2006 what's your current output? Link to comment https://forums.phpfreaks.com/topic/16409-problem-ascending-information-from-mysql/#findComment-68329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.