473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Array Formating and Display Error

384 256MB
I have this function below and it takes in the id of the article and the table its from in the database.
The first query will return a string like so ;1|;4|;7|;8| which is assigned to $format_array, what im trying to do in the second query and loop is to check the id returned from each row of review_format table and if its equal to one of the numbers in the $format_array that it will echo out to screen "checked".
Expand|Select|Wrap|Line Numbers
  1. function display_edit_format($id,$table) {
  2.  
  3.     $sql = mysql_query("SELECT format FROM ".$table." WHERE id=".$id."");
  4.     while ($row = mysql_fetch_array($sql))
  5.     {
  6.         $i = 0;
  7.         $format_array = $row['format'];
  8.         $array_size = sizeof($format_array);
  9.  
  10.         $sql = mysql_query("SELECT id,description FROM review_formats");
  11.         while ($row = mysql_fetch_array($sql))
  12.         {
  13.             echo'<input type="checkbox" name="format[]" value=";'.$row['id'].'|" class="form"';
  14.                 for($i = 0;$i < $array_size;$i++)
  15.                 {
  16.                     if($row['id'] == $format_array[$i])
  17.                     {
  18.                         echo' checked';
  19.                     }
  20.                 }
  21.             echo'>'.$row['description'].'<br>';
  22.         }
  23.     }
  24. }
Sep 28 '08 #1
1 1169
Atli
5,058 Expert 4TB
Hi.

If your first query is returning all those ID's as a single string (which is a bad idea btw. See this article to see more), then you will have to split them up before you can loop through them as an array.

Check out the explode function to do that.
Sep 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Polar | last post by:
I have a database that stories entries of short stories for a writers website. I can easily input the data into MYSQL but my trouble lies in retrieving the data. the story in just cut and...
6
by: Krackers | last post by:
How do you write a function which returns a reference to an array. I can only get a function to return a copy of the array itself. I've had a look at some other threads in this group an the return...
2
by: Jamie Fryatt | last post by:
I have a querystring that passes through the value 001 for example, the form on the receiving page need to display that number but with 1 added to it. i have dim strnum strnum =...
2
by: rudy | last post by:
I am trying to highlight the output of a field to display something similar to conditional formating. Would prefer to display the result with a code instead of a colored font or colored background...
8
by: ulyses | last post by:
I'm trying to put pointer to flexible array of structures in other structure. I want to have pointer to array of pixels in screen structure. Here is mine code, but I think it isn't quite all right:...
0
by: k1ckthem1dget | last post by:
I need to display the unsorted list of names and display the sorted list of names. My program is getting a bunch of errors though, and i dont know why. I am getting the following errors. 28:...
2
by: k1ckthem1dget | last post by:
I need to display the unsorted list of names and display the sorted list of names. My program is getting a bunch of errors though, and i dont know why. I am getting the following errors. 28:...
7
by: ianenis.tiryaki | last post by:
well i got this assignment which i dont even have a clue what i am supposed to do. it is about reading me data from the file and load them into a parallel array here is the question: Step (1) ...
2
by: assgar | last post by:
I am having problems getting the user selected form info to inserted into the mysql database. I am also rec eving an error: Warning: Variable passed to each() is not an array or object in ...
4
by: kent | last post by:
Hi, If a block box appears in an inline formating context, it will start a new line box. However, I can't find where this is stated in the CSS spec. Any pointer? Thanks!
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.